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!
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
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.