|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Sending variables to Auto Mode
Hey,
As ship date ominously approaches, our team is scrambling to get some testing in. Currently our robot is set up to do all three autonomous positions (forward, middle, and back) however I've had some problems setting up our toggle switch so we can quickly toggle between positions. Basically we've got a custom 3-state DPDT switch hooked up to our OI through Port 3 so that Switch Forward makes p3_sw_trig true, and switch back makes p3_sw_top true... if you know what I mean. Anyway, the 3-state switch is used to determine our position in autonomous, but we also use it for harvesting and expelling balls in manual mode. It works properly in manual mode so I know it's wired and working properly. Getting it to work with auto mode is not so successful. Let me show you what I have set up: main.c: Code:
char position = 0;
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. */
position = Process_Data_From_Master_uP(); /* You edit this in user_routines.c */
if (autonomous_mode) /* DO NOT CHANGE! */
{
printf("Main: p: %d\r\n",(int)position);
User_Autonomous_Code(position); /* You edit this in user_routines_fast.c */
}
}
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 */
Code:
char pos = 0;
char Process_Data_From_Master_uP(void)
{
Getdata(&rxdata);
/* Camera and other important Stuff... */
if(trig_fwd) //trig_fwd is p3_sw_trig
{
pos = 0;
}
else if(trig_rev) //trig_rev is p3_sw_top
{
pos = 2;
}
else
{
pos = 1;
}
Putdata(&txdata);
return pos;
}
Code:
void User_Autonomous_Code(char position)
{
/* Important Stuff */
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
if(position == 0)
{
// Auto Stuff
}
else if(position == 1)
{
// Auto Stuff
}
else
{
// Auto Stuff
}
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
Thanks for the help! Last edited by Adrien : 19-02-2006 at 01:17. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| auto mode | nuggetsyl | General Forum | 12 | 13-02-2006 19:45 |
| Cross Mode Variables? | Mr. Steve | Programming | 16 | 26-01-2006 14:34 |
| camera auto mode pwm contention? | AL_E | Programming | 4 | 24-01-2006 22:10 |
| Did you use Auto Servo Mode? | Greg Marra | Programming | 8 | 27-04-2005 15:35 |
| pic: 233 after Auto mode | Jeff Rodriguez | Extra Discussion | 13 | 26-04-2005 19:33 |