|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
switching modes
in STL we only had one autonomous mode so we could only set up on the left side of the field. i have written more programs but i don't know or understand how to write the code to switch between different modes. i have written 4 mode (includes right and left). i would prefer to be able to switch modes from the OI but am open to doing it anyway possible. i need something i know will work since we accedently left the robot controller on the robot so i have no way of testing it before our next regional.
thankyou so much allison |
|
#2
|
|||||
|
|||||
|
Re: switching modes
Well, I believe the OI can't send data inputs to the RC during autonomous. However, if you put 2 switches on your RC and plug them into the "Digital Inputs"... simply make one code, with all 4 modes on it. Make one switch the side switch (i.e. when on run Left side, when off run Right side code) and the other switch can choose between 2 modes... if you want to do 4 modes like you said, you can do more digital inputs with switches to choose. Then just in your code make IF loops to pick the code. Tell me if this makes sense, I'm kind've tired so I don't know if I make any sense.
|
|
#3
|
||||
|
||||
|
Re: switching modes
You can in fact use the OI [edit] apparently im wrong about the rest of what i said i trust 10inthecrunch's explanation better than my own
[/edit]Last edited by Max Lobovsky : 24-03-2004 at 20:12. |
|
#4
|
||||
|
||||
|
Re: switching modes
We use switches this year on our OI. The robot and OI are in full communication when you set them out on the field (just PWM and relay outputs are squelched), and inputs are only set to neutral when you go into autonomous. So, to do this: figure out which digital inputs you want to use, and in your program, capture the *previous* values of those inputs (the program makes one more sweep with neutral values, so you need the good ones from before that).
Basically just set up variables for the previous values and set them at the bottom of User_Routines, and in your Main function, create a variable that amalgamates those variables. Now you have one variable you can use for a switch statement in your autonomous code. PM or IM me if you have trouble getting it to work, its a little difficult to explain in a static post . |
|
#5
|
|||||
|
|||||
|
Re: switching modes
Last year we used a switch wired into the RC to tell whether we would turn left or right. I am not sure about whether or not we used one program, or had it switch between two programs. I was not the programmer last year, but I may have heard from our previous programmer that it switched between two different programs.
|
|
#6
|
|||||
|
|||||
|
Re: switching modes
And it turns out that Main.c is messed up. when Auton is set, it does one run of Process_Data_From_Master_uP() before doing Auton. I'll post a fix if anyone wants it.
|
|
#7
|
||||
|
||||
|
Re: switching modes
Quote:
![]() |
|
#8
|
|||||
|
|||||
|
Re: switching modes
Better than nothing.
|
|
#9
|
|||||
|
|||||
|
Re: switching modes
Here's what we're talking about:
Code:
void main (void)
{
#ifdef UNCHANGEABLE_DEFINITION_AREA
IFI_Initialization (); /* DO NOT CHANGE! */
#endif
User_Initialization(); /* You edit this in user_routines.c */
statusflag.NEW_SPI_DATA = 0; /* DO NOT CHANGE! */
while (1) /* This loop will repeat indefinitely. */
{
#ifdef _SIMULATOR
statusflag.NEW_SPI_DATA = 1;
#endif
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{ /* I'm slow! I only execute every 26.2ms because */
/* that's how fast the Master uP gives me data. */
if (autonomous_mode) /* DO NOT CHANGE! */
User_Autonomous_Code(); //You edit this in user_routines_fast.c
Process_Data_From_Master_uP(); //Used to be before the if
}
Process_Data_From_Local_IO(); /* You edit this in user_routines_fast.c */
/* I'm fast! I execute during every loop.*/
} /* while (1) */
} /* END of Main */
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Alternative autonomous modes | Jon Reese | Programming | 1 | 14-01-2004 13:17 |
| high-low gear switching | archiver | 2001 | 8 | 23-06-2002 22:39 |
| Team 45 Dual Motor Gear Switching Assembly | WorkThoseBuns | Motors | 1 | 20-03-2002 19:27 |
| switching joystick axis????? | team222badbrad | Technical Discussion | 9 | 16-01-2002 23:07 |
| [white paper] Dual Motor Gear Switching Assy | Brandon Martus | Motors | 0 | 29-06-2001 12:56 |