PWMs 13-16 are the 4 "fast refresh" PWM ports (2ms as opposed to 17ms for normal PWM) that are controlled by the User processor. Generate_Pwms() is the function the processor uses to refresh PWM values. Putdata() function calls Generate_Pwms() for PWMs 1-12 which the Master processor refreshes every 26.2ms (when the User and Master exchange data).
The programmer can call Generate_Pwms() for 13-16 anytime (well every 2ms). This allows the programmer to control more important motors (like the drive train) more precisely which is particularly useful during autonomous mode. FIRST did not include Generate_Pwms() before the Putdata() in the autonomous default code probably because they did not want to restrict everyone to the slow 26.2 ms part of that loop. Generate_Pwms() can be placed outside of the if statement looking for new data as shown below:
Code:
void User_Autonomous_Code(void)
{
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! */
/* Add your own autonomous code here. */
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
// insert realy fast auto code for PWMs 13-16 driven
// by wheel encoders, gyros, line trackers, IR Sensors, etc...
// here
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
}
}
The fast code will execute every cycle much like Process_Data_From_Local_IO(). If you need to use analog inputs during this code you must use the function Get_Analog_Value() to activate the ADC(Analog Digital Converter) for every analog value you need.
(Note: I have not got a chance to test this on a bot and I am explaining this as best as I can for anyone who doesn't already know. I am still learning new stuff about this new processor and I could be wrong about something)
The fast PWMs are one of the many things that make this new processor is much more powerful than the last one, which was needed for autonomous. Because of this new powerful processor, I expect the 2004 StangSense (Wildstang's incredible auto program) to be accurate to a quarter inch in any direction.
