Thread: Autonomous code
View Single Post
  #7   Spotlight this post!  
Unread 14-01-2003, 14:50
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by frumious

if counter++ > 500 then 'arbitrary time value
p1_x = 254
else
p1_x = 0
endif
Yeah, that will work as long as you ditch the ++ part. Doing a little C recently?


Anyway, dead-reckoning with the 2.5 syntax begs you to use the SELECT:
Code:
counter var word
counter=0

do
serin ....

IF auton_mode = 1 then
  SELECT counter
    CASE 0 to 100
      PWM1=254
      PWM2=254
      counter=counter+1
    CASE 101 to 200
      PWM1=254 
      PWM2=0
      counter=counter+1
    CASE else
      PWM1=127
      PWM2=127
   ENDSELECT
ELSE 
   'regular code goes here
ENDIF

serout...
LOOP
This code will go forward for approx. 2.6 seconds, then turn for another 2.6. To add new steps, just add another CASE. After it's done, it just stops and no longer incremements the counter. If you put the counter incrementer outside the SELECT, it will loop back to 0 after approx. 28 minutes. This may be OK, it may not.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php