Interrupt performance?

Hi,

FIrst post here. Apoligies if this has been covered elsewhere already...

I'm using two external interrupts with an Arduino Nano to measure phase shift of two analog signals which come into digital input pins 2 and 3 from a voltage comparator. Basically I need to find when the delay between the two interrupts is the smallest. I seem to just about get the results I'm after but I'm wondering if I'm overloading the processor? In the docs it says the resolution of the micros() function is 4 micro seconds for Nano. Fair enough, but can I actually run anything on the processors if the interrupts come in right after each other and very frequently? Is this reliable? Are there any info on how much I can load/rely on the interrupts etc?

I'm open to alternative solutions on measuring the phase shift as well if you know any? The frequencies I'm dealing with are less than 10kHz...

Cheers,
Kari

Forgot to mention that all I really do in the interrupts is to store the result of micros() and some other minor stuff...

What you are doing sounds fine, but you will have some minimum reading - you can never get to zero since you have to wait for the first ISR to finish before you can wait for the next one.

I would tend to do it in hardware. Set your comparators to start/stop a counter and after the second comparator fires, read the counter value. By setting the clock rate to the counter you can change resolution as desired, say if it overflows.

You can use the timers/counters to measure small intervals.

Thanks guys! The hardware approach is intriguing. I ordered a few 74LS161 counters. Let's see if I can get this working with these :slight_smile: