Help my Boe-Bot is crazy.
Helloo all!
I have a problem, my Bot is crazy.
Y uploaded a program to the bs2 and now, only moves the left servo ='( but he didn't stop to move it!
I pulled reset button few times and it continues doing the same!
Can someone tell me what's wrong?
this is the program:
Thanks in advance,
Izzy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sorry for my english, I'm spanish.
I have a problem, my Bot is crazy.
Y uploaded a program to the bs2 and now, only moves the left servo ='( but he didn't stop to move it!
I pulled reset button few times and it continues doing the same!
Can someone tell me what's wrong?
this is the program:
' -----[noparse][[/noparse] Title ]-------------------------------------------------------------- ' Robotica con el Boe-Bot - StripeFollowingBoeBot.bs2 ' Boe-Bot adjusts its position to move toward objects that are closer than ' zone 3 and away from objects further than zone 3. Useful for following a ' 2.25 inch wide vinyl electrical tape stripe. ' {$STAMP BS2} ' Directiva del Stamp. ' {$PBASIC 2.5} ' Directiva de PBASIC. DEBUG "Program Running!" ' -----[noparse][[/noparse] Constants ]---------------------------------------------------------- Kpl CON 35 ' Change from -35 to 35 Kpr CON -35 ' Change from 35 to -35 SetPoint CON 3 ' Change from 2 to 3. CenterPulse CON 750 ' -----[noparse][[/noparse] Variables ]---------------------------------------------------------- freqSelect VAR Nib irFrequency VAR Word irDetectLeft VAR Bit irDetectRight VAR Bit distanceLeft VAR Nib distanceRight VAR Nib pulseLeft VAR Word pulseRight VAR Word ' -----[noparse][[/noparse] Initialization ]----------------------------------------------------- FREQOUT 4, 2000, 3000 ' -----[noparse][[/noparse] Main Routine ]------------------------------------------------------- DO GOSUB Get_Ir_Distances ' Calculate proportional output. pulseLeft = SetPoint - distanceLeft * Kpl + CenterPulse pulseRight = SetPoint - distanceRight * Kpr + CenterPulse GOSUB Send_Pulse LOOP ' -----[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 2,1,irFrequency irDetectRight = IN0 distanceRight = distanceRight + irDetectRight NEXT RETURN ' -----[noparse][[/noparse] Subroutine - Get Pulse ]--------------------------------------------- Send_Pulse: PULSOUT 13,pulseLeft PULSOUT 12,pulseRight PAUSE 5 RETURN
Thanks in advance,
Izzy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sorry for my english, I'm spanish.
Comments
Eliminate one thing at a time.
'
[noparse][[/noparse] Subroutine - Get Pulse ]
Send_Pulse:
PULSOUT 13,pulseLeft
PULSOUT 12,pulseRight
PAUSE 5
RETURN
change your PAUSE 5 to PAUSE 20, to give your servos time to get the correct pulse rate.
Jax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..
I don't think the change is needed. Notice that the program always calls the IR routine. That takes up the other amount of time to the extent where he should be about right. It might be a little fast of a refresh rate, but it seems to work (since the left servo turns).
do a debug command for the right pulse servo to make sure your getting the correct pulse signal range to the servo.
@ SRLM, yes you are correct with the timing speed, I did not take in consideration for the time it takes to re-calculate the new positions.
Jax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..