I've written a program that triggers both a motor and a laser. The laser is housed in a unit that senses a 5V pulse and turns the laser on accordingly. The issue is that the moment the motor toggles on or off, the laser fires, even if the part of the program that toggles the pulse that turns on the laser is removed. I have access to an oscilloscope, and it is clear that there is some electrical noise that occurs whenever the motor triggers on or off. Furthermore, when the positive lead to the laser was disconnected and the laser was only connected to the ground, I still noted the phenomenon occurring. I've tried this with two separated Arduino Uno boards. Any help/directions to forum posts regarding similar problems would be appreciated! I might not know the appropriate terminology that would lead me to the correct posting. Also, I apologize if this is the incorrect subforum, but it appears to be more of an issue with the board rather than the program.
Are you controlling the motor directly from an Arduino pin by any chance ?
That would be a very bad idea.
And you didn't forget to use a diode to get rid of back EMF ?
It is always best to power motors from a separate power supply and to use some sort of motor driver. Be sure to connect the motor power supply and motor driver grounds to the Arduino ground.
I don't have the board directly driving the motor, instead I'm using a xantach AC1 outlet voltage switch that toggles on as long as it receives a 5v input from the arduino board. I am not currently using a diode. Could back EMF be responsible for the fluctuations in the other parts of the board?
If it is a household AC motor and switch, then interference could be radiated by the motor leads, AC switch wiring or could be coming through the AC line itself. In the latter case, an AC line filter for the Arduino power supply may help.
Attached is a screenshot of a circuit diagram. I didn't really know how to represent the Xantach AC1 or the laser driver. Sorry for my inexperience! Does anyone know a good source for MOV or TVS diodes? If I'm driving the motor with a 5V pulse, would I want to connect a 6 V MOV/TVS in parallel?
Thank you!
Edit: They aren't actually connected to a common ground, that was a quirk of Fritzing. (I don't have CAD available right now)
Sorry to not be clear. The proximity sensor, laser driver, and motor toggle are all connected to different "ground" pins on the board. I'm not sure if these are all linked together (I'm using an UNO).
All pins named GND are connected.
In case a pin would be named slightly different like AGND or DGND, those are not connected directly.
You only have GND pins on your Uno.
A flyback diode might help, given that that fancy Xantech AC1 controlled outlet is probably nothing more than a relay in in some housing.
But also be sure to follow up on the other tips given.
Used twisted pairs and moved the motor driver/fancy relay away from the Arduino board
Recognize the need for a flyback resistor
In regards to 3, does anyone have suggestions as to what diode to get? Would a 1N4148 work? The signal to the relay isn't PWM, it's just a constant 5V from the board.
I tried adding a flyback diode to the circuit (1N4148) and it did not mitigate the effect. Furthermore, I discovered that the back EMF only persists when something is plugged into my relay, even if the relay is being toggled off and on. Am I just not designing the snubber circuit correctly, or should I try moving to something like a photocoupler to isolate the circuits?