Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Programing delays in MPLAB (http://www.chiefdelphi.com/forums/showthread.php?t=64052)

Shivang1923 14-02-2008 09:19

Programing delays in MPLAB
 
Yeah. What is the command to set up a delay (like go forward for x seconds) ?

Mark McLeod 14-02-2008 12:19

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


All times are GMT -5. The time now is 20:26.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi