View Single Post
  #4   Spotlight this post!  
Unread 07-02-2004, 21:34
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Programming code Fix FRC

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.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 07-02-2004 at 21:37.