HB-25 and BS2
Pale_Flyer
Posts: 11
i am trying to use a SumoBot board with BS2 that i have lying around to control three motors.· I know i need to have an HB-25 per motor, and i do, but i can not get the HB-25 to drive the motor.· i am running it off a 7.2v Ni-MH battery pack.· i have been trying the demo program, with two diffrent pwm cables, two diffrent motors (both work direct off batt.) and two of the three HB-25's.· I have even tried modifying the code, but it just wont drive the motor!· it is for a class project, and i need to get it to work soon!!!!!· the fuse is good, and the green LED is bright.· but the red (Fault) LED is just lit, almost looks like spill off from a circuit.· But BOTH HB-25's have it, and they are brand new.· When i have them connected to power the cooling fane spins.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The smarter I get, the more I understand I don't know!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
Dout PIN 0 ' P0 <-- Dout (LISY300.2)
SCLK PIN 1 ' P1 --> SCLK (LISY300.4)
CSn PIN 2 ' P2 --> /CS (LISY300.5)
'
[noparse][[/noparse] Constants ]
Yes CON 1 ' Yes Constant
No CON 0 ' No Constant
Kpl CON -35
Kpr CON 35
SetPoint CON 2
CenterPulse CON 750
'
[noparse][[/noparse] Variables ]
value VAR Word ' ADC Result Value
freqSelect VAR Nib
irFrequency VAR Word
irDetectLeft VAR Bit
irDetectRight VAR Bit
distanceLeft VAR Nib
distanceRight VAR Nib
pulseleft VAR Word
'
[noparse][[/noparse] Initialization ]
Initialization:
HIGH CSn
LOW SCLK
PAUSE 250
'
[noparse][[/noparse] Program Code ]
Main:
DO
IF (irdetectleft=1) & (irdetectright=1) THEN
DO
GOSUB Get_Ir_Distances
pulseleft = 750
GOSUB Send_Pulse
LOOP
ELSEIF (irdetectleft=1) THEN 'something left
pulseleft = 650
ELSEIF (irdetectright=1) THEN 'something right
pulseleft = 850
ELSE
GOSUB Read_Gyro
IF value < 505 THEN ' gyro control servo
PULSOUT 15, (value) - 750
ELSEIF value > 520 THEN
PULSOUT 15, (value - 511) + 750
ELSE
PULSOUT 15, 750
ENDIF
ENDIF
LOOP
'
[noparse][[/noparse] Subroutines ]
Read_Gyro:
LOW CSn
SHIFTIN Dout, SCLK, MSBPOST, [noparse][[/noparse]value\13]
HIGH CSn
RETURN
'
[noparse][[/noparse] Subroutine - Get IR Distances ]
Get_Ir_Distances:
distanceLeft = 0
distanceRight = 0
FOR freqSelect = 0 TO 4
LOOKUP freqSelect,[noparse][[/noparse]37500,38250,39500,40500,41500], irFrequency
FREQOUT 8,1,irFrequency
irDetectLeft = IN9
distanceLeft = distanceLeft + irDetectLeft
FREQOUT 4,1,irFrequency
irDetectRight = IN3
distanceRight = distanceRight + irDetectRight
NEXT
RETURN
'
[noparse][[/noparse] Subroutine – Get Pulse ]
Send_Pulse:
PULSOUT 15, pulseLeft
PAUSE 5
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"WOAH! that wasn't supposed to happen!"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"WOAH! that wasn't supposed to happen!"