|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
GOING FORWARD THEN BACKWARD
Well lets see, how can you go forward and then backward
Well try to find these three lines of code MainLoop : '(there is code between here) Serout USERCPU, OUTBAUD, [255,255,p1_y,relayA,p2_y,relayB,p3_y,p4_y,p1_x,p2_ x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel] '(there is code between here) Goto MainLoop : Well the way it works is that every 26 miliseconds or so, the program goes through the loop and sends output through the serout command. You can't use a for loop -- it would stay inside the for loop and never get to the serout command. What you want is a counter variable to keep track of how long the robot goes forward and backwards. For example : '=== DECLARE VARIABLES (out of main loop) state var byte state = 0 counter var byte counter = 0 '====== ' PUT THIS AFTER MainLoop, before SEROUT command if NOT (auton_mode = 1 and state = 0) then skip1 state = 1 counter = 0 p1_y = 254 skip1: counter = counter + 1 if NOT (state = 1 and counter = 50) then skip2 state = 2 p1_y = 0 counter = 0 skip2: if NOT (state = 2 and counter = 50) then skip3 state = 3 p1_y = 127 skip3: ' ========= You could easily alter this for tank-steering/other purposes You notced I use the NOT and brackets, that's how I get into making the if statement a true if statement... it normally goes to the label, but if I put a NOT, it reverses, going to the label if the opposite is true... neat eh? I'm going to be posting our team's autonomous code soon. The problem I heard from another post is that since the battery voltage changes, motor speed changes, so using an internal counter is not that reliable... but I'm not that convinced that can happen, how much voltage drop is going to happen in 2 minutes? Hope this helps 907 Brian Lim |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| autonomous mode problem on field | Chris_C | Programming | 17 | 26-03-2003 19:11 |
| Autonomous Code From Experience | EbonySeraphim | Programming | 7 | 14-03-2003 21:56 |
| Autonomous code tutorial | miketwalker | Programming | 2 | 23-02-2003 12:28 |
| Overcomplicated Autonomous Code | EbonySeraphim | Programming | 33 | 20-02-2003 21:53 |
| Autonomous Code | Adrian Wong | Robotics Education and Curriculum | 1 | 18-11-2002 22:34 |