Tuesday, January 1, 2013

Raspberry Pi board power design

Now that we have the Raspberry Pi's mounted on a plexiglass board and a power supply has been obtained that can easily put out the 8 A at 5 V requirement, it is time to give some thought on how to get the power to the board. Whenever you build something, there are a few design principles to follow:

1. Safety first
2. Make the design scalable
3. Keep it as simple as you can make it

Safety first means that I don't want to have to worry about excessive power all going through one circuit. If I can break it up in smaller sections, I think I'll prefer that. Looking at the problem at hand, there seem to be two ways to get power to the RPi. One is using the micro USB connector on the board, and the other is via the GPIO pins. After reading quite a bit of online articles, I decided against using the GPIO pins and I went for a USB-based approach instead.

Having made that decision, I decided to go for three power boards, each containing 4 USB ports. The boards must be put in parallel to distribute the current requirement. Each board will have a toggle switch to power it on or off, an LED to indicate if it active and the main circuit will have a fuse in it; for the time being fused at 10 A. If I decide to add additional Pi's, all I need to do is add a board and maybe upgrade the fuse.
Theoretically, each power board should be able to deal with about 2 A. Note that I will not need a separate power switch or LED indicator for the total circuit, since that is taken care of by the power boards.

Each power board is relatively simple also; two double USB-ports (DigiKey: ED2984-ND) in parallel, a toggle switch (Radioshack 275-613) and an LED indicator to signify that the board is on.


Note that pin 2 and pin 3 of the USB ports have been shorted; that just means that no data will flow and that the port can only be used for charging. The resistor in series with the LED is just a current limiter; the LED (568nm; green) has a forward voltage of 2.2 V, which leaves 2.8 V over the resistor. I need a current of 25 mA, which means that the resistor needs to be about 120 Ω. Because I had them, I put in 330 Ω, which gives me a current of about 8 mA. Not the brightest LED, but that's okay.

For now, the plan is that I'm going to build up the circuits using a simple PC Board.

Next: Prototype power board to light up four Raspberry Pi's

Using a PC power supply for Raspberry Pis

Now that I had determined that I need to be able to provide approximately 500 mA of current at +5 V of voltage per unit, which adds up to needing the capability to draws about 9 A when all boards are on, I needed to come up with a way to make that happen. A quick experiment with a multi-port USB hub with external power quickly made it beyond obvious that was not going to work. The hub ran out of juice after four Pi's, and I need to be able to power a dozen or more.

Rather than coming up with something complicated, I decided to convert a PC ATX power supply and strip out everything I don't need. PC power supplies are cheap and they provide a range of voltages (+12 V, +5 V, + 3.3 V, to name a few). My power supply is capable of 22 A at +5 V, which is plenty for my purposes.

Fortunately, all wires are color coded, and that was going to be helpful. There are a few things worth mentioning:

1) A PC power supply will not work without some form of a load over the +5 V line
2) In order for the power supply to turn on, the switch wire (green) must be connected to ground

With that knowledge; we can by removing all wire ties and connectors from the cables sticking out of the power supply. Once that is done, we can start opening up the enclosure. Be careful, there are some large capacitors in there that can hold quite a nasty charge. You don't want to be on the receiving end.



Since a normal PC power supply is turned on and off by the master switch on the PC enclosure, we want to bring in our own switch. I like to have a visual confirmation of the fact that the power is on, so I included an indicator LED also.

For both the switch as well as the LED, I needed to drill holes in the enclosure. Make sure that when you do that, metal shavings don't short out any of the components in there, and make sure that the drill doesn't go too far and damage stuff on the circuit board.

On the left-hand side, from top-to-bottom, we see the toggle switch (Radioshack 275-603), the load resistor (Radioshack 271-132), two banana plugs (that I ended up not using) and the LED (Radioshack 276-271).

The first thing to do is remove all wires that we know for a fact will not be used. In my case, I removed all but the black, red, and green wires. Using wire cutters, clip the wire as close to the circuit board as possible and pull out the clipped ends. You'll still have quite a few red and black wires left; don't trim any of those until you are doing putting in place what you need; it is much harder to unclip than it is to clip ;)

