I am building an electronic tachometer for an old motorbike (a moped).

For RPM monitoring I have come up with a solution of painting part of magnet black and using a TCRT5000 reflective sensor which is fed to a LM393 comparator which finally drives an interrupt pin on an ESP32. A DAC pin from ESP32 is used to set the LM393 threshold as a means for sensitivity control. There is about 100 - 150 cm of cable which needs to be routed more or less near the spark plug wire to the handlebar. The circuit has its own power and is isolated from the motorbike. For completeness: the motorbike has an induction coil and contact breaker. The spark plug cable is strained copper about 20 cm long.

The problem is that when the engine runs there is so much EMI from the spark plug and its cable that it causes countless interrupt firings. The interrupts happen only when the cable is connected to the pin. I am using a 3 x 0.08 mm microphone type cable with the shield connected to ESP32 ground and not used for communication.

So far I made the following improvements with limited success:

  • a low pass filter at 300 Hz (R = 5.1k, C = 0.1uF) at the microcontroller side
  • changed 10k pull up at the comparator output to 1k
  • added two 1N5819 Schottky suppression diodes at the microcontroller side
  • wrapped the spark plug wire with household aluminium foil, connected to motorbike chassis (this to my surprise helped quite a bit)

I am looking for practical solutions to my problem: preventing EMI propagation at the spark plug wire and shielding at the data cable. The space inside the motorbike compartment (where the sensor is located) is very limited so a more complex circuit cannot be put there (like a differential driver). Also, the spark plug cable cannot be changed nor relocated. Any other idea is basically doable. What are the best practices, which type of cable is to be used, etc. I am not an expert in electronics so I would be happy if answers included sources to allow me to further study the matter.

For the record: the setup is tested on the bench with an electro motor and at around 8k RPM still works as intended. I am unfortunately unable to include an oscilloscope measurement image as I do not own one. I hope an expert in the field can guess pretty well what is happening inside the cable.

Thank you in advance!

Motorbike setup


Suppression diode idea taken from here: https://www.digikey.com/en/articles/techzone/2012/apr/protecting-inputs-in-digital-electronics

Motorbike's technical book with electrical scheme (unfortunately Slovene): https://www.google.si/url?sa=t&rct=j&q=&esrc=s&source=web&cd=10&ved=2ahUKEwjH7fXeg6PhAhVx-ioKHXaoDZQQFjAJegQIARAC&url=http%3A%2F%2Fwww.obnovi-si.si%2FSlike%2Fkatalogi%2FKatalog%2520rezervnih%2520delov%2520Tomos%2520Apn%25204.pdf&usg=AOvVaw2RTRIM5KcCoMEm13dPCL8S

Cable (unfortunately German): http://www.produktinfo.conrad.com/datenblaetter/600000-624999/608065-da-01-de-MIKROFONKABEL_3_X_0_08_MM2.pdf

Edit 09/04/2019:

I was finally able to measure what is happening within the cable with a cheap usb scope. I am surprised that the signal going to the comparator is actually very clean, yet the interrupts fire randomly. The picture shows the non inverting input on the comparator.

enter image description here

  • \$\begingroup\$ You could try adding a low pass at say 100KHz to suppress some of the high frequency EMI. Does your MCU have pin level interrupt deglitching? \$\endgroup\$
    – crasic
    Mar 27 '19 at 21:20
  • 1
    \$\begingroup\$ I don't think shielding will help as much as you think. It certainly didn't help me. I was working with an FPGA though so I was able to program in something that would only trigger if the signal was stable X amount of clock cycles. If you are lucky your MCU might have pin deglitching/filtering. If not, you could program your interrupt to simulate this. Upon firing, a timer is started to fire a second interrupt. This interrupt checks the IO level to see if it is stable before running the actual routine. You can schedule or cancel more checks via timer interrupt for more samples before executing \$\endgroup\$
    – DKNguyen
    Mar 27 '19 at 22:14
  • 1
    \$\begingroup\$ If the pin runs to a timer, you can use it to trigger starting a timer directly. But if programming is not your thing you could try throwing in a some differential transmission and receiver chips. Place the chip as closely as possible to your processor so the spark doesn't couple in between the receiver and the MCU pin where the differential transmission cannot reject it. \$\endgroup\$
    – DKNguyen
    Mar 27 '19 at 22:18
  • 1
    \$\begingroup\$ Why not just sense the spark instead of going through all the trouble of suppressing it? A diode and and RC to decode the amplitude modulation might work. You can also filter more in software. \$\endgroup\$
    – crj11
    Mar 28 '19 at 3:04
  • 1
    \$\begingroup\$ @crj11 the moped probably has not battery and uses magneto ignition, which makes the coil voltage less predictable. there might be a point on the ltenator that can be tapped though but if the regulator is a shorting type that could be messy too, an inductive pickup on the spark lead should work, but they're fragile. \$\endgroup\$
    – Jasen
    Mar 28 '19 at 7:18

Without knowing the type of .1uF capacitor you are using in the low pass filter, I would suggest adding a lower value ceramic cap in parallel with the .1uF cap, similar to the 100nF cap that is in parallel with the 1uF cap on your Vcc bypass.

The noise from the spark is wideband, extending into RF. Capacitors have parasitic series inductance that becomes important at high frequencies. Most capacitors will typically act as inductors at a high enough frequency, and the transition typically occurs at higher frequencies for smaller, lower value capacitors. Parasitics vary widely depending upon the capacitor construction.If you click on a capacitor type at this link, you will be able to select parts, compare their frequency response and download their spice models.Kemet has a tool for modeling their capacitors

  • \$\begingroup\$ Please, add an explanation why would this help. \$\endgroup\$
    – Blaž Umek
    Mar 28 '19 at 23:23
  • \$\begingroup\$ If I understand you correctly, my low pass filter might not actually block certain frequencies? I am using a ceramic cap though. \$\endgroup\$
    – Blaž Umek
    Mar 29 '19 at 10:23
  • \$\begingroup\$ Roughly speaking, a real world capacitor is a series resonant circuit that will have an impedance that decreases as the resonant frequency is approached from below and increases above the resonant frequency. For example, the K-SIM tool I linked to above shows that the C1210C104K5GAC .1uF ceramic chip capacitor has an impedance of about 8 milliohms at 15.8MHz, but rises to 465 milliohms at 95.5MHz. If you are using a capacitor with leads, the lead inductance must be considered. Using a number of smaller caps in parallel will reduce equivalent series inductance and resistance. \$\endgroup\$
    – mdm55
    Mar 29 '19 at 22:19

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.