Strange problem with 12v motors - Page 1
Forum section: electronics / beginners

author: Remark
author_rank: Contributor
timestamp: January 14, 2023, 06:35:42 pm
content: Hello everyone.I'm working on a liquid mixing machine that uses 12v motors and valves with peristaltic pumps (it's a one combined system for different liquid flow channels). For some time now I have been facing with strange problem when pumps are started...Until the pumps are off, I can configure device through menu (I'm able to change several features with language and sensors). Everything looks good. But when one or more pumps are started, my 20x4 LCD freezes, sometimes I can use the keyboard , ignoring the stuck LCD, but the MCU sometimes also stops responding to all keyboard clicks.I use this relay module for motor, valves control (one relay for both. 8 pumps in total):The valves I use:Motors:Because of relay module is reverse controlled, I made signal inverters with 2n3904 transistors and voltage level shifters to receive 5v at the output, which would be suitable for controlling relays. This thing works well. When I turn off the GPIO signal from the controller, the relay turns on. When there is signal from GPIO, the relay turns off.I also tried to optically separate the relay control ports with PC817 optocouplers. No result.I made a separate 5v power supply for the relay module with a 7805 stabilizer. Also nothing.I noticed a small voltage fluctuation in the microcontroller part when the pumps are turned on. But I don't understand where the oscillation can come from if the low current part of the microcontroller is now completely separated from the relay module and the motors.Do you have any thoughts or have you encountered a similar problem?Thanks a lot for the answers.Remark.

author: Siwastaja
author_rank: Super Contributor
timestamp: January 14, 2023, 07:31:36 pm
content: Serious EMC problem within your thing.This is a common problem with those "arduino" modules; they are "designed" by hobbyists. How they are wired up doesn't make things any better.You can try some random simple modifications, such as:* add a small (<100nF) ceramic capacitor directly across the motor terminals* add some 100-470uF, 16V (or more) electrolytic capacitor(s) between the supply + and GND, close to the relay board, and another close to the MCU board.* keep wiring short and use enough ground wires (not just one). Make the GND wire go near the signal wires.This is not replacement for proper design, but possibly enough to solve the issue.

author: Infraviolet
author_rank: Super Contributor
timestamp: January 14, 2023, 07:38:30 pm
content: Personally, with 12V motors and lower voltage logic (5V? 3.3V?) I'd just get some h-bridge chips that can handle 12V for the motor side and take lower voltage logic on the controlling side. TB6612FNG is nice (if they are in stock thesedays) if the current requirement for each motor isn't >1A. A TB6612FNG will handle two motors, so you'd need just 4 for your 8 pumps. For higher currents there are fancier h-bridges. a h-bridge chip lets you control motors mroe quickly than a relay and lets you PWM them for speed control too, this is tricky with a relay that might only be able to close and shut ten times a second and, being mechanical, may have a limited lifespan of open-shut cycles. A h-bridge is fully solid-state electronic.As for your present issues, how many decoupling capacitors do you have around the MCU and LCD stuff? How is the low voltage rail for them being powered?I once built a system where the MCU browned out whenever a bright LED was turned on, because this sudden demand for current (from the same voltage rail as the MCU was powered) dropped the MCU's voltage. Provide lots of capacitors physically close to the MCU and LCD between Vcc and Gnd to fix this. You could even do some stuff with diodes which would ensure any drops on the power to the relays and motors wouldn't lower the logic's power supply.If you can post a full schematic of your setup it might help identify problem areas too.

author: james_s
author_rank: Super Contributor
timestamp: January 14, 2023, 07:40:21 pm
content: Does the same behavior occur if you disconnect the pumps themselves and just have the relays going? Can you post some photos of your layout and a schematic of how everything is wired up? What power sources do you have and how are they connected?

author: Remark
author_rank: Contributor
timestamp: January 14, 2023, 08:23:24 pm
content: Quote from: Siwastaja on January 14, 2023, 07:31:36 pmThanks for the reply!I'll try putting capacitors between the motor terminals tomorrow, I'll see what happens. There can also be problems with the wiring. It's not very short, due to the fact that I have to connect the keyboard, screen, sensors from long distances >50 cm

author: Remark
author_rank: Contributor
timestamp: January 14, 2023, 08:33:21 pm
content: Quote from: Infraviolet on January 14, 2023, 07:38:30 pmThanks for the reply!The power supplies look like this:when pumps are on, 3.3v line starts to fluctuate between 3.3-3.0v. I will try to put bigger caps between Vcc and GND and I'll see what happens. But I have a suspicion that larger capacitors may affect the startup of the MCU.

author: Remark
author_rank: Contributor
timestamp: January 14, 2023, 08:53:55 pm
content: Quote from: james_s on January 14, 2023, 07:40:21 pmThanks for the reply!When the relays are running at idle (when no motor is connected with the pump), everything works perfectly. I can activate or deactivate the relays and nothing gets stuck.I have put the schematics of the power supplies in this post. Now I do everything by testing what was not included in the design. I am also uploading a snippet of the optocoupler and inverter schematic that I am using.Instead of the motor shown in the schematic, I connected it to the relay trigger signal inputs on the relay moduleI'm also placed some capacitors to the LCD. Same as here:

author: Infraviolet
author_rank: Super Contributor
timestamp: January 14, 2023, 09:06:16 pm
content: From your first schematic, I'd put a 10uF in parallel with C4, C4 may respond faster (depends on cap types), but having a big 10uF there will help smooth over any power supply glitches.From your schematic in reply #6, why have you got 5V on both sides of the optocoupler? Seems pointless to have an optocoupler in those scenarios.Surely the point would be to have the stuff on the receiving side fully isolated from the logic side controlling the relay?If the relay is a mechanical one rather than an optocupler then a diode pointing backwards (flyback) across the relay will be helpful too.

author: Remark
author_rank: Contributor
timestamp: January 14, 2023, 10:47:47 pm
content: Quote from: Infraviolet on January 14, 2023, 09:06:16 pmYes, exactly. I had the idea to completely separate the relay module from the microcontroller. I did this using optocouplers. I don't know if this is a very effective solution. I encountered it for the first time.

author: james_s
author_rank: Super Contributor
timestamp: January 14, 2023, 11:17:42 pm
content: If you do that, you need separate power supplies in order to achieve isolation. I think the problem is with your power supply though given you said the voltage drops on the 3.3V rail. Is the 5V rail solid? Since you've got the regulators daisy chained an issue with one of the higher voltage rails will trickle down.

author: Infraviolet
author_rank: Super Contributor
timestamp: January 14, 2023, 11:21:55 pm
content: Can you get yourself an h-bridge instead? I'd be very surprised to see a good h-bridge giving any of these types of issues, especially if you ensure that the power is fed separately to the motor's side of the h-bridge than it is to the logic side.My suspicion is the issue here might be at the 5 volt rail, because it seems to be used to power the control side of the relays as well as powering logical elements.Remark: try removing the motors and see if you still have problems simply from controlling the relays even when there is nothing on the other end of them. If the problems disappear then mroe complex things are going on, but if they remain then we know it is related to the current draw (or any voltage spikes from) driving the controlling side of the relays.

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: January 15, 2023, 01:22:30 am
content: I had same problem with a model railway motor controller.The relay power supply needs to be substantial.Add 100uf and 100nf across relay power supply as close to relay as possible.The 100nf kills any nasty spikes.Have you added flyback diodes to the relay driver ?

author: Remark
author_rank: Contributor
timestamp: January 22, 2023, 07:05:15 pm
content: Thank you guys for the replies.I put a couple of electrolytic capacitors on the relay power supply and near MCU board. Also I put the 1n4007 flyback diodes on the motors. The problem seems to be gone. Nightmare.

author: james_s
author_rank: Super Contributor
timestamp: January 22, 2023, 07:37:36 pm
content: It's also not a bad idea to put a couple 0.1uF ceramic capacitors on each motor. A lot of electronic toys that had brushed motors put a capacitor from each terminal to the motor housing.