Anda di halaman 1dari 3

PICAXE products are developed and distributed by Revolution Education Ltd

Unit 2 Bath Business Park, Foxcote Ave, Bath, BA2 8SF, UK

PWMOUT / H-Bridge

This circuit uses a PicAxe 08M2 to drive an H-Bridge chip that in turn controls the
12-VCD motor.
Blue jumper wires are connected to the common (0) and green jumpers connect to
the voltage coming from the power supply, not the 5VDC power. This allows the
motor to be run on any voltage up to the power supply voltage.
The H-Bridge is capable of running two motors buy this is set up for just one.
Wiring Connections:
H-bridge leg 1 to PicAxe pin 2 (motor 1 enable pin used with pwmout)
H-bridge leg 2 to PicAxe pin 1 (one of two pins needed for reverse and stop, motor 1)
H-bridge leg 3 to motor1
H-bridge leg 4 to ground (blue breadboard rail) (also used as a heat sink)
H-bridge leg 5 to ground (blue breadboard rail) (also used as a heat sink)
H-bridge leg 6 to motor 1
H-bridge leg 7 to PicAxe pin 4 (one of two pins needed for reverse and stop, motor 1)
H-bridge leg 8 to input voltage + (red input breadboard rail)
(up the other side)
H-bridge leg 9 no connection (motor 2 enable pin used with pwmout)
H-bridge leg 10 no connection (one of two pins needed for reverse and stop, motor 2)
H-bridge leg 11 no connection (motor 2)

PICAXE products are developed and distributed by Revolution Education Ltd


Unit 2 Bath Business Park, Foxcote Ave, Bath, BA2 8SF, UK
H-bridge leg 12 ground (also used as a heat sink)
H-bridge leg 13 ground (also used as a heat sink)
H-bridge leg 14 no connection (motor 2)
H-bridge leg 15 no connection (one of two pins needed for reverse and stop, motor 2)
H-bridge leg 16 to input voltage +
PicAxe Program:
symbol duty =w0
pwmout pin,period,duty
symbol maxspeed = 1000
1024 is the largest number allowed for duty
symbol minspeed = 700
change this to see what happens
symbol ratechange = 150
change this to see what happens
main:
pwmout 2, 250, 800
starts the motor at a medium speed
High 1
' enable forward set by these two lines
Low 4
for w0 = minspeed to maxspeed step 10 ' increase speed
pwmout 2, 250, w0
pause ratechange
next w0
pause 4000

' Run time at maximum speed

for w0 = maxspeed to minspeed step -5 ' decrease speed


pwmout 2, 250, w0
pause ratechange
next w0
low 1
' stop motor
low 4
Pause 1000

'stopped time

low 1
high 4

' enable reverse while the motor is stopped

for w0 = minspeed to maxspeed step 5 ' increase speed reverse


pwmout 2, 250, w0
pause ratechange
next w0
pause 2000

' Run time

for w0 = maxspeed to minspeed step -5 ' decrease speed reverse


pwmout 2, 250, w0

PICAXE products are developed and distributed by Revolution Education Ltd


Unit 2 Bath Business Park, Foxcote Ave, Bath, BA2 8SF, UK
pause ratechange
next w0
Pause 2000

run time at lowest speed

low 1
low 4

' stop motor

Pause 1000

' stopped time

goto main

' do it again

Anda mungkin juga menyukai