HB-25 motor controller, Prop-1, and DC motor questions
electrichaunt
Posts: 3
Hello... I have connected the Parallax HB-25 to my Prop-1 controller and ran the motor test using the sample code in the HB-25 documentation. Everything went as expected and now I want to proceed slowly by understanding a few things along the way.
Please see the simple picture and the motor test code below and help me answer these questions:
1. I did the polarity test on the HB-25. The green "power" light illuminated proper, but I noticed the red "fault" light illuminated... just barely... why?
2. in the code below, there is mention of PIN0 in the code description:
"..... this code....written for one HB-25 connected in mode 1 (single) to PIN0"
and then mentioned again:
"LET DIRS= %10000001· 'set PIN0 to output"
and then mentioned:
"Finish: GOTO Finish· 'prevent PIN0 from changing state"
What's the deal with PIN0? the HB-25 is connected to PIN7. I do not understand the involvement of PIN0 at all.
4. Should the setup jumper at PIN7 be placed as a pull-down resistor?
And then finally the big question...... What can I put in the code to make the motor run in the other direction?
Many thanks.
' =========================================================================
'·· File...... HB-25 Motor Test.bs1
'·· Purpose... Tests One HB-25 Connected To P0
'·· Author.... Parallax, Inc.
'·· E-mail.... support@parallax.com
'·· Updated... 08-01-2006
'
'·· {$STAMP BS1}
'·· {$PBASIC 1.0}
'
[noparse][[/noparse] Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motor up, wait 3 seconds then ramp back down to a
' stop.· This code was written for one HB-25 connected in Mode 1 (Single)
' to PIN0.
'
[noparse][[/noparse] I/O Definitions ]
SYMBOL········· HB25 =· 7·············· ' I/O Pin For HB-25
'
[noparse][[/noparse] Variables ]
SYMBOL········· index = B0············· ' Variable Space For Ramp Counter
'
[noparse][[/noparse] Initialization ]
Startup:
IF PIN7 = 0 THEN Startup··············· ' Wait For HB-25 Power Up (P0)
LET············ DIRS =· %10000001······ ' Set PIN0 To Output
PAUSE 5································ ' Wait For HB-25 To Initialize
PULSOUT HB25, 150······················ ' Stop Motor
PAUSE 20······························· ' Wait 20 mS
'
[noparse][[/noparse] Program Code ]
Main:
· FOR index = 150 TO 200··············· ' Ramp Up To Full Speed
··· PULSOUT HB25, index················ ' Motor Forward
··· PAUSE 150·························· ' 150 mS Smoothing Delay
· NEXT
· PAUSE 3000··························· ' Wait 3 Seconds
· FOR index = 200 TO 150 STEP -1······· ' Ramp Back Down
··· PULSOUT HB25, index················ ' Motor Forward Slowing
··· PAUSE 150·························· ' 150 mS Smoothing Delay
· NEXT
Finish:
· GOTO Finish·························· ' Prevent PIN0 From Changing State
Please see the simple picture and the motor test code below and help me answer these questions:
1. I did the polarity test on the HB-25. The green "power" light illuminated proper, but I noticed the red "fault" light illuminated... just barely... why?
2. in the code below, there is mention of PIN0 in the code description:
"..... this code....written for one HB-25 connected in mode 1 (single) to PIN0"
and then mentioned again:
"LET DIRS= %10000001· 'set PIN0 to output"
and then mentioned:
"Finish: GOTO Finish· 'prevent PIN0 from changing state"
What's the deal with PIN0? the HB-25 is connected to PIN7. I do not understand the involvement of PIN0 at all.
4. Should the setup jumper at PIN7 be placed as a pull-down resistor?
And then finally the big question...... What can I put in the code to make the motor run in the other direction?
Many thanks.
' =========================================================================
'·· File...... HB-25 Motor Test.bs1
'·· Purpose... Tests One HB-25 Connected To P0
'·· Author.... Parallax, Inc.
'·· E-mail.... support@parallax.com
'·· Updated... 08-01-2006
'
'·· {$STAMP BS1}
'·· {$PBASIC 1.0}
'
[noparse][[/noparse] Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motor up, wait 3 seconds then ramp back down to a
' stop.· This code was written for one HB-25 connected in Mode 1 (Single)
' to PIN0.
'
[noparse][[/noparse] I/O Definitions ]
SYMBOL········· HB25 =· 7·············· ' I/O Pin For HB-25
'
[noparse][[/noparse] Variables ]
SYMBOL········· index = B0············· ' Variable Space For Ramp Counter
'
[noparse][[/noparse] Initialization ]
Startup:
IF PIN7 = 0 THEN Startup··············· ' Wait For HB-25 Power Up (P0)
LET············ DIRS =· %10000001······ ' Set PIN0 To Output
PAUSE 5································ ' Wait For HB-25 To Initialize
PULSOUT HB25, 150······················ ' Stop Motor
PAUSE 20······························· ' Wait 20 mS
'
[noparse][[/noparse] Program Code ]
Main:
· FOR index = 150 TO 200··············· ' Ramp Up To Full Speed
··· PULSOUT HB25, index················ ' Motor Forward
··· PAUSE 150·························· ' 150 mS Smoothing Delay
· NEXT
· PAUSE 3000··························· ' Wait 3 Seconds
· FOR index = 200 TO 150 STEP -1······· ' Ramp Back Down
··· PULSOUT HB25, index················ ' Motor Forward Slowing
··· PAUSE 150·························· ' 150 mS Smoothing Delay
· NEXT
Finish:
· GOTO Finish·························· ' Prevent PIN0 From Changing State
Comments
You wrote: And then finally the big question...... What can I put in the code to make the motor run in the other direction?
This thread may help
http://forums.parallax.com/forums/default.aspx?f=5&m=309722&r=x
FOR index = 150 TO 100 step -1 ' Ramp Up To Full Reverse
PULSOUT HB25, index ' Motor Forward
PAUSE 150 ' 150 mS Smoothing Delay
NEXT
Should make the motor reverse. As far as the pin 0 thing, ignore it if the HB25 is connected to pin 7. Hope this helps.
P.S. Here is your code cleaned up a little, see if it works:
' =========================================================================
' File...... HB-25 Motor Test.bs1
' Purpose... Tests One HB-25 Connected To P0
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Updated... 08-01-2006
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
[noparse][[/noparse] Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motor up, wait 3 seconds then ramp back down to a
' stop, wait 3 seconds, then ramp up to full reverse and back to a stop. This code
'·was written for one HB-25 connected in Mode 1 (Single) to PIN7.
'
[noparse][[/noparse] I/O Definitions ]
SYMBOL HB25 = 7 ' I/O Pin For HB-25
'
[noparse][[/noparse] Variables ]
SYMBOL index = B0 ' Variable Space For Ramp Counter
'
[noparse][[/noparse] Initialization ]
Startup:
IF PIN7 = 0 THEN Startup·· ' Wait For HB-25 Power Up (P0)
DIRS = %10000000··········· ' Set PIN7 To Output
PAUSE 5························· ' Wait For HB-25 To Initialize
PULSOUT HB25, 150········ ·' Stop Motor
PAUSE 20······················· ' Wait 20 mS
'
[noparse][[/noparse] Program Code ]
Main:
FOR index = 150 TO 200··· ·' Ramp Up To Full Speed
PULSOUT HB25, index······ ·' Motor Forward
PAUSE 150····················· ' 150 mS Smoothing Delay
NEXT
PAUSE 3000 ' Wait 3 Seconds
FOR index = 200 TO 150 STEP -1·· ' Ramp Back Down
PULSOUT HB25, index················ ·' Motor Forward Slowing
PAUSE 150······························· ' 150 mS Smoothing Delay
NEXT
Pause 3000 ' Wait 3 seconds
FOR index = 150 TO 100 step -1··· ' Ramp Up To Full Reverse
PULSOUT HB25, index················ ·' Motor reverse
PAUSE 150······························· ' 150 mS Smoothing Delay
NEXT
FOR index = 100 TO 150············· ·' Ramp down To stop
PULSOUT HB25, index···················' Motor reverse slowing
PAUSE 150································ ' 150 mS Smoothing Delay
NEXT
Finish:
GOTO Finish······························ ' Prevent PIN7 From Changing State
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
When all else fails.....procrastinate!
Post Edited (Shawn Lowe) : 4/7/2009 5:42:18 PM GMT