2
\$\begingroup\$

I am monitoring an external system which sends out a 5v pulse every 2 seconds when in normal mode. When the motor is working, it sends out a constant 5v designed to power a flashing light or LEDs as a warning system. When the pulse is not present, it is 0v. There is currently nothing connected to this, and I want to feed it into a micro so that I can monitor it (i.e., know when the device is active and send the appropriate signal to me).

There will be an optocoupler between the two circuits as these are powered independently (although now that I'm thinking about it, I certainly could integrate my micro into the existing framework, but that's not how it's currently setup).

I know I could programatically take out the pulse, by putting the input on an interrupt and waiting an appropriate amount of time before retesting, a kind of debounce. But I would like to know if I could do it by filtering out the pulse through circuitry.

My initial thought was to filter anything (for example) below 5Hz (since the pulse is at 1/2 Hz) and that I would need a high pass filter. But then someone pointed out to me I needed a LOW pass filter since the constant 5v I want to test for is actually at a lower frequency than the pulse.

As an additional point, the output of the filter will be driving a low impedence opto with no other load. I have no idea how to take this into consideration.

Any help would be appreciated.

\$\endgroup\$
3
  • \$\begingroup\$ Your design also needs to take in account the width of the pulse. Hence you should provide a description of width. \$\endgroup\$
    – mpflaga
    Feb 3, 2014 at 14:21
  • \$\begingroup\$ Yeah, I meant to do that, but got sidetracked. The peak is momentary, less than a millisecond, however the decay is very slow. It drops quickly but then becomes a classic hyperbolae which takes a good half 500ms to get to zero volts. Then repeats after two seconds. \$\endgroup\$
    – Madivad
    Feb 4, 2014 at 0:39
  • \$\begingroup\$ Thanks guys (@spehro and @jrtrzeciak) for your answers below, but I am now considering it in hardware and using the peak of the pulse as a heartbeat for the project. I am after a faster response and I think I can achieve something better in code. Thanks again \$\endgroup\$
    – Madivad
    Feb 4, 2014 at 0:42

2 Answers 2

0
\$\begingroup\$

If you truly want to filter the pulses via hardware, a low pass filter (LPF) is definitely what you want. It will PASS the low frequencies and attenuate the higher frequencies. You are looking for DC values which are of inherently lower frequency than any pulse train. The simplest way is to implement a first order LPF using a resistor and capacitor. The cutoff frequency is then

\$f_c = \frac{1}{2\pi RC}\$

schematic

simulate this circuit – Schematic created using CircuitLab

However, the response is going to be pretty slow. It will take a noticeable amount of time for the capacitor to charge up. Also there could be quite a bit of ripple depending on what size components you choose. To alleviate some ripple, you could use a second-order filter via the Sallen-Key topology.

schematic

simulate this circuit

If each resistor and each capacitor is the same value, the cutoff frequency will be the same as previously.

Whichever you choose, the output voltage will be dependent upon the duty cycle of the pulse. Therefore, if the pulse is low and high for equal amounts of time, and the amplitude is 5V, the output of the filters will be 2.5V. If you aren't using a comparator or ADC input on the microcontroller, you will need to implement a comparator as well. Since there will be some ripple on the output of the filter, a comparator with hysteresis will be necessary. From an Analog Devices article:

Comparator with Hysteresis and Calculations

Now you can probably see why using an input capture interrupt is probably the best bet. It is likely less work and definitely cheaper. Had your pulse frequency been higher, an analog solution may have been more useful.

\$\endgroup\$
1
\$\begingroup\$

It would be straightforward to do it in the micro- say you have a counter that counts down to 0 at (say) 50Hz. Whenever a pulse edge is detected, you preset the counter to (say) 150. If the counter gets to zero, you stop decrementing. If the counter == 0, then the pulses can be considered to have stopped.

You could do a similar thing in hardware by using a retriggerable monostable multibrator such as one half of a 74HC123. In the below timing diagram, note the retriggering from the falling edge of the /A input (far right part of the timing diagram showing \$t_{rr}\$).

You'd want \$t_w\$ to be something like 3 seconds, so the timing components would work out to be something like 10uF and 300K (for the Toshiba part, might be different for other makers).

In this case, the Q output will go low and the /Q output high if the pulses stop.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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