1
$\begingroup$

An input device sends a 20ms positive signal to perform an action. The signal is captured using an interrupt triggered on the rising edge of the positive signal. It appears that there might be some electrical noise on the signal line. I suspect this because the interrupt is getting trigger inadvertently. I currently don’t have access to an oscilloscope to verify the signal integrity. I am using MSP430 microcontroller.

Question: What is the most effective/simple way for the micro-controller to capture the 20ms positive signal with out modifying electrical hardware?

$\endgroup$
1
1
$\begingroup$

Add a low-pass filter.

This can be a resistor in series and capacitor in parallel.

enter image description here

If you can't adjust the hardware then you will need to debounce the signal in software.

That will mean taking the average of the last x samples and then seeing if it exceeds the trigger level

$\endgroup$
2
  • $\begingroup$ Thank you for the response. The design should have had a low pass filter. But the current hardware doesn't have a low pass filter. So I like to solve this in software with the least amount of digital signal processing. I will take a look at debounce. Appreciate your insight $\endgroup$ – Mahendra Gunawardena Sep 3 '15 at 12:10
  • $\begingroup$ The SW debounce helped the rising edge. But there is ringing a the falling edge too. Thus had the debounce for more than 20ms, thus defeated the used of interrupts to a large extend. Appreciate the tip $\endgroup$ – Mahendra Gunawardena Sep 8 '15 at 0:39
1
$\begingroup$

With a 20 ms pulse width you really should not be using interrupts directly.

The usual thing is to have some timer generating periodic interrupts at maybe 250Hz or so, then if on two consecutive timer events you read the input as active you can be reasonably sure you have a pulse lasting at least 1/Timer frequency, similar logic can be applied to filtering the falling edge.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.