8 years, 11 months ago.  This question has been closed. Reason: Off Topic

interrupt from analog input

is there a way to to generate interrupts from analogin, lets say if the value is greater than a certain value. and using .rise to indicate its rising edge.when there is a rise then it starts timing .im not sure on using interrupt from analogin.

2 Answers

8 years, 11 months ago.

Analog interrupt is not supported by the mbed lib mainly because most mbed platforms dont have this feature. You can emulate it by a timer driven sampling of the ADC and checking of the values. Some mbed platforms do have simple comparator hardware that may be used to generate an interrupt when a threshold is exceeded, for example the lpc824. You will have to write your own code for that. An easy alternative in hardware is to use an external op-amp based voltage comparator that drives a digital input to generate an interrupt.

Any links so i can kickstart with my project.?

posted by faris abdat 18 May 2015

google for op amp comparator circuit and you'll get lots of examples of circuits where the output will go from 0 to 3.3V when the input crosses a threshold. Generally all you need is an opamp and 2 resistors.

The resistors divide the supply voltage down to the threshold voltage, that goes into the - input. Your signal goes into the + input. When your signal is over the threshold the output will go high.

You can make one of the two resistors variable to allow you to change the threshold easily.

If you have a noisy signal or power supply then add a series resistor on the input signal and two capacitors, one from each of the op-amp input pins to ground. That will give you a basic low pass filter to get rid of noise.

posted by Andy A 20 May 2015
8 years, 11 months ago.

stm32f334 has analogwatchdogs just for this purpose, but as said, you have to program them using lower layers

I'm trying to avoid using a hardware.is there better options.?

posted by faris abdat 18 May 2015

More common than analog watchdogs, most of the microcontrollers have comparators which are able to generate interrupts when a signal goes above a given (programmed) value. Check yours.

In case of a simple ADC, the interrupt is only useful to signal the end of the analog to digital conversion to the application.

posted by Jose Luu 18 May 2015

okay i find out that the lm75b can act as an comparator but i can't seem to find any example to control the analogin.do u have any links to where i could start?

posted by faris abdat 19 May 2015

The lm75b has a comparator mode but all it is doing is checking if the temperature is over a certain threshold, you can't use it as a comparator for your own analog signal.

posted by Andy A 20 May 2015