Interrupt to Detect analog voltage change

John P

Joined Oct 14, 2008
2,025
I want to connect a "voltage" with a POT to one microcontroller input and do something at every change of the voltage level.
Can it be done with an interrupt or it has to use polling?
So the original inquiry was about whether it can be done with interrupts instead of polling. I don't think anyone claims that interrupts are actually the right way to do the job! But it's a challenge to think of how it might be possible.

I thought of another way, doing it backward. Use a single comparator with a reference voltage, and rely on the fact that the output of the pot will have noise which will constantly be triggering changes in the comparator output, first higher than the reference and then lower. If the interrupts stop occurring, then you know the pot voltage has moved away from the reference and it's time to change the reference to match it. That is brilliant, is it not?
 

dannyf

Joined Sep 13, 2015
2,197
But it's a challenge to think of how it might be possible.
Anything, however simple it is, can be a challenge to someone somewhere.

Whether it is the right way to do things will depend on the particular application.

I thought of another way, doing it backward.
Pick any mcu and try to implement it that way. You will find it quite "limiting":

1. the DACs usually have limited resolution;
2. The Vref generator has limited resolution;
3. You are using more resources than you need;
4. If you think the use of interrupt is "challenging", your approach might have been Everest, :)

That is brilliant, is it not?
It can be brilliant, I am sure in some applications - for example, you are running out of adc channels. But that's probably not the case here.
 
Top