In the IFI 2007 default code main.c , there is a condition statement (see below) where if _SIMULATOR is defined then
statusflag.NEW_SPI_DATA is set to 1 and the slow loop (which execute every 26.2ms) is used., otherwise
it is never entered.
It is my assumption that because _SIMULATOR is defined in the default.h header file that this slow loop
will always be executed.
**Why would you not want to use the slow loop (and remove the definition in the header file)? **
Here is the 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. */
Process_Data_From_Master_uP(); /* You edit this in user_routines.c */
if (autonomous_mode) /* DO NOT CHANGE! */
{
User_Autonomous_Code(); /* 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.*/
_SIMULATOR should only be #defined if you plan to run your code using the simulator. I don’t see a default.h file. I see one named ifi_default.h, but that file doesn’t define _SIMULATOR. Typically it isn’t defined in a file at all, instead being passed to the processor on the command line.
The statusflag structure is filled in automatically by the communication with the master processor. It will signal a new data packet each time the OI sends values over the radio or the tether connection, about 40 times per second. The slow loop will run once each time that happens. If you’re using the simulator to run the code, there is no OI communication, and the compiler needs to pretend it’s getting data so you can test out your slow loop.
And yes you are right the correct name for the header file is ifi_default.h
-My incorrect typing…
I didn’t know that The statusflag structure is filled in automatically by the communication with the master processor and so I wasn’t sure how or it the user_routines.c was being accessed.
Is there any any description of this workings of this software available for those of us that are not as familiar with it?
It looks quite basic but any additional information helps with the learning curve…
I was playing around with the default code tonight and now I am really confused…
there is a section that is set up for 1 joystick control and I tried this but it did not work as I expected. The comments stated that I need to connect one wheel to PWM_13 or PWM_14 and the other wheel to PWM_15 or PWM_16 but what I found to work was to connect one wheel to PWM_01 and the other wheel to PWM_13.
What line of code is actually outputing the PWM value to the PWM outputs?