Quote:
|
Originally Posted by charrisTTI
Interrupts provide a way to signal the processor to stop what it is currently doing and run a special piece of code to handle the interrupt. When the processing of the interrupt is complete the processor returns to running the original program exactly where it left off. An interrupt provides a way to immediately handle an event rather than polling for changes in the state of an input within the main program. Interrupts allow us to be sure that we do not miss events (with some caveats) or more accurately measure the timing of events. For an encoder, the interrupt is used to increment the variable used to store the number of steps. In a polling loop, steps could be missed while the processor is doing something else resulting in an inaccuracy in the measurement. For the ultrasonic range finder, we want to measure the time between when the transmitter fires and the receiver detects the reflection. The timer is started when the transmitter is fired. The timer is stopped when the interrupt occurs. The use of the interrupt allows for more precise measurement of the time. In a polling loop there would be significantly more uncertainty in the measurement of the time. We might even miss the signal altogether if the signal from the receiver is shorter than duration of the loop. Interrupts are a powerful feature which must be used carefully. Interrupt service routines should be kept as short as possible. Do only the processing that is absolutely required. Let the main program loop do as much of the work as possible.
|
Thanks! That is terrific information for me that I was unaware of. Given what you said, how can I then quantify the effect of sensors that are interrupt driven, such as the encoders and ultrasonic range finder?
I still feel like I'm missing some key understanding of the software and timing, and that until I understand this, I won't be able to write code that effectively uses the available resources. If anyone has additional information, I would appreciate any and all of it.
Thanks again,
Pat