Control and Distribution of Power – ATX and Pi

Control and Distribution of Power – ATX and Pi

The sensors and devices that I plan to control are located several meters from each other. This is just the nature of things. If I want to successfully deploy and reliably use the system, it means I’ll have to reconsider how everything is powered. The bench in my lab allows me to use AC adapters to power the devices. The wall outlet is nearby and I don’t have to fuss so I can focus on other things. This isn’t true for real world applications. My smoke detectors are ceiling mounted and my ventilation is hard powered from the electrical panel. Even if outlets were everywhere, I would be adding another fail point by using dozens of AC adapters throughout the system. Also, I’ve experienced cascading failures where a bad AC adapter bricks a device it is powering. To avoid all of this headache, I’ll be supplying power from a central location. Since I have to run a data cable to each of these devices, I might as well use some of the lines for power.

Enter the old and reliable ATX PSU. The power supply unit used in personal computers is a perfect consideration for powering all of the sensors and control devices. The cost of a PSU is a fraction of what it would be for all of the AC adapters. In addition, it is more efficient to do the AC to DC conversion once versus by a factor of x for each adapter. I have had great success using an ATX PSU to replace failed power adapters for my NAS devices.

Again, since I’m running physical data lines to the sensor control network, I’ll use some of the extra lines for power. For this purpose, I’ll be using 4 pair UTP Ethernet cable. I only need 3 lines for my I2C bus which includes ground. I can use an additional 3 lines to supply 3.3, 5, and 12 volts DC which should cover any future requirement. Do note, this does not follow any standard such as PoE. The supply voltage for PoE is much higher. To avoid confusion, I’ll be using colored cabling and junction boxes that are clearly labeled as such.

The ATX PSU pinout is as follows.

The supply amperage from ATX PSUs vary depending on their rating. Always check to ensure you have enough driving force to power all of your devices safely and reliably. One of the interesting aspects of the ATX PSU is its standby mode. From the pinout above, the purple 5 volt standby line is used by systems to operate them in a powered off standby mode. Computers use it as a way to remain off and power on based on a schedule or by instruction from a network connection known as WOL (Wake On LAN).

We’ll be using the standby line as our primary supply voltage to our main raspberry pi controller. The raspberry pi will not need more than 2 amps to operate and the ATX standby line provides plenty of push to accommodate the raspberry pi.

The added benefit from powering our raspberry pi this way is we can use it as a controller for powering on or off the ATX PSU. The PSU green line simply needs to be set low for the PSU to fully power on. We’ll do this using a transistor switching circuit shown below.

This control will be useful for a number of reasons. If a low voltage condition is detected from the PSU, the raspberry pi can power off the ATX and send a notification of a fault. This could precede damage that might occur had the PSU been left in a powered state. If supply AC service becomes unavailable, the raspberry pi can power off the ATX to ensure the UPS battery run time will be as long as possible for it to operate. None of this would be possible with AC adapters. Here is a code snipet of a script I use to control the PSU with the Raspberry Pi GPIO pin 24.

gpio -g mode 24 out            # Set GPIO pin 24 as output
gpio -g write 24 1            # Turn on PSU
echo "Turning on PSU and powering up Arduino"
echo " will be on for 10 seconds"
sleep 10s                      # Wait 10 seconds
gpio -g write 24 0            # Turn off PSU
echo "Turning off PSU and powering up Arduino"
echo "...Going to close script in 10 seconds"
sleep 7s                      # Wait 7 seconds
echo "Bye bye..."
sleep 3s                      # Wait 3 seconds

I mentioned the use of a UPS (Uninterrupted Power Supply) above. Using a UPS will be essential. We want to protect our PSU from under or over voltage conditions. We also want to have graceful shutdown of our system to protect against data corruption. The UPS is a simple low cost solution that we can monitor using the raspberry pi and a service called APCUPSD. I won’t cover the service in detail here, we can at a later time. Just note that it lets us control the UPS using software via the USB cable from the UPS to the raspberry pi.

Although we are ensuring our supply power is conditioned and protected, outside forces can still act on our mini grid. This interference can be caused by high energy spikes caused from solar events, lighting storms, or other electromagnetic conditions. We’ll using ferrite chokes to further protect our devices from these forms of influence. Nothing is 100 percent, this is a best effort. Not doing so is a choice, however the cost of putting in EMI protection is relatively low compared to repairs and down time.

Another thing I would like to cover is line loss. Some of the runs from our controller and voltage source will be long. None of them will be greater than 100 meters. Still, there could be enough copper in the wire that significant attenuation could occur. One offset for our power requirements is to use a higher supply line and regulate it at the device. The extra 2 lines in the Ethernet cable might also need to be used to handle the larger supply and ground requirement. For our data lines, we could do the same and use logic shifters to adjust the levels to safe operating ranges. These do not need to be covered in detail here, but it will need to addressed as each device is developed. Keep this in the forefront of development. You don’t want to cook your supply lines.

Enough with all the theory, now it’s time to put all the pieces together. Here is a list of the hardware I’ll be using.

  • UPS – Uninterrupted Power Supply
  • PSU – Power Supply Unit – ATX
  • PDU – Power Distribution Unit – Terminal Block
  • Raspberry Pi – Central Controller
  • GPIO Header – Data Distribution Terminal Block
  • GPIO Header Ribbon Cable
  • UPS Control Cable
  • PSU Supply Cable
  • Wall Panel Enclosure

This is going to be a utility, so you want to place it were it will belong. I’ll be locating mine in the basement, mounted against the wall near my other home utilities. Everything should fit neatly in the enclosure. I’m leaving plenty of space for easy access and for venting so nothing overheats. As my sensor and devices begin to get deployed, I want to be able to connect them without too much effort. Keeping these ideals in mind when placing it will prove to be rewarding later on.

The PDU and GPIO header will be used to connect my devices and sensors to as they get deployed. This makes it scalable and reducing the time and effort to add or remove items as needs change. This pretty much covers the physicality of it. Now I’d like to give some basics about the software on the raspberry pi which will monitor and control power.

There is a service that I installed on the raspberry pi called APCUPSD. This works with my APC model nicely and lets me monitor and control the UPS. Not only that, I can do other functions based on what the service sees on the UPS. For instance, I can send an email if a power condition is detected. I can track my power consumption and log it. The service also provides other features like a web interface. It has many more features that I won’t cover in detail here.

The other item I would like to cover is the PSU control program. This is nothing more than a GPIO pin digitally controlling the transistor switch to turn the PSU on or off. It’s really basic. I’m not covering GPIO programing here, I’ll do that on another post. Just know that it doesn’t take much effort.

Another thing I would like to do is monitor the conditioned voltage levels supplied by the PSU. Tracking the 3.3, 5, and 12 volt lines is a simple matter of feeding them into a level matching circuit, next on to a analog to digital converter, then on to the raspberry pi GPIO. Here we can track and take action based on those readings.

That pretty much covers this topic. I hope you have enjoyed this and found it informative. Please join me for more posts as I begin to build the sensor and control system.

Comments are closed.