Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 6 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
9 years, 6 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.
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 20 May 20159 years, 6 months ago.
stm32f334 has analogwatchdogs just for this purpose, but as said, you have to program them using lower layers
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 18 May 2015