View Single Post
  #2   Spotlight this post!  
Unread 26-11-2007, 15:17
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

Quote:
Originally Posted by JesseK View Post
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
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08