First of all, I apologize for the lack of a “formal” schematic… I tried to draw one out, but got buried in the nuances of it :)
Second, I’ve done enough research to have some idea of what my problem is: namely, I need a decoupling capacitor in the mix. Problem is, I’m new enough to this that I’m not 100% sure where to put it, nor what capacitance I should use.
So the setup: -I’m using a Wemos(like) D1 Mini to drive 8 relays via an HC595 shift register -The D1 Mini microcontroller, HC595, and relay module are all powered by the same 5V DC and ground -The microcontroller addresses the shift register via 3.3VDC data pins -The relays power a water valve via a separate 24VDC power supply and transformer - plugged into the same AC outlet
And the problem: everything works just fine UNTIL I actually add the 24VDC power load. Once that’s done, the results are very erratic… usually turning on the correct valve correctly, but rarely turning it off in the same way. As I mentioned, I intuitively suspect noise in the data caused by the sudden power to the valve… but it doesn’t make too much sense since everything is on different power supplies.
Any guesses as to where I need to put some capacitor(s)? Thanks!!
That’s interesting, so you can flip the relays all you like without trouble as long as the 24DC supply isn’t connected? If that’s true then your problem presumably isn’t the typical inductive kick from the relay coil. It looks like your relay board has stuff on it which is presumably drivers and snubbers so let’s assume all of that is adequate to the job.
So, if it’s inductive kick from the valve solenoid it’s being coupled all the way from there, back through the 24DC supply to the outlet, then forward through the USB supply to your shift register, which is impressive! But not implausible.
Anyway, three places I’d add some stuff:
- The main thing you need is a snubber network across the valve solenoid coil itself, ideally physically close to the valve (you want to minimize the area of the loop formed by the valve coil - wiring - snubber). Something as simple as a freewheel/clamping diode would probably help a lot. This will also improve the lifespan of your relay contacts which are probably arcing a little.
- Small decoupling cap on your breadboard, say 0.1µF on the power supply rails, to keep your logic happy.
- Larger decoupling cap on your 24VDC rails (the bus on the left), just to eat any transients the snubber doesn’t deal with. Maybe 1-10µF or so?
Thanks for your thoughtful response… and sorry it took so long to get back to you. I tried different combinations of capacitors, a diode on the load lines, etc… nothing worked. And then I put a 0.1uF capacitor directly between the power leads on the valve itself… and everything started working fine. Admittedly, I’m not 100% sure why… but I won’t complain :)
That makes sense, it forms a simple snubber network. A capacitor in series with a low-value resistor might work even better. Did you try a freewheeling diode directly across the valve leads?
Not entirely sure, but maybe these help you somehow:
The relay has a coil which requires 0.35W. The chip seems to have a maximum output current of 35mA.
The ‚switch on current‘ of an inductive load is usually 3 to 5 times higher than the ‚hold‘ current.
The valve may not have a free-wheeling-diode. This could create an issue by creating strange voltage spikes on all your supply voltages (connected by GND).
Yeah, decoupling cap here might as well just help OP fry the chip more effectively by ensuring it can sink all that current.
Solution here is probably a transistor/MOSFET that the chip turns on, which in turn turns on the relay. Relay coils are inductors, so that probably also needs a diode to protect the transistor from inrush current and also the kickback when it turns off: inductors resist changes, so it’ll try to keep sinking the current and result in temporary spike of very high voltage: https://spinningnumbers.org/a/inductor-kickback.html
Thanks so much! It turns out that the relay (8x) module I’m using - https://www.amazon.com/gp/product/B00LX3UH9C - has isolated relays… but I’ll try a diode, too.
Seems your linked website as a very believable conclusion attached to it. I have a similar issue where the relay module would behave erratically. In my case it was when the relay module/595 chips received power before the Arduino was fully powered up. It’s unlikely that a load affects your relay module as they should never be connected to the main circuit.
I guess something like a pulldown resistor on the SER, CLK and RCLK pins would solve the issue since that would kill any noise. The noise is probably the kind of voltage that BARELY registers as HIGH but highly random.
That or making the relay module only turn on after the microcontroller has finished starting up using a mosfet or something.