View Single Post
  #52   Spotlight this post!  
Unread 17-01-2005, 16:34
scottm87 scottm87 is offline
Registered User
AKA: Scott McClure
#0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Nov 2002
Rookie Year: 2000
Location: Bloomfield Hills, MI
Posts: 24
scottm87 is on a distinguished road
Re: Hall Effect Sensor.

Quote:
Originally Posted by russell
doesnt the program only run every 26miliseconds? Thats about 38 times per second. So if you had 38 teeth moving past it per second wouldnt your program show taht the robot is simply sitting still? These things look way too complicated for me.
First of all, the slow loop runs at something around that speed. The fast loop runs much faster. Even if the fast loop was too slow, there is the magic of interrupts!

Interrupts allow your code to process events that may come in during the execution of another task, and "interrupt" the current processing to handle the interrupt (in a function known as the "ISR", or "interrupt service routine") There are a few magic registers in the controller that control how interrupts are handled (for a good reference, check out Kevin Watson's interrupt code).

So, while the radio may be able to only transmit/recieve information every 26ms, the controller operates much faster, and with interrupts, can handle tasks even faster than the "fast loop" that executes code while waiting for a radio packet.

Scott