H-bridge
TURKEYUSA
Posts: 4
I wrote the following code to run·a dc·motor forward·3 sec,·stop 3 sec and then run reverse 3 sec. However it runs 3sec forward·and then imidiately runs 3 sec reverse then it·pauses for 3 sec.· Does anybody know why?·When both output 8 and 10 set to 1 or 0(1,1)(0,0) it doesnt run. I attached the picture for wiring reference. I also used http://robotroom.com/HBridge.html·for the H bridge.
Regards,
OUTPUT 8
OUTPUT 10
main:
OUT8=1
OUT10=0
PAUSE 3000
OUT8=1
OUT10=1
PAUSE 3000
OUT8=0
OUT10=1
PAUSE 3000
GOTO main
Regards,
OUTPUT 8
OUTPUT 10
main:
OUT8=1
OUT10=0
PAUSE 3000
OUT8=1
OUT10=1
PAUSE 3000
OUT8=0
OUT10=1
PAUSE 3000
GOTO main
Comments
You should start/stop with the IC pin2 and go FWD/REV with pin4.
You should use HIGH 8, LOW 8 and HIGH 10, LOW 10 to change the states of the STAMP outputs.· [noparse][[/noparse]Yes, declare them as OUTPUTs first, then use HIGH/LOW to change states.]
On the TC4424 pins 2 and 4 are the control lines and essentially they can be reversed.· When·both pins are HIGH or LOW, this effectively acts as a "brake" to the motor.
That said, if you are driving one pin HIGH, then the other pin must be driven LOW.· and vise versa.· Refer to the link that you provided... notice the asterisk indicating
the PWM situation for forward.· The opposite would be true for reverse.
As PJ said, use HIGH 8, LOW 8 and HIGH 10, LOW 10 to change the states of the STAMP outputs.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I understand the concept but my programming knowledge is only 6 hours old. I was able to write the code from the given samples from the tutorials. At this point I still don’t know how I can output first then use high and low.
I used pin8 on BS2 for pin4 on IC(P10 for pin2). I wrote the following code; unfortunately the result is still the same. Is my code totally wrong? How should I change it?
Best regards,
' {$STAMP BS2}
OUTPUT 8
OUTPUT 10
main:
HIGH 8
LOW 10
PAUSE 2000
HIGH 8
HIGH 10
PAUSE 3000
HIGH 10
LOW 8
PAUSE 3000
GOTO main
When·I enter the following code it rottates in only one direction
' {$STAMP BS2}
OUTPUT 8
OUTPUT 10
main:
LOW 8
HIGH 10
PAUSE 3000
HIGH 8
HIGH 10
PAUSE 3000
LOW 8
LOW 10
PAUSE 3000
GOTO main
Post Edited (TURKEYUSA) : 4/27/2006 11:19:22 PM GMT
i was doing the same thinng but missing the 4th step ('does this stop2?
).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
· N.B. -- It's not really a STOP (like a brake), it just puts both Motor terminals at the same potential (GND or +); it cuts the juice.
rotation will be restricted due to the short compared to the same motor without a short.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
You're not done having fun yet! :-)
Please take a look at this version with some additional documentation, and another feature - variable speed. Please note the use of Pin Port NAMES, as opposed to Pin Port NUMBERS. Much easier to understand, and self-documenting too!
/code
'{PBASIC 2.5}
'{STAMP BS2}
'Declare Pin Port Usage
Speed· PIN 10· 'Pin·2 on TC4424 Driver IC
Dir······ PIN··8···'Pin·4 on TC4424 Driver IC
'Declare Constants
Full······ CON 255·· 'Full speed constant
Half····· CON 127·· 'Half speed constant
Quarter CON· 63··· 'Quarter speed constant
Time···· CON 255·· 'Max. time permissible in microseconds
Initialize:
OUTPUT Speed· 'Set Speed Pin Port to Output mode
OUTPUT Dir· 'Set Direction Pin Port to Output mode
'Ensure we are stopped initially
· LOW·Speed
· LOW·Dir
main:
· 'go one way
··HIGH·Speed
··LOW·Dir···· 'Proceed Forward
· PAUSE 3000
· 'does this stop1?
· LOW·Speed
· LOW·Dir
· PAUSE 3000
· 'go other way
··LOW·Speed
··HIGH·Dir···· 'Proceed in Reverse
· PAUSE 3000
··'does this stop2?
··HIGH·Speed
··HIGH·Dir
· PAUSE 3000
'Let's try variable speed!
'Prototype PWM Command (See PBASIC Stamp Manual for details):
'PWM Pin, Duty, Duration
'Run at Full Speed, same as before
·LOW Dir
·PWM Speed, Full, Time
·PAUSE 3000
'Stop for a second
·LOW·Speed
·LOW·Dir
'Run at 1/2 speed
·PWM Speed, Half, Time
·PAUSE 3000
'Stop for a second
·LOW·Speed
·LOW·Dir
'Run at 1/4 speed
·PWM Speed, Quarter, Time
·PAUSE 3000
'Stop for a second
·LOW·Speed
·LOW·Dir
·GOTO main
code/
My apologies if I inadvertantly introduced any syntax errors above, as I wasn't able to run this test code through the Stamp Editor. There are·probably more "LOW Dir" commands above than what is really needed, but I left them in for symmetry during the learning process. In other words, that's how you're used to seeing it.
Once you understand what's going on, I'm sure you'll see which ones can be removed. No harm is done by having them there, it just makes the program longer than it needs to be.
Have fun!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Was bored, so I ran the code through the Editor and no probs - except I had to erase the stamp directives and redo them, wouldnt work without doing that for some odd reason.....other than that, all seems good
Robert
Thanks, I forgot the necessary currency indicator
'{$PBASIC 2.5}
'{$STAMP BS2}
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Currency indicator- hehe. No strings attached-
I can't tell you how many people have problems when first starting with PBASIC because they think that the directives are comments, and leave them out. The directives are necessary!
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com