Step 1) Cut back one black (ground) wire and one red (+5V) wire and strip about 1/2 inch of the insulation. Don't go back all the way to the circuit board; but go short enough that it fits in the enclosure comfortably. Slide pieces of heat shrink tubing over the trimmed wires.

Step 2) Solder the 10 ohm resistor to the wires, move the heat shrink tubing over the exposed leads and apply some heat to shrink them into place. If you can avoid having live leads exposed, why not do so? I found that the best place to mount the resistor is next to the cooling fan, and zip-tied to the grating. Your mileage may vary.

Step 3) Figure out how to position your switch and, using a multi-meter, measure what leads you'll need to use. Remember; a switch in the down position is usually off, a switch in the up position is usually on. Cut the green wire (power switch) and a black wire back far enough that you can reach the switch leads comfortably. Keep in mind that there usually is only one green cable; you don't get a second chance if you cut it too short, so err on the side of caution! Slide the heat shrink wrap over the wire, solder to the switch, position the heat shrink tube and apply heat to shrink.

Step 4) Identify a red cable and a black cable and cut it to size to fit your LED. Slide on heat shrink tubes. Note: unlike light bulbs, LEDs are polarized. Make sure you solder the wires to the right leads, or it won't work. The LED that I used had a resistor included with it, so I didn't have to worry about that. If you are using separate LEDs, you'll have to put a resistor in series. Don't forget to position the heat shrink tube and apply heat.

At this point, you should be pretty much done. Cut back all but two red wires and all but two black wires. Make the cuts as close to the circuit board, taking care not to damage anything in the process.

Next, you can take the two red leads and twist+solder them together, and do the same for the black. Before closing up; it probably wouldn't hurt to grab your multi-meter and just test some leads. Apply your line voltage. If your fuses didn't pop, you probably didn't short out anything. Go ahead, and see if you get +5 V over the wires. If you do, you're done. If not, it is time to troubleshoot.



My final product looks like shown above. You can see the 10 ohm resistor sitting next to the bit heat sink, held in place by two tie wraps. The front of the enclosure has the toggle switch and the LED indicator. My +5 V wires hang out the back, and measure as +5.06 V.

Next: Raspberry Pi board power design

Power requirements of the Raspberry Pi Model B

The Raspberry Pi (Model B) is a nifty little device. It isn't loaded with computing power, but there is enough on the board to make it a fully functional computer. Since it can be powered by a USB cable, and USB ports are supposed to provide up to 500 mA of current (at +5 V), I had hoped that grabbing a multi-port USB hub with external power could do the trick.

Of course, any time that I would have done the math, I should probably have known better. A dozen RPi's at 500 mA each would mean 6 A of current without blinking.

After inspecting the external power supply to my USB hub, I found that it was rated to provide only 2 A. Oops; that won't do. But, since it is a bad idea to believe what you read without giving it a go, I started connecting RPi's to the hub and began powering them up. Sure enough, after four devices, we ran out of juice and the boards didn't get the power they needed.

Well; that threw a wrench in the mix. For me to figure out how much current these things actually draw, I had to sacrifice a USB cable. USB wiring is simple; there are only four strands. Two of those are for power (the outer two pins on the connector; typically red and black in the cable) and two of those are for data. Since we don't use the hub for data transfer, we don't really care about those two wires.


The photo listed above shows the RPi connected via a cross-over cable to my laptop, a micro-USB cable that had been opened up and the ammeter connected via alligator clips. To my surprise, the RPi draws the highest current when it is booting up; even when having the processor run at full load after it boots, it doesn't peak much after that. Measurements were consistently between 410 mA and 450 mA. Note that in my scenario, I am only putting load on the network jack. I presume that adding stuff to the USB ports and to the HDMI port will lead to a higher draw.


At this point, I am looking at potentially up to 15 devices drawing 450 mA each. After adding some overhead, it seems like I need to be able to provide between 8 A and 9 A of current. 


Monday, December 31, 2012

Mounting the Pi's

Mounting
By far the easiest part of the project to bring a dozen or so Raspberry Pi's online was finding a place for them to stay in one location. Rather than going with a Lego approach, I decided to obtain an acrylic sheet (plexiglass) from the Home Depot (SKU: 241610) and mount the Pi's on there.

