|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
For those of you that may still be struggling with autonomous code, here is some code snippets that may help.
loopCnt VAR byte 'Loop counter Low byte loopCntHigh VAR nib 'Loop counter High nibble StradegyNumber VAR nib 'The Stradegy number selected on robot Stradegy1 VAR rc_swB.bit5 ' Stradegy Selection Switch 1 Stradegy2 VAR rc_swB.bit6 ' Stradegy Selection Switch 2 Stradegy3 VAR rc_swB.bit7 ' Stradegy Selection Switch 3 loopCnt=0 loopCntHigh=0 MainLoop: '>>>>>>>>>>>>>>>>>>> LOOP COUNTER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF auton_mode THEN IF (loopCnt + 1 > 255) THEN loopCntHigh = loopCntHigh + 1 loopCnt = 0 ELSE loopCnt = loopCnt + 1 ENDIF ELSE loopCnt = 0 loopCntHigh = 0 ENDIF '>>>>>>>>>> STRADIGY SELECTION <<<<<<<<<<<<<<<<<<<<<< 'This section move the stradegy switches into the StradegyNumber varible for program use StradegyNumber.Bit0 = Stradegy1 StradegyNumber.Bit1 = Stradegy2 StradegyNumber.Bit2 = Stradegy3 '>>>>>>>>>> AUTONOMOUS MODE <<<<<<<<<<<<<<<<<<<<< IF auton_mode THEN 'Check for Autonomous mode SELECT StradegyNumber CASE 0 'Stradegy 0 code goes here CASE 1 'Stradegy 1 code goes here CASE 2 'Stradegy 2 code goes here CASE 3 'Stradegy 3 code goes here CASE 4 'Stradegy 4 code goes here CASE ELSE 'Not a valid stradegy PWM1 = 127 PWM2 = 127 ENDSELECT 'End the autonomous mode stradegy selection ELSE 'Not in Autonomous Mode loopCnt=0 'Reset Loop Counter when not in Autonomous Mode loopCntHigh=0 ENDIF Tim Tedrow |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2-week FIRST summer program @ WPI | ColleenShaver | General Forum | 20 | 31-05-2009 03:02 |
| Fried program slots? | Jeff Waegelin | Programming | 18 | 19-03-2003 18:08 |
| Ahh! Program trick confusing! | archiver | 2001 | 9 | 24-06-2002 02:26 |
| Credits for FIRST program. | archiver | 2000 | 6 | 24-06-2002 00:16 |
| An invitation for HS Juniors | archiver | 2000 | 0 | 23-06-2002 22:51 |