Programming code Fix FRC

In the Autonomous code, there is a line missing in Our version of the FRC code:
Generate_Pwms(pwm1…pwm16);
what ever PWM’s you use in Autonomous, include them here or it wont work!

-Devon

From “user_routines.c”


Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

I don’t think Generate_Pwms(…) can do all 16.

Generate_PWMs() only works on PWMs 13-16. The other 12 are controlled by the master processor.

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:

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. :smiley:

also a note to any programmers that haven’t seen it yet - many people have reported problems with Generate_Pwms - this is due to a missing line in some of the default code - in whatever file you are using Generate_Pwms in, make sure you #define _FRC_BOARD (this does not apply for the edubot).

Well they used an external processor last year … so they really weren’t limited by the BASIC Stamp’s (lack of) capabilities.

I was confused. StangSense was from 2002 when they used Motorola current sensors to read out motor status on a PDA. Actually, Wildstang’s 2003 autonomous program was called StangPS (Positioning System). They had a 2 inch resolution on their wheel encoder with that external Motorola processor. Interrupts should increase their resolution greatly (can handle many more pulses per revolution) and the fast PWMs should increase their efficiency in getting there. The question is: What will they spend their $200 budget on this year? Will they be the first to use the TTL port in competition?