1
\$\begingroup\$

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. 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. Each individual relay in the module uses this configuration.

With all that said, my overall question is the following:

  1. Will I need to worry about noisy feedback from a relay affecting a raspberry pi connected to the same power supply?
  2. 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.

Current Overall Schematic. 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!

\$\endgroup\$
  • 2
    \$\begingroup\$ It's really worrying when a person who describes himself saying "I'm quite inexperienced with any kind of electrical work" asks advice for a project like this one. In the first paragraph you mentioned a shift-register and a 5v low trigger relay. In question #2 you talked about opto-isolators. Where are the opto-isolators? The best way of getting help is posting a schematic of the circuit you want to build. \$\endgroup\$ – mguima Jun 5 at 22:18
  • 1
    \$\begingroup\$ Sorry about the confusion, I suppose my description wasn't very clearly written. I'll try to get a schematic uploaded soon. The relay module I'm using is a SainSmart 8-relay module that has opto-isolators for each of the relay input signals. \$\endgroup\$ – Garrett Jun 5 at 22:36
  • \$\begingroup\$ I've added a quick rough sketch. Please forgive the quality. \$\endgroup\$ – Garrett Jun 6 at 1:55
1
\$\begingroup\$

Computer PSUs tend to be nicely designed. At least the big name ones. They of course arent used to drive solenoids and relays. There may be noise when the solenoids are powered on or off. The noise is unlikely to damage your RPi but it can cause other noise issues like brownouts or false readings.

The simplest solution would be to keep your 3 supplies and just use a power strip/splitter.

The next easiest is to use a 12V supply for everything and add a 12v to 5v switching regulator (like a car usb adapter). This should help isolate the rpi and relay board from the solenoids.

Another option is to use a 12v supply and a switching regulator but also had a linear regulator to help smooth out the power input even more.

The next solution is as you described. It is a valid solution, the noise issue is just a concern. Testing would be simple enough for you to try.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ A 12v supply feeding into a buck converter was something I'd been considering as well. The question that kept coming up with such a configuration was whether or not I would need to have further protection for the RPi's power line? You know, in case the relay provides feedback that may put the Pi input over 5v. I imagine a regulator leading to the RPi after the split from the relay might smooth it out enough? \$\endgroup\$ – Garrett Jun 6 at 18:56
  • \$\begingroup\$ The relays on that module should have D1 a reverse diode for the relay inductance collapse. And your solenoids should have one too or you may want to add one. \$\endgroup\$ – Passerby Jun 6 at 19:39
0
\$\begingroup\$
  1. Even a 200 W PSU can supply about 15 to 20 A at 5V rail. I dont know how will be the relays' frequency of switching or if all of them will switch at the same time, but a normal PSU can handle this. If you experiment some problems, just add a capacitor of about 4700 uF to the power cable, place it near RPi. But I think that it will not be necessary.

But please check that the combined power requirements of the solenoids at 12 V respect the PSU capacity, too.

  1. No. You will be using RPi 3.3V logic to control the opto-isolator that controls the transistor. That's a lot of isolation to the RPi logic (GPIO). The power connector of RPI is not connected directly to the CPU. The RPi Gpio is connected only to the opto-isolator and to this shift register - you didn't tell so much about the shift register.

Generically speaking, this seems to be safe - at least you are not risking to fry RPi again. The worst that can happen is the circuit do not work.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.