My code and circuit worked great when wired into the motorcycle battery. Then when I actually finished the motorcycle engine and ran it, my lights went haywire! When the engine is off, the lights work fine; engine on and they blink rapidly. Turn the engine off and they work normal again.
What I imagine is happening is that some dirty electrical frequency is getting into my Arduino inputs and telling the Arduino that the buttons have been pushed when they actually haven’t. I’m thinking I’ll have to add ferrite beads or possibly capacitors somehow?
The full electrical schematic is attached as a Fritzing file. Thanks!
Oh, and unfortunately I wont actually be able to try any troubleshooting on this for a while as I am moving cross country and the engine is broken again :(
Once I have the engine fixed I may be able to run the bike without the alternator attached, which would eliminate that as the source of the noise. If the noise is still present with the alternator disconnected, my next guess would be the ignition coils/spark plugs. We'll have to wait and see...
may be able to run the bike without the alternator attached, which would eliminate that as the source of the noise.
I would have thought that having the alternator running is rather more important than any Arduino-controlled brake and turn signals. You might try solving the problem using the standard suppressors and ignition cables used in cars.
Suggest you start by finding out whether the problem is EM radiated noise, or noise on the power supply, or something else.
You could find whether it's EM radiation by removing the external wiring to the sensors, leaving any external pullup/pulldown resistors in place. If it's EM radiation, you could address that by screening.
You could find out whether it's noise on the power supply by giving the logic components a known clean power supply i.e. not powering them from the bike's electrical system. If it's power supply noise, you could address that by adding a low pass filter to the incoming power line or by using a better regulator to convert the noisy 12V ish supply to a clean filtered 5V.
peter is smart! do you have a spare battery lying around? with the whole thing installed on your bike, but wired to the spare battery sitting on the floor, startup your bike and see if the issue survives. then you know if its radiated noise or electrical noise quick and easy
in cars it is pretty hard to get a non-resistor plug unless you wanted to on purpose.
That's not my experience. You need to specify the resistance characteristics (along with all the other properties) when you select the plug type, but non-resistive plugs are readily available and no harder to get than the resistive types.
To revive my long dormant post and hopefully help someone else, here's an update.
I've finally come ashore for long enough to set up a proper garage and put some energy and brainpower into my motorcycle. As suggested above, I have tested the electrical system with an independent, clean power source but this did not resolve the issue.
User Chagrin mentioned (literally years ago) that sparkplugs without internal resistors can cause a huge amount of RF interference. Indeed, the sparkplugs that I have installed are no resistor type and the lights erratic behavior does seem to increase in frequency when the bike is revved tto higher RPM. Tomorrow I will buy and install resistor type sparkplugs and report back my findings.