View Single Post
  #14   Spotlight this post!  
Unread 27-11-2007, 15:39
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: in case of EMERGENCY, is a loop of NOPs an option?

NOPs are often used in assembly language programming where a very (very! a microsecond or two!) short, predictable delay which is some multiple of the CPU clock instruction time is needed. I've used these when talking to peripheral devices at bus speeds ... there isn't enough time to configure or even check a timer value, just enough to execute a few NOPs. Usually interrupts are OFF as well - to avoid unexpected extra time.

I don't think that will be useful here ...

a) in a for-loop with an index that counts up to some large number, the NOP makes a poor-man's timer. But if you stay in the loop for a too long (> 26 msec) without a PutData(), there is the risk of the Code Error light coming on and your program being terminated, as whitetiger0990 said.

b) don't you need to check the autonomous bit in the loop too?

c) the IFIRobotics FAQ on Victor Speed Controllers states that the Victor updates at about 120 Hz, so the fastest it will accept updates is every 8 msec. This seems to be your limiting factor.

d) last year we had a too-small motor on our arm prototype, and yes it had zero holding power and we had to keep kicking it to resist gravity pulling the arm down. After a few seconds of this, the motor began to smoke! The moral of the story: use a different motor, with gearing high enough to provide the "holding power" that you need.

I'm guessing your desire for a quick-and-dirty solution to timers relates to the amount of code that would have to be found and commented in or out as you were making your between-match fixups. You might also want to consider using EasyC and WPILIB - MUCH easier to use timers/etc ...

mike


PS - another use of NOPs (back in the dim, dark past) was to leave extra space in the executable part of the program so as to PATCH in extra code manually through front-panel switches. I guess that's not the case here unless you are writing self-modifying code!