Shop OBEX P1 Docs P2 Docs Learn Events
tabrokit sumobot programming — Parallax Forums

tabrokit sumobot programming

DrewdawgDrewdawg Posts: 12
edited 2004-10-14 22:35 in BASIC Stamp
i'm trying to get my bot to go forward for an allotted amount of time and can't seem to get it to work, can anyone help me out?

Comments

  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-05 13:36
    The 'forward' time on the Tab SUMOBOT is determined by the number of times that the 505 receives the forward instruction. Each forward instruction should have a pause between between it. The pause can be up to 180. A pause that is longer than 180 caused our robots to have choppy·movement.

    The total 'forward' time is:

    · 'forward'·command to 505
    +· pause 180
    ~ 180 m sec

    *··10 loop iterations (number of times this loop is performed).
    ~ 1800 m sec

    I have attached some code with comments which may be interesting.
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-06 13:37
    i now understand exactly how to make my bot do everything but one thing, how do you tell how many times to loop, you said the command "DO" makes it loop ten times, how do you change the number of times it loops
  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-06 16:58
    The comment after the 'DO' is not correct. The 'DO'/'LOOP' will be infinite.

    DO ' Do the loop 10 times
    RobotData = RobotForward ' Move forward
    GOSUB RobotSend
    PAUSE PauseTime ' Wait msecs between RobotSend commands
    LOOP ' Repeat Again

    It should have been:
    FOR sendCmd = 0 TO 9 ' Do the loop 10 times
    RobotData = RobotForward ' Move forward
    GOSUB RobotSend
    PAUSE PauseTime ' Wait msecs between RobotSend commands
    NEXT

    Don't forget to declare variable 'sendCmd'.
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-08 14:15
    so what do i change to tell the program how many times to loop the forward command, thanks for the help by the way
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-08 14:18
    do i change the "0 to 9" which makes it loop ten times, to lets say "0 to 15" to make it loop 16 times?
  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-08 17:17
    You are correct, "0 to 15" will make it loop 16 times

    My son has some of his TAB SUMOBOT code posted on our WEB page. Please have a look at it.
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-11 21:51
    its not working correctly, when i send it to the bot it doesn't stop after the allotted number of loops it just goes on forever, it send the forward command forever
  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-12 00:19
    I think that the·attached file should be complete. I have not tested it. I hope it is useful.

    I encourage you to read through the·CD that came with the robot. It will take you through·several code writing execises.·The manual on the CD·is not as well written as the Parallax material but it is the only way for you to learn how your TAB SUMOBOT works.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-10-12 00:44
    Drewdawg-

    In case you weren't aware of it, there is a Yahoo Group which deals exclusively with the Tab Robot Kit. Here is a link to that Yahoo Group:
    http://groups.yahoo.com/group/tabrobotkit/

    Regards,

    Bruce Bates
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-12 01:21
    i don't mean to bother u again, but i've read almost everything that comes on theat cd, and really doesn't have anything that relates to what i'm trying to do, and your latest isn't working, i've tried to tweak with it and i can't get it, and the yahoo groups is useless
  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-12 04:22
    If you would like to post your code, I will try using it on a TAB SUMOBOT that I have here.
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-13 23:50
    ' Move forward

    '

    ' { $STAMP BS2 }

    '|||||||||||||||||| Variables ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||



    PauseTime VAR WORD ' Create a 16 Bit Variable

    CountMoves VAR NIB ' Create a 4 Bit Variable

    RobotData VAR BYTE ' Data Byte to Send to/Receive from Robot



    '||||||||||||||||||| Constants ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

    RobotStop CON 0 'Stop the Robot

    RobotForward CON 5 ' Move Forward for 200 msecs

    RobotReverse CON 6 ' Move Reverse for 200 msecs

    RobotLeft CON 7 ' Turn Left for 200 msecs

    RobotRight CON 8 ' Turn Right for 200 msecs

    RobotPWM0 CON 11 ' PWM = 0% Duty Cycle

    RobotPWM1 CON 12 ' PWM = 1st "Notch"

    RobotPWM2 CON 13 ' PWM = 2nd "Notch"

    RobotPWM3 CON 14 ' PWM = 3rd "Notch"

    RobotPWM4 CON 15 ' PWM = 100% Duty Cycle

    LED CON 11 ' LED, Negative Active On

    SC CON 14 ' Define the Serial communications Clock Pin

    SD CON 15 ' Define the Serial communications Data Pin



    '|||||||||||||||||||| Main Code |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

    debug "forward"

    HIGH SC ' Set the I/O Bits As O/P - Required by the 505

    HIGH SD ' and High - Required by the 505

    HIGH LED ' Turn off the LED

    PauseTime = 80 ' msecs between commands

    PAUSE 100 ' Time for the electronic circuits to startup

    RobotData = RobotPWM0 ' Set the speed to 0 of 4 since Behavior 1 will probably start.

    GOSUB RobotSend



    RobotData = RobotPWM4 ' Set the speed to 0 of 4 since Behavior 1 will probably start.

    GOSUB RobotSend

    FOR CountMoves = 0 TO 1 ' Do the loop # times

    RobotData = RobotForward ' Move forward

    GOSUB RobotSend

    PAUSE PauseTime ' Wait msecs between RobotSend commands

    RobotData = RobotStop ' Stop the Robot

    GOSUB RobotSend





    RobotSend: ' Send the Byte in "RobotData"

    LOW SC ' Hold Low for 1 msec before

    PAUSE 1 ' Shifting in Data

    SHIFTOUT SD, SC, LSBFIRST, [noparse][[/noparse]RobotData]

    HIGH SC

    return
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-10-14 00:10
    Drewdawg -

    I didn't look through your coding all that thoroughly, but there is definitely a NEXT statment missing after your FOR statement. Additionally, I don't see anywhere that the variable CountMoves is incremented or decremented or even referenced anywhere in your coding except in tha FOR statement mentioned above. Lastly, you are probably going to drop right into the RobotSend coding. The RobotSend coding is a sub-routine, and it should only be accessed by a GOSUB statement.

    I'd clean up at least that much before you try toactually troubleshoot it any further.

    Regards,

    Bruce Bates
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-14 01:17
    everything is functioning right except for the countmoves command, no matter what i set countmoves equal to, it just loops the forward command forever, i can't get it to work
  • Ken GraceyKen Gracey Posts: 7,387
    edited 2004-10-14 04:10
    Drewdawg,

    I'll invite the guys who designed the robot into this discussion.

    Ken Gracey
    Parallax, Inc.
  • Russ FergusonRuss Ferguson Posts: 206
    edited 2004-10-14 14:03
    I also found that the code would not stop the·robot.

    I modified·the code to·make·it·stop after the forward commands. I also tested it on my TAB SUMOBOT.·The·sub-routine had been a part of the main program logic. When the context came to the 'Return' statement it caused the program to start over again. I choose to use an endless loop before the subroutine but you could just as easily use a 'goto' to skip over it and have more code.

    The·code is attached.
  • DrewdawgDrewdawg Posts: 12
    edited 2004-10-14 22:35
    i finally got the code to work thanks to your help russ, i had to change a few things but i got it to work, thank you very much
Sign In or Register to comment.