Quote:
Originally posted by manodrum
will a WORD variable hold more than 254? i'm at a last resort of counting loops for our autonomous code so i need a counter...also if anyone has any simple autonomous code that works and would like to share, i just need to see how you worked it into the main code and detecting if auton_mode = 1
and all that jazz...
Thanks,
manodrum
|
Hi,
Here is some of our code.
(Warning: I am not one of the programmers.)
We have multi-bank code. See Innovation FIRST site for an explanation and example.
We have our autonomous code in bank 2.
Below is how we jump to bank 1 where our driver controlled code is, when autonomous is over.
'---------- Aliases for the Pbasic Mode Byte (PB_mode) -------------------------------
'----------------------------------------------------------------------------------------------
' Bit 7 of the PB_mode byte (aliased as comp_mode below) indicates the status
' of the Competition Control, either Enabled or Disabled. This indicates the
' starting and stopping of rounds at the competitions.
' Comp_mode is indicated by a solid "Disabled" LED on the Operator Interface.
' Comp_mode = 1 for Enabled, 0 for Disabled.
'
' Bit 6 of the PB_mode byte (aliased as auton_mode below) indicates the status
' of the Autonomous Mode, either Autonomous or Normal. This indicates when
' the robot must run on its own programming. When in Autonomous Mode, all
' OI analog inputs are set to 127 and all OI switch inputs are set to 0 (zero).
' Auton_mode is indicated by a blinking "Disabled" LED on the Operator Interface.
' Auton_mode = 1 for Autonomous, 0 for Normal.
'
' Autonomous Mode can be turned ON by setting the RC to Team 0 (zero).
'
' Bit 5 of the PB_mode byte (aliased as user_display_mode below) indicates when
' the user selects the "User Mode" on the OI. PB_mode.bit5 is set to 1 in "User Mode".
' When the user selects channel, team number, or voltage, PB_mode.bit5 is set to 0
' When in "User Mode", the eight Robot Feedback LED are turned OFF.
' Note: "User Mode" is identified by the letter u in the left digit (for 4 digit OI's)
' Note: "User Mode" is identified by decimal places on the right two digits (for 3 digit OI's)
comp_mode VAR PB_mode.bit7
auton_mode VAR PB_mode.bit6
user_display_mode VAR PB_mode.bit5
'After our autonomous routine, we wait for autonomous to end.
WaitQuitAutonomous:
do
Gosub SerialInput
' Quit autonomous mode when it's time
Gosub TestQuitAutonomous
Gosub SerialOutput
loop
TestQuitAutonomous:
' (Test if its time to run the main loop (competition code)
if auton_mode = 0 then Run 1 ' (If autonomous is turned off, we jump to bank 1 and run the driver controlled program)
if AutonomousSwitch = 0 then Run 1 ' (We have a switch on our robot which allows us to turn off autonomous mode)
' Keep going in autonomous mode
Return
Hope that helps.