There were a few reasons for that choice:
1) Plexiglass is cheap and easy to obtain
2) With a simple drill (Dremel-type), it is easy to drill the right size holes in it
3) It doesn't break easily
4) It looks nice

The disadvantage is that standard plexiglass is rather flexible. I expect that, once we are fully completed, I'll need to reinforce it somehow.

The Pi's come with two pre-drilled holes in the circuit board that can be used to mount them  perfectly. I decided to use Radioshack stand-offs (#276-195). They come in packages of four, and include two screws per standoff, which translates to two RPi's per bag. Without crowding the plexiglass board, 14 Pi's easily fit on a 18"x24" board.

Since my goal is to network the Pi's and to power them as well (duh), I decided to mount the top row of RPi's with the SD card facing down and the bottom row of RPi's with the SD card facing up. The means that

a) power is on the inside of the board
b) SD cards are on the inside of the board
c) Network cables are on the edge of the board.

Labeling is an important thing to keep in mind, since the RPi's all look the same. After mounting the first set, the board looks like this:


Note that my idea was that I was going to power the boards via a USB hub. According to spec, each USB port must be able to provide 500mA of current, which I believe to be enough. It turned out very quickly that this was not the case, and I'll elaborate on that in a later post. Suffice it to say, the USB hub is no longer part of the design.

Anyhow; after also mounting the bottom row, adding network cables and a few switches, the whole thing looks like this:


Note the two zip-ties that keep the cable mess together on the board. When we come closer to finishing up, I'll make sure that the network cables are all of the right length, the same color, etc. The eye needs to be pleased also, after all.

In a next post, I'll cover getting power to the board.

Next: Power requirements of the Raspberry Pi Model B

Sunday, December 30, 2012

Project initiation

Introduction
After experimenting with a single Raspberry Pi, I came to the conclusion that the units form a cost-effective platform to give undergrad students a dedicated Linux node for the duration for a semester. They'll have full superuser access in an isolated playground, and they can access the machine whenever they feel the need to do so.

To take a simplistic view of this, I'll need to solve two problems: hardware and software. Hardware appeared to be easy. Simply order however many units you need, find something to mount them on and power them up, and tie everything in to a network switch. It turned out to be a little more problematic than that, but none of the things that I ran into proved to be insurmountable.

I started out with ordering 15 boards, and they came in a nice small package.


For my project, I was able to get the Model B Raspberry Pi's that come with 512 MB main memory and
with on-board 100 Mb/s network jacks. Earlier in December, MCM electronics had plenty of Pi's in stock and was able to get them out quickly. If you're looking for a Pi and cannot find any, it is worth checking them out.

Next: mounting the RPi's

My Raspberry Pi experiment

(cross-posted from my Information Security Leadership Blog)

I ordered a Raspberry Pi a while ago to tinker around with. I did not have a fully developed plan for what to do with it yet, but a fully functional computer for $35 is something that I couldn't pass up. Now that I have messed around with it for a while, I'm really starting to like the device. Eventually, it will probably make a nice media center of sorts, but 512 Mb of on-board RAM is plenty to run a modern (headless) Linux distro and plenty of useful software has been ported to the platform.

As you know, I regularly run classes in which students participate in a virtual cyber wargame. That game typically involves about a half dozen targets, serving different purposes Some of the limitations that I experienced in the past were constraints on the number of VMs that I can bring up, and the fact that I cannot give my students their own individual machines.

With Raspberry Pi's, that  might change; there is really nothing wrong with provisioning one RPi per student. I'll need  a cheap network switch to power them all and  punch of power supplies and/or a USB port replicator that can provide enough current for the boards. They'll still be behind some form of a bastion host, so I don't have to have a top-of-the-line switch; something cheap(ish) will do just fine.

The guys over at Pwnie Express have put together a nice bundle of security software for the RPi that  might just serve my purposes very well.

It is worth exploring!

New blog: Technology Toolshed

I started blogging about my experiments with Raspberry Pi computers on my Information Security Leadership blog. However, since hardware tinkering and Information Security Leadership are only slightly related (at best), I have decided to spin my technical musings off to a separate blog. If you are interested in what I am doing in hardware land, please subscribe to my Technology Toolshed blog.