You are on page 1of 86

.



1.
2.
: 5.
6.
8.
:9..
) (10.
) (13....
: 26
)(27
)(54.
)62..(PWM
) (69
) (77.
84

:


) ( .
.

.
.

:
.
. .
.


.
. .



) .(

.

) (.


.
http://arduino.cc/en/main/boards

10

) Arduino
.( Uno

) (

) ( Breadboard

11

) ( Resistors
.


) ( LED

)(jumper wire

12

13


.

.
.

14

-1
:

15

-2 ) (Add-Ons
) ( Get Hardware Support Packages
:

16

- 3 )(Install from Internet


) .( NEXT

17

- 4
:
: ) ( Arduino
.
: ) ( Arduino Due
.
: ) ( Arduino Uno/Nano/Mega2560
// .
.
) .( NEXT

18

- 5
) .( NEXT

19

- 6 ) .( NEXT

20

- 7 ) .( Install

21

- 8
. .

22

- 9
) .( Finish

23

- 10
) .( Simulink Library

24

- 11

) .( Simulink Support Package for Arduino Hardware

25

26

) (:

:
) ( Arduino Uno
) ( Breadboard
330
) ( LED

27

: .
LED pin 2 .
:
NEW .simulink modle

28

:
.
) .( simulink library

29

) ( simulink library

.

:
.1 ) ( Puls Generator
.2 ) (Digital Output LED
.3 ) ( Scope

30

:
.

Puls
Generator
Sources
.

Digital Output .Arduino





.common


Common
Digital Output .

31


Scope
Sink
) (.



.

.

32

scope

pulse

) ( digital output

33

:
.

Digital Output

.
) 2 (.

34

Puls Generator

.

:

.1 0 6 ) (
.2 3 2
.3
1
.4 0 2
) (
35

.Puls Generator

36

) Pulse type
(
Sample based : ) (
.
Time based : ) (
Sample
.based

:Samples

) Samples ( .
13 13 ) ( Samples
.

37

) Time (t
.use simulation time

Amplitude
.1

Period
) ( number of samples

10 ) samples 10
10 (.

Pulse width
.


10
5 5.
7 3.

38

Phase delay

.

Sample time
0.2.

:
10 .
0.2 2.

) .( Sample time * Period
2 ) 1
1 ( LED .

.OK

39

) ( Run
.
) ( Run .

40

) (
.
.

) (

.
10 ) 5 (

:

41

) ( semulation stop time


. 10 5
) ( Run .
.

42

: ) ( semulation stop time



.

43

Number
.of axes 1 2 OK
) ( Run
:

44


.
Number of axes
2 1
.

45

History
:

46

Style :


.
OK ) ( Run
.

47


) Y ( . Y

:

Axes properties :

48

Y-max Y-min
.OK ) ( Run .

49

:
USB ) ( tools
:

50

) ( Run on Target Hardware


) ( Prepare to Run
:

) ( Prepare to Run
) Uno Mega (
:

) .( Arduino Uno

51

.OK

52

:
) ( Deploy to Hardware :

LED
.

:
https://www.youtube.com/watch?v=H4Tk8owL1GI

53

) (:

:
) ( Arduino Uno
) ( Breadboard
2 ) ( Bush Button
330
2 1
) ( LED

54

: .
LED pin 1 pin 7
pin 13 .
:
NEW .simulink modle
: ) ( simulink library
:
.1 ) ( Digital Input

.2 ) (Digital Output LED
.3 ( AND Gate ) AND
.4 ) ( Scope
:
.


AND

Logic and Bit Operations .

55


Digital Input

Arduino common
. .


)
(.

) ( digital input
AND ) ( digital output

) ( digital input
scope

56

:
.

Digital Input

.
) 7 (.

Digital Input

.
) 13 (.

57

Digital Output

LED .
) ( LED ) 1 (.

) (
.

:

3 .Number of axes
.

58

AND
. :

OPERATOR .
.AND

59


.Number of input port


.icon shape

RUN
.

AND
AND :


) ( Input 1 ) ( Input 2 ) ( Output
0F 0F 0F
0F 1F 0F
1F 0F 0F
1F 1F 1F

) 5 = 1 ( LED
) 0 = 0 ( LED

60

:

LED .

LED .

LED .

LED.

:

) .( Deploy to Hardware

LED
.

:
https://www.youtube.com/watch?v=Sf1OanjGPIk

61

):( PWM

:
) ( Arduino Uno
) ( Breadboard
330
) ( LED

62

:PWM
) .( from Digital to Analog
5 ) 0 5 (.
) 0 5 (.
PWM .

: .
LED pin 9 . PIN 9
.PWM Arduino Uno

~


PWM
) ( 11 10 9 6 5 3 .PWM
PWM .
PWM 8 ) ( 8 bit
256 ) 0 .( 255

: .

63

: ) ( simulink library
:
.1 PWM
.2 Repeating Sequence
.3 ) Scope (
:
.

PWM
Arduino
.common
.
.


Repeating
Sequence
.Sources

64


) (.

:
.

PWM
LED .

) ( LED 9
) (.

65

Repeating Sequence

.LED

) Time values LED (.


) Output values .( LED
.
) 0 ) (0 0.2 (30
) 0.4 ) (60 0.6 (100
) . 1 ) . (255 2 (0
255
. Time values
.Output values

66

RUN
.

) (
.Scope :

.
AutoScale .

67

AutoScale :

:

) .( Deploy to Hardware

LED
255 .

:
https://www.youtube.com/watch?v=vz-CAHV2H2k

68

) (:

:

) ( Arduino Uno
) ( Breadboard
) ( ServoMotor

69

:servomotor
) 0 180 (

.
) (.
servomotor .
servomotor .
servomotor

servomotor

servomotor

70

: .
.
) PIN 0 ( 13
.PIN 10

: .

: ) ( simulink library
:
.1 Standard Servo Write
.2 Repeating Sequence Stair
.3 ) Scope (

:
.

Standard Servo Write Arduino


.common
.
.

71

Repeating Sequence Stair .Sources



.


) (.

72

:
.

Standard Servo Write




.
) 10 (.

Repeating Sequence Stair



.

73

Repeating Sequence Stair


Vector of output values
] .[ 0:1:180 180:-1:0
0:1:180
0 1 180.
180:-1:0
180 1 ) (
0.
] [ 0:3:60 60:-3:0 .

Sample time
) 0.01
(.
] [ 0:1:180 180:-1:0 1
0.01.
] [ 0:3:60 60:-3:0 3
0.01.

74

RUN
.

) (
.Scope :

:
AutoScale .

75

:

) .( Deploy to Hardware


180

:
?https://www.youtube.com/watch
v=NGcVMZdCWWI

76

) (:

:
) ( Arduino Uno
) ( Breadboard
) ( ServoMotor
) ( Potentiometer

77

: .
.
) PIN 0 ( 13
.PIN 8


)
( .
) .( Analog Input

.
6
) A0 ( A5
.A0
10 ) ( 10 bit
1024 ) 0 .( 1023

: .

78

: ) ( simulink library
:
.1 ) ( Analog Input

.2 Gain
.3 Standard Servo Write

:
.

Analog Input Arduino


common


. .

Gain
Math
.Operations
.

Standard Servo Write


.
79


) (.

:
.

Analog Input


.
) A0 (.
0.01 .Sample time

80

Standard Servo Write




.
) 8 (.

Gain


. 0.176 .Gain

:
1024 )(1023 - 0
).(180 - 0

81

A 0

1023 .B
1023 .
180
180 1023 0.176
.Gain

:Gain
255
Gain 0.176
44.88 44.88.
1023
Gain 0.176
180 180.

RUN
.

82

:

) .( Deploy to Hardware



) 0 180 - (.

:
?https://www.youtube.com/watch
v=mO450hzd7og

83

.
.
:

http://www.mathworks.com/hardware-support/
arduino-simulink.html
http://makerzone.mathworks.com/arduino/
#featured
https://www.youtube.com/watch?
v=_OLctOFjjYQ&spfreload=10
https://www.youtube.com/watch?
v=vAG3Tri7QeM
https://www.youtube.com/watch?v=EjVHlJqMtK0
http://www.mathworks.com/matlabcentral/
fileexchange/41906-arduino-s-function-for-
mpc4725-i2c-dac
http://www.automatedtrader.net/articles/
42/143277/creating-driver-blocks-for-
arduino--lego--and-other-targets

84

You might also like