Answered: Interrupt ports with sensors

I was wondering specifically in regard to the ultrasonic sensor and optical shaft encoders why the output line from the ultrasonic and channel A line from the encoder has to be plugged into an interrupt port and not an analog or digital input?

Happy holidays

It does not have to be but by using an interrupt line you can get better accuracy in your measurements.

Any reason why it would be used annd why it’s more accurate?

**When you are not using an interrupt, you can only check to see if an event has occurred at loop intervals - you would not know exactly when the event occurred but only that it has happened since the last time you checked it. When using an interrupt, the code can stop what it was doing to handle the event immediately and then continue with the normal code sequence/loop.

MarkO suggests “Try this document, Using Polled or Interrupt-driven Timers , which describes the 2004-2005 FRC Controller, which has the same 18F8520 PIC Processors in it as the Vex Controller… All the same reasons are valid…” **