![]() |
Delay
is there a code for a delay command for c?
|
Re: Delay
You could start up a counter and use the counter to tell the robot to do certain things at a certain time (remember the code loops every 26. something milliseconds).
Unfortunately, as far as I know, there is no delay function. |
Re: Delay
There are timer interrupts (which, sorry, I'm unsure how to use). But for most applications you rarely need any more resolution than 26.2ms. It's pretty much constant from loop to loop.
|
Re: Delay
Wait(x);
x being the number of milliseconds. Thus, if you want the code to pause for 3 seconds, you type "Wait(3000);" |
Re: Delay
Where did you find reference to the "Wait" command? Did you find it in a manual. I'm trying to find a reference to all these kinds of functions?
|
Re: Delay
I believe Wait(n) is in EasyC, not in mplab. The two operate much differently in this respect.
In mplab you don't want a command like wait 3 seconds inside your code. The code needs to do it's own paperwork every loop. You can use a counter variable like i_am_samus suggests. Here's my note to myself in the code: Code:
// timer notes:As I recall from other places here at CD, the counter variable method isn't exact but is close enough. |
Re: Delay
If you're using MPLAB and last year's code, you should have a "delay.h" file (partially copied here). If you're using this year's code, some of these functions appear to be
called, but from an unused code block, and the file "delay.h" is gone. Perhaps Kevin can shed more light on this? Code:
/* PIC 17Cxxx and 18Cxxx cycle-count delay routines. |
Re: Delay
You can setup one of the timers and increment an integer in the interrupt routine (more accurate and adjustable period) or increment a counter variable in the default functions (fixed period but easier to implement and only works when OI is talking to the robot). Spinning a loop to get a delay is a bad idea in this application. The "paperwork" referred to in this post is the processing of messages to and from the operator interface controller. If you start missing those messages or not replying in a timely manner, the master game controller will disable your robot for the duration of the match.
Update: A simple spin to create usec type delays is OK but don't spin for a long time relative to the cycle of the main loop (~23ms). |
Re: Delay
Quote:
|
| All times are GMT -5. The time now is 13:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi