Quote:
Originally Posted by JesseK
You can't do for loops on the current controller iirc, but I programmed very little of it in the last 2 years.
nOPs are good enough in a jam, but you design the bot, sensors and programming other way -- the way that DOESN'T use timers/nops to get to where you want. nOPs usually lack consistency in mechanical control.
|
Easy partner... hardware timers are ONE OF THE best and most accurate ways of timing when code executes, or upon what interval. A must for true, high performance PID/LeadLie/StateSpace loops.
Uhm... but I'd still like to know... why do you want to make a for loop of nops?
One of the only times I've used one of these for FIRST is in my single-pin Parallax ultrasonic driver (
posted here) to generate the keying pulse to trigger the ping, since it was a very short (just a few microseconds) pulse time, and would have been inefficient to set a timer and come back just to time such a short pulse. Actually, the amoount of time it takes to enter/exit an interrupt would have been longer than the duration of the pulse, so, the best option in that case was to create a for loop. It's important to note that nops are not needed in the for loop to make a spinlock/busy wait. only:
Code:
for(unsigned char delaycounts = 0; delaycounts < 10; delaycounts++);
But yeah i'm still wondering about what the long for loop has to do with making a motor not 'skip'... and how you make a motor 'skip'...
-q