0
\$\begingroup\$

Am trying to read the frequency of a 0-12V square signal generated by a motorbike ECU with a PIC. Range 20Hz-300Hz I'm getting strange intermittent noise on the output of my optoisolator, and wondered if anyone can suggest the best way to suppress? LP filter on the output, or condition the input somehow?

Circuit: enter image description here

A couple of scopes (at MCU pin) last one is a higher RPM:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Is the noise on the 3.3v supply? \$\endgroup\$ – HandyHowie Mar 5 '16 at 19:55
  • \$\begingroup\$ I've tried caps up to 10uF on the input side without any help - I have however "fixed" the problem with a 0.1uF cap across the MCU input pin to ground, any idea what that might point to being the issue? \$\endgroup\$ – J Warner Mar 5 '16 at 21:19
  • \$\begingroup\$ Have you put the scope on the power rails to check if the noise is on the 3.3v? \$\endgroup\$ – HandyHowie Mar 5 '16 at 21:31
  • \$\begingroup\$ Hi Howie, just done that - it's perfectly clean engine on and off... \$\endgroup\$ – J Warner Mar 5 '16 at 21:35
0
\$\begingroup\$

An LPF on the input might be a good place to start. The transient appears to be a much higher frequency than the tach signal (but you need to make sure that's true for higher tach frequencies). Just place a small capacitance in parallel with the input side of the opto-coupler and see if it improves. Keep adding capacitance until the noise goes away or your signal starts to fall apart.

If a simple LPF doesn't work (or if it is degrading the nice edges of your signal too much), try an LPF followed by a Schmitt-trigger (LPF on input and Schmitt trigger might work, but if you use a Schmitt trigger that can handle 12V, putting it on the input side would keep the edges through the opto-coupler nice and square).

If all that fails, you could try to fix it in software: the noise only occurs intermittently, so taking the mode of a few cycles should eliminate it.

\$\endgroup\$
  • \$\begingroup\$ Thanks very much- will try that, what would be a sensible starting value in your opinion 0.1uF? \$\endgroup\$ – J Warner Mar 5 '16 at 18:56
  • \$\begingroup\$ Yes, 100nF is probably a reasonable starting point. \$\endgroup\$ – uint128_t Mar 5 '16 at 19:14

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.