Shop OBEX P1 Docs P2 Docs Learn Events
Help my Boe-Bot is crazy. — Parallax Forums

Help my Boe-Bot is crazy.

IzzyIzzy Posts: 24
edited 2009-01-17 02:39 in Robotics
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:
' -----[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

  • SRLMSRLM Posts: 5,045
    edited 2009-01-15 19:05
    Try this code to see if your problem is hardware or software:

    DO
    PULSOUT 12, 600
    PAUSE 20
    LOOP
    
    



    Eliminate one thing at a time.
  • GWJaxGWJax Posts: 267
    edited 2009-01-15 19:39
    Also in this routine:
    '
    [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..
  • SRLMSRLM Posts: 5,045
    edited 2009-01-16 00:35
    @GWJax

    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).
  • GWJaxGWJax Posts: 267
    edited 2009-01-16 15:39
    @Issy

    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..
  • MovieMakerMovieMaker Posts: 502
    edited 2009-01-17 02:39
    You may have to calibrate your servos. My robot did the same thing until Andy told me to calibrate them. Once that was done, they behaved themselves.
Sign In or Register to comment.