I'm quite inexperienced with any kind of electrical work and am currently putting together a set of (minimum 6) 12v solenoid locks to be controlled by a Raspberry Pi 4. So far, I have the Pi sending data through a shift register to a 5v low-trigger relay. The current function of the setup isn't an issue, but as it stands it contains 3 power sources: the stock USB-C 5vDC supply for the Pi, a random 5vDC supply for the relay, and another 12vDC supply powering all of the solenoid locks.
In order to simplify the powering of this system, I'd like to hook all of these systems up to the same power supply. So far, I'd read about using just a PSU from any old computer, and just connecting all of my components directly to it, but I was worried about noise potentially pushing a higher voltage to the Raspberry. I've already fried my first Pi by hooking it up incorrectly to the relay, and I'd hate to do the same again simply because I don't know what I'm doing.
A rough sketch proposing a circuit. Powered by the 12VDC and 5VDC rails of a standard PC PSU.
Each individual relay in the module uses this configuration.
With all that said, my overall question is the following:
- Will I need to worry about noisy feedback from a relay affecting a raspberry pi connected to the same power supply?
- Wouldn't that invalidate the isolation I'd acquired with the relay's opto-isolators and external power source?
UPDATE!! 06/26/2020
After weeks of working on this project, I feel like I've finally come to a pretty decent stopping point. Since this seems such a niche application for the question, I considered not updating any of this question. However, on the off-chance someone came along and found this project relevant, I figured it was worth doing. Hopefully it helps make development for someone else far easier than it was for me! With how little I know of EE, I figure documenting my own problems and solutions is the most I can give in return for the help I've been given here.
For whoever may come across this and be interested in what actually worked, the following is a description of the current functioning solution, as well as a summary of some of the problems that have occurred along the way: (And for whomever feels like critiquing the way I've done things - I'm always open to improvements)
The Current Setup I've decided to just use a 12VDC 2A wall converter as the overall power source. I have a +12V and ground rail split off for use in operating the solenoid locks while the main feeds into a 3A-rated, adjustable output, isolated-output buck-converter set to just over +5.0VDC.
The +5V source is being used to power both the 8-module relay and the RPi-4. I haven't yet decided if I would like to stick with a 5V fan for cooling the RPi and converter or upgrade to a 12V one since they will be housed together in a cramped compartment and tend to get quite hot. Either the fan will be attached to the 12V rail along with the solenoid locks, or pulled directly from the converters output with the rest.
The RPi is used to run a 74HC595N shift register which will in turn run the relay module. Eventually, the system will be expanded to require up to 12 locks, so this was deemed the most prudent solution.
A simple button will be used to properly turn the RPi off/reboot, while the power switch will have be be used to turn the system on and as a safety disconnect for handling.
Please forgive the odd choices for diagram symbols and labels - this is my first time using Fritzing and I'm still going through their library
The relay module is simplified to save space. In reality, each module is equivalent to what is shown in figure 2 above.
The problems thus far The first major issue encountered was a stray short from a faulty relay module. The relay was being powered directly from the RPi's 5V-out pins, and 12V somehow made its way from a solenoid attached to one of the relay outputs through a single layer of isolation to the RPi's GPIO pins. This led to some paranoia that a second layer of isolation was necessary "just in case". As such, a separate 5VDC source was hooked up to the relay module's JD-VCC and GND as per figure 1 above. At least it doesn't hurt anything, right?
When it came time to condense power sources, something really bizarre started happening. While no solenoid was connected to the +12V rail, the shift register would operate perfectly fine. Every byte input would be translated properly and cause the correct relays to trigger. However, for whatever reason, applying a load to the +12V rail would then cause the wrong relays to trigger in completely random ways.
After almost a week of troubleshooting the relay module, shift register, and GPIO pins, I was eventually able to trace the problem back to the RPi's power source! When plugged into a dedicated supply, the problem would disappear and the random relay-switching stopped.
The root of the problem appeared to be the presence of any load on the 12V rail. Any of the locks firing seemed to cause enough of a drop in voltage that the RPi was no longer capable of putting out a solid high/low signal in any of the GPIO pins. Without proper voltage-rise detection by the register_clock and latch_clock on the shift register, the register's outputs would be effectively random (with recurring patterns).
More research yielded several potential fixes - an electrolytic capacitor across the RPi's +5VDC and GND pins, a small ceramic cap. across the register's VCC and GND, an inductor across the buck-converter's outputs, removing the ground-isolation that the converter provided, etc. None of them seemed to fix the problem, while most actually made it worse. I finally decided to just try to buffer the voltage drop on the +12V rail (that occurred when a load was toggled on by the relay) with a (admittedly arbitrarily sized) large capacitor. Since the system would be intended to be powered 24/7, and each individual lock would be powered for short periods, I figured just about anything over 25µF would do the trick.
I picked up a random 47µF electrolytic capacitor from one of my variety kits and connected it across the +12V and GND rails and let the system toggle a few times. The correct relays fired for the most part, with roughly every 3/20 attempts yielding random results. I upped the cap. size to 100µF and the problem seems to finally be resolved!