|
Re: Compiling with MPLAB
There is no way (as far as I know) you can just halt execution and wait. There are routines the bot has to run or else it will die (As seen by that Code Error).
The best way (that I know) is to count the loops. There's two loops you normally put code into. The one in user_routines.c and the one in user_routines_fast.c
Process_Data_From_Master_uP() in user_routines.c is run every 26.2ms. It has to wait for user input (from the Operator Interface) so there is a large delay on it.
Process_Data_From_Local_IO() in user_routines_fast.c is run ever loop. It's bound by how fast the processor is. It's not exactly practical to count those. They are not run at a set interval.
The problem with the 26.2ms loop is that it doesn't often match up to the delay you really want. To get close to a quarter of a second, you'd loop it 10 seconds. (Which is actually .262 seconds.)
Oh, User_Autonomous_Code() in user_routines_fast.c is also bound by the 26.2ms. It gets data from the OI. (You can put an autonomous mode selector on your OI if you wish. =) )
Using a forloop to stop execution is also kind of a programming no-no. It might work, but then you add something that slows (or speeds up) the code, and that changes the delay. Also, if you run it on a different processor, it'll run way differently (think older DOS games running on modern processors.) Ideally you'd use some sort of timer function with ms resolution. You record the time, loop until the difference between the current time and the recorded time is what you want, and them move on. (Else a sleep function that does that all for you)
Either way, delaying like that won't work on the Robot Controller. There's too many functions which need to be called a lot in order to assure its own survival. I -think- one of those functions is called in order to detect an infinite loop. When you delay too long it rips out of your execution (via an interrupt), and displays the nice Code Error. That's what I've always figured, can someone confirm this?
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
|