View Single Post
  #2   Spotlight this post!  
Unread 14-02-2008, 12:19
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,740
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programing delays in MPLAB

There is no single function through MPLAB, but there are several ways to accomplish what you want. The simplest is to just use a count of the slow radio packet loops as an approximation of time.
Here's an example.

Code:
#define HOW_LONG 38                //38 = 1 second, e.g., 76 = 2 seconds
static int counter=0;
 
if (counter < HOW_LONG)
{
    counter++;
    // Drive at half speed
    pwm01 = 127 - 60;
    pwm02 = 127 + 60;
}
else
{
    // Stop driving
    pwm01 = 127;
    pwm02 = 127;
}
Another method is to setup an internal clock, but that's more complex.
There's a white paper on understanding timers here: http://www.ifirobotics.com/docs/time...004-jan-14.pdf
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 14-02-2008 at 12:25.