I'm building a system as follows:
- There are two pumps which lower and raise the level of the water
- There is an ultrasound detector which measures the level of the water
- While the water is too high, water is pumped out
- While it's too low, water is pumped in
There are thresholds to prevent micro-adjustments, the system doesn't flip-flop back and forth.
However after a short while the ultrasound sensor stops working, until I power the system off and on again. My electronics knowledge is extremely rudimentary, but I know motors can be nasty to other components?
I've included my circuit diagram, should I be doing anything about that? I'm using reed switches to turn them off and on, but the ground and 5v rails are all tied together, and powering the arduino too via VIN.
2 Answers 2
Motors are inductive loads (they contain coils) that generate voltage spikes when switched off. These voltage spikes can indeed be nasty to other components.
You need to add a flyback diode in parallel with the motor, with the cathode connected to Vcc.
It will normally not conduct current, but when the motor is switched off, because the voltage spike is negative, it will provide a path for the current and allow to dissipate it through the coil's internal resistance.
As pointed out in the comments, it's also a good idea to (always) add an electrolytic capacitor (> 100 μF) close to the ultrasonic detector to filter out this kind of spikes.
-
1It might also be a good idea to put a capacitor of >100 μF between Vcc and GND, close to the utrasonic detector. Flyback diodes need to be placed between the reed relay and Vcc, in parallel with the motors, with the stripe (cathode) connected to Vcc.StarCat– StarCat2021年05月31日 06:22:24 +00:00Commented May 31, 2021 at 6:22
Hopefully you are powering the Arduino Vin with at least 7 volts. We know the Arduino a power supply it is NOT so where does the 5V come for the motors? You need to post technical links to the hardware items you are using. Are you calling relays reed switches? D11 and D12 sound like port pins, normally they cannot drive relays unless they are designed appropriately. I would suggest you either buy another set of electronic parts or stop using it until the problems can be determined. As far as a circuit diagram does not show the information needed. A schematic, not a frizzy thing is much better.
-
We don't know what the OP uses, but if you use relay modules designed for use with an arduino, they include the transistor to drive the relay as well as the flyback diode, at least for the relay.PMF– PMF2021年05月31日 06:20:41 +00:00Commented May 31, 2021 at 6:20