Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Sunday, July 20, 2014

Raspberry Pi GPS Stratum 1 NTP server

First. most of the credit for this goes to this page.

I stumbled across it after asking myself (and Twitter) how accurate a GPS based NTP server on the Raspberry Pi could be. Accurate timekeeping has always been an interest of mine. Back when I was in college I breadboarded a CHU modem. I bought an early Magellan developer's board and always intended to turn that into a stratum 1 NTP server, but never got around to it. It was always made more difficult because desktop computers generally didn't have very good facilities for accepting the PPS input. Of course, the Raspberry Pi is a whole 'nother story.

I designed a GPS Pi Plate for the purpose, but it turns out that if you just get yourself the Adafruit Ultimate GPS module breakout board, you can pretty easily make yourself a custom 5 pin cable and be done with it.

What you need to make is a 5 pin .1" SIP cable. This cable is going to connect between pins 4 through 12 (that is 4, 6, 8, 10 and 12) on the GPIO connector and the bottom 5 pins of the breakout board (TX, RX, Vin, GND and PPS).

What you want to do is connect pin 4 to Vin, 6 to GND, 8 to RX, 10 to TX and 12 to PPS.

You can use these to achieve this. I used my own supply, but it's the same concept.

I went down the user-space path. All I had to do was install gpsd (and I'm not entirely sure how necessary that was) and rpi_gpio_ntp. The ntpd that comes with wheezy works just fine and is capable of accepting the 127.127.8.x "server" declarations.

ntp.kfu.com is the result - it's a public stratum 1 server. The catch is that it's IPv6 only. :)

Friday, July 18, 2014

Confirmed: Pi Power & Model B+

Here's a model B+ sitting in my hand. In this picture, I've installed a 14 pin stacking header on the remainder of the GPIO header.

A side view of the above. There is a slight gap between row 13 and 14, but it's not so wide that a connector won't fit.

And to prove that, here's a 26 pin header plugged in across the gap.

Pi Power user guide

Pi Power store on Tindie

This page is intended to be the end-user documentation for Pi Power. I'll revise this page if/when anything changes. The current version of the Pi Power board is v0.3. Here's the history:
  • v0.1 - initial version.
  • v0.2 - MOSFET changed from SOT-23-3 footprint to TSOP-6. The actual part is now a Si3443CDV for improved thermal performance.
  • v0.3 - Added auxiliary power input pads on the bottom of the board.
  • v0.4 - Add polyfuse on output.
The Pi Power is a Raspberry Pi power supply. It is rated to take in anywhere from 6 to 14 volts DC and output up to 2 amps at 5 volts. The power input jack is a standard 2.1mm barrel connector, tip positive.

Pi Power is compatible with all presently released models of the Raspberry Pi. If you're using a model A, then you can't take advantage of the added power for USB peripherals without modifying your Pi to remove the USB polyfuses. If you're using a model B+, then you may (or may not) want to elevate the extra 14 pins of the GPIO header with a 14 pin stacking header. You may want to do this so that you can plug 40 pin GPIO accessories in above Pi Power. You may not want to do this if you want to plug in 26 pin IDC (ribbon cable) connectors, since they collide with pins 27 and 28.

Pi Power's output power is regulated to within 1% of 4.968 volts. Ripple is 25 mV P-P when the supply voltage is greater than 9 volts, and rises to up to 45 mV P-P at lower voltages. Pi Power's efficiency is roughly inversely proportional to the input voltage. At 6 volts, its efficiency is in the low 90% range. At 9 volts, it's in the high 80% range, at 12 volts, the low 80% range, and at 14 volts it's in the mid 70s.

If you wish to use Pi Power in an automotive application, you should add two 1N4001 diodes in series to the input. This will drop the (nominal) 13.8 volts down to something closer to 12 volts. In addition, you should also add a 14V MOV across the power input to absorb any spikes.

The sweet spot for Pi Power is at a load of 750-1000 mA and a power supply voltage of 9 volts. If you were going to buy a "wall wart" power supply for Pi Power, my own recommendation would be a 8-10 watt 9 volt supply (or 9 volts at 800-1000 mA). I myself use a 12 volt, 1200 mA supply. A model B Pi with a keyboard, wifi module and camera can be expected to draw up to around 325 mA @ 12 volts. A beefier supply is just margin for future expansion. This will, of course, vary considerably from one Pi and peripheral set to another. Model B+ Pis will probably draw less by themselves because of their improved power supply infrastructure (but to make up for that, they offer 4 rather than 2 USB ports).

The output specification of "up to" 2A comes with some minor caveats. If you really want all of that 2A of output, you'll find that the MOSFET will start to get warm. This will limit the upper bound of the maximum ambient temperature to some extent. At 2A with a 12 volt supply, you can expect the MOSFET to rise up from an ambient temperature of 25°C to almost 60°C. Temperature is proportional also to the input voltage. If you really want to push the envelope, you should try and run with as low an input voltage as you can. None of this paragraph really applies to normal Raspberry Pis with reasonable and modest USB and/or GPIO peripherals. If you're not exceeding 1500 mA of draw or temperatures that are dangerous to humans, you shouldn't have anything to worry about.

If barrel connectors aren't your thing, then you can use the two auxiliary input pads on the bottom of the board. They're intended to take a 2 pin .1" right-angle SIP header. The pins won't go all the way into the hole because of the barrel connector on the other side. You might consider trimming the pins shorter so they'll fit. While soldering it, you will want to connect a plug to the header to insure the pins remain parallel to the board. Alternatively, of course, you could just solder two wires there instead. Be sure to take note of the "+" sign. The TVS diode will present a short circuit to a reversed polarity input to protect Pi Power (and your Raspberry Pi).

If you want to alter the output voltage of Pi Power, you can replace R1 and R2. As supplied, the resistors are R1=68k and R2=22k, for 5.08 volts. This makes up for any drop across the polyfuse that might occur. The output voltage is 1.242 * (R1+R2) / R2. If you prefer the voltage slightly low instead of slightly high, you could use R1=30k and R2=10k instead (4.96 volts).

Don't try to exceed 14 volts input voltage. As the voltage passes 14 volts, the switching frequency increases to the point where the capacitance of the MOSFET causes it to overheat. Furthermore, at 17 volts, the TVS diode will break down and start conducting, which may cause it to start heating up (which would be bad). Also, the breakdown voltage of the MOSFET is 20 volts and the voltage rating of the input filter cap is 25 volts. At some point under 6 volts, the output voltage will begin to sag. That likely would cause either your Pi or its peripherals to begin malfunctioning.

Don't connect anything to your Raspberry Pi's power connector while powering it with Pi Power, or connect Pi Power at the same time as other power supplies. Attempting to power your Raspberry Pi with two power supplies will not work properly - the two supplies will fight with each other to regulate the voltage, leading to unpredictable results that may damage one or the other supply, or your Raspberry Pi.

Before you begin

When you begin using your Pi Power, please take a moment to test it before you connect it to your Raspberry Pi. With a suitable DC input voltage between 6 and 14 volts, you should see 5.08 volts +/- 1% on the output. If you don't, then do not connect Pi Power to your Raspberry Pi until you resolve the problem. Pi Power injects power directly to the Raspberry Pi's 5 volt power bus, and if it's not working properly (for whatever reason), you could damage or destroy your Raspberry Pi.

When soldering the stacking header into place, it's not absolutely necessary to solder all of the pins. Soldering them all maximizes the mechanical strength of the connection, but at a bare minimum, you can solder just pins 2 and 4 and two of the ground pins, which are 6, 9, 14, 20 and 25. For maximum stability, pin 25 should be the first choice, but soldering all of the ground pins at least is a good idea.

You should also periodically check D17 on the Raspberry Pi (this is D5 on the model B+). This is a TVS protection diode located on the bottom of the board near the corner with the microUSB power jack (on the B+ it is on the top near the jack). If you feel it with your finger, you should not be able to detect any elevated temperature. If D17 is hot - regardless of whether you're using Pi Power or anything else - disconnect power immediately! D17 getting hot means that your 5 volt power supply voltage is too high and D17 is partially short-circuiting to reduce it. It can't do that for too long, however, before it releases the magic smoke. If D17 dies because the voltage is too high, then its death will very shortly precede the death of much more critical parts of your Raspberry Pi - very probably bricking it beyond repair. Excess current through D17 should cause excessive current through the polyfuse on the output of Pi Power, causing it to open to protect your Pi. If your Pi stops working, the first step in diagnosing the problem is to remove Pi Power and check both sides of the polyfuse for 5.08 volts. If you see a voltage other than that, then do not reconnect Pi Power until and unless the problem is resolved. If you see 5 volts on the "far" side of the polyfuse and not on the "near" side, then the polyfuse has opened. It should close on its own after a brief resting period, but if not, then it may need to be replaced.

Note that supplying 5 volts on the GPIO header bypasses the input fuse on the model A and B and the reverse polarity protection MOSFET on the model B+ (though Pi Power does have its own reverse polarity TVS diode on its input). This is why you need to check D17/D5 for heating. Normally, if those diodes were conducting, the excess current would open that fuse.

Schematic



Thursday, July 17, 2014

Pi Power's upgraded MOSFET

I couldn't wait the full two weeks. Last night before bed, I considered what it would take to kludge the TSOP-6 MOSFET onto the SOT-23-3 footprint of the prototype. The result wouldn't have the full thermal improvements of the new design, but at least electrically I'd get a preview of any particularly nasty surprises lurking.

Fortunately, there appear to be none.

The TSOP-6 device has pins 1, 2, 5 and 6 bonded to the drain; pin 3 is the gate; and pin 4 is the source. They intend you to put a heat spreader under and around the device that's electrically the drain signal.

The SOT-23-3 device is in a G-D-S triangle (with the drain on the side by itself). It turns out that the width of the SOT-23-3 package gate and source pins actually lines up with the TSOP-6 pins pretty well! The only issue is that the drain pad gets buried under the device, but I was able to replace the PCB trace with just a 22 gauge solid wire kludged onto two of the drain pins and reaching over to the diode's cathode.

I was able to get a good look at the regulation and output ripple on my scope with various loads at 12V in and there weren't any big surprises. The MOSFET still gets quite warm when you hit it with a 2A load, but I stuck a thermometer on it and it topped out in the mid 50s Celsius, which I believe is acceptable - particularly without having the correct thermal solution. The output ripple was still no worse than 25 mV P-P, and the regulation was still well inside of 1% (voltages edged down as low as 4.963 volts, but never went higher than 4.980). Efficiency at 12 volts was 87% at 500 mA, 86% at 1A, 85% at 1.5A and 83% at 2A.

For those of you playing along at home, remember that even 10W resistors get super hot when you ask them to get rid of 5 watts of heat.

Wednesday, July 16, 2014

Pi Power and the Raspberry Pi B+ - stacking headers

Those contemplating buying a Raspberry Pi model B+ can rest assured that they'll have no problem using Pi Power. To demonstrate exactly how, I've come up with a reasonably good fake demo.


Playing the part of the Raspberry Pi B+ this evening will be... an ordinary model B. Don't worry, we can still prove the concept.


Here we see a 26 pin stacking header along side a 14 pin stacking header. The one on the left is sold by AdaFruit, and it's what I've been using for my Pi Power prototypes. I believe they actually come from 4uconnector.

The 14 pin stacking header on the right is actually the remains of a 26 pin header that was cut down with a dremel. That's why the one edge looks a little... raw. Don't worry, that edge doesn't matter either - we'll put that edge on the outside.


Our hero - Pi Power!



In this photo, we're going to pretend that we've attached Pi Power to the 40 pin GPIO header of a B+ Pi. You can see that the GPIO header on the board has 7 rows that continue on at the end of the first 13.

This is something you can't do with a ribbon cable connector. Ribbon cable connectors - also known as IDCs - are wider than PC mount headers - you can't use a narrow one on a wide header because the wide edge of the connector will hit the first unused row of pins. But as you can see, Pi Power has no problem fitting properly.

This points out that Pi Power can be used as a serviceable workaround for 26 pin IDC cables! You can use Pi Power both as an IDC cable adapter and as a power source!


Here's another view of the same thing. You can see that Pi Power hangs way off to the right - on a real B+, that space would be the rest of the first 26 pins of the GPIO header, but for this photo shoot, we shoved it over to the right by 7 rows.


If you want to use Pi Power and the bottom 7 rows of GPIO pins, then all you need to do is add a 14 pin stacking DIP header onto the GPIO connector right next to Pi Power. Now all 40 pins are at the same level, and you can plug anything you like in while Pi Power supplies power to everything.

Just to prove that you can plug something in, this 26 pin stacking header is pretending that it's a 40 pin header. This works whether the header you're attaching is IDC or PC mount. Of course, it won't accept a 26 pin IDC cable, but you can still make that work by simply removing the 14 pin stacking header first.

Pi Power BOM details

If anyone is interested in building your own Pi Power (it is open hardware, after all), there are some details of the BOM (bill of materials - fancy name for a parts list) that I thought I'd share.

R1, R2, R4, C2 and C3 are fairly ordinary. I use 0805 parts. For the resistors, I buy 1%, simply because when you buy a reel of them, the price difference for 5% or worse isn't worth it. For the caps, 50 volts is fine. I forget which dielectric (X7R or NP0) I used. It hardly matters.

C4 is a crucial component. It's an OS-CON electrolytic. It needs to have minimal ESR and has to be able to tolerate the ripple currents - which won't be insignificant at 2 amps of output current. It's 100 µF at 20V.

C1 is a bit of an oddball. I'm used to input filter caps being electrolytic, but TI's design tool spat out a huge ceramic one. It's a 1210 X5R 25V. I currently use a Murata GRM32ER61E226KE15L.

R3 is another weird one. It's 25 milliohms and a half watt. They're in a 1206 form factor. I buy them from Stackpole.

L1is a 15 µH inductor rated at 5A of current. I'm using a Bournes SRP1040-150M. Large surface mount inductors are always fiddly to deal with because there are generally no standard footprints for them. I happened to find an Eagle library that lined up with the inductor I needed.

D1 was chosen for its forward current capacity. Not much else is special about it.

D2's purpose is both as a reverse polarity protection and to absorb voltage surges. Its breakdown voltage is a bit higher than the maximum rated input voltage for the circuit. If you're going to use Pi Power in a more challenging environment - in particular, a car - then you probably should augment the input protection - perhaps with an MOV and a fuse.

Q1 had to be upgraded. The original SOT-23-3 MOSFET that I tried got too hot at the maximum rated current. It got hot enough, in fact, that on my prototypes you can't read the markings on the top anymore. The replacement going forward will be a Vishay SI3443CDV-T1-GE3. It's going to have a nice, big heat spreader under it on both sides of the board with 3 chimneys underneath the case. If that isn't good enough, the next step would have to either be a D2PAK part or a TO-92. I seriously doubt that will be necessary. We'll know for sure in a couple weeks.

IC1 is an LM3485. There are two basic variants - the LM3485MM and LM3485MMX. I can't tell what's different about them, but they're the same price (at least for cut-tape) at DigiKey. I've been buying the MM one.

The power jack is the one I've been using ever since the very first SMD thing I've made. It's from CUI, and the only downside is that you can only conveniently get them from DigiKey, so when DigiKey is out of stock... poof. :(

That, and the board, are all you need to make your own Pi Power.

Or you can save yourself the bother and just buy one from me!

Monday, July 14, 2014

Pi Power efficiency

I was able to do some performance characterizations today in the lab. I could only go up to 1 amp of supply current, but what I got was that the efficiency was largely inversely proportional to the input voltage. That is, the higher the input voltage, the less efficient Pi Power gets. At 6 volts, the efficiency is in the mid 90s; at 9 volts, the high 80s; at 12 volts, the low 80s and at 15 volts the mid-to-high 70s. That appears to be a constant across the load conditions I was able to select.

The temperature of the MOSFET was also seemingly tied to the input voltage as well. So for best results, go for as low a voltage as you can. The downside of that is that the lower the input voltage, the higher the input current requirements. The sweet spot seems to be around 9 volts. If you have an ordinary R-Pi and are not trying to go nuts powering peripherals, you probably could do just fine with an 800 mA @ 9V supply. That will give you some headroom.

I power mine with a 10 watt 12 volt supply, and that works well too (it draws around 300 mA).

The actual boards that are going to go in the store likely will not have the thermal issues the prototype did. I have high hopes that the full 2A draw will be available with the upgraded MOSFET and thermal design.

Pi Power & Raspberry Pi model B+

It's early yet, but so far as I know, Pi Power should be compatible with the new Raspberry Pi model B+, but with a caveat.

The new model B+ has a 40 pin rather than a 24 pin GPIO header. The 24 pin header that comes with Pi Power won't fit. The 24 pin header that comes with Pi Power can be used, but the result will be that the bottom 14 pins of the GPIO header will be at a different "altitude," meaning that you can't just plug a 40 pin GPIO connector into the top of Pi Power. You have a few choices:
  1. You can buy a 40 pin stacking header. Install Pi Power over the first 24 pins. This is the best option if you can find a 40 pin stacking header.
  2. You can obtain a 14 pin stacking header and stick that onto the bottom 14 pins of the GPIO header, raising them up to the same level as the other 26. You can also do this with two 7 pin SIP headers.
  3. If you're trying to connect a 26 pin IDC cable to your model B+ and don't need the bottom 14 pins, then just use your Pi Power as an adapter for your 26 pin cable. You won't need to snip off pins 27 and 28 like you would if you wanted to squash the IDC cable directly onto the 40 pin GPIO header.
Again, I haven't actually had a chance to try it yet, but so far as I know, Pi Power's 5 volt output should work just fine powering a B+ model.

Sunday, July 13, 2014

Pi Power - prototype testing results

Well, the prototypes are not perfect. They're good, but I'm going to revise them once and that will be what sells when (and if) someone buys one.

On the bench, the output voltage regulation stayed good everywhere from 6 volts to 14.75, where the bench supply itself dropped out (it couldn't quite make it to 15). This was on no load, .5A, 1A, 1.5A and (briefly) at 2A. The ripple stayed within 25 mV P-P everywhere above 9 volts. Lower than that and the ripple started to increase up to a maximum of around 45 mV P-P.

I spot-checked efficiency. I didn't have an ammeter on the load, so I could only estimate it with the resistance values in use - which may not have been fully accurate. Nevertheless, efficiencies were in the 80% range or so.

The only problem I encountered was that at high current draw, the switching MOSFET on the board got very, very hot. I didn't fully understand the thermal implications and assumed that a MOSFET rated at 700 mW dissipation could handle <~150 mW without special attention, but now that looks like a bad assumption. The next board will have a MOSFET that comes in a TSOP-6 case instead of an SOT-23-3. It has 4 pins bonded to the drain, and I've made a bigger-than-recommended heat spreader for it with chimneys leading to another heat spreader on the bottom. The new MOSFET is also rated at >3W dissipation. All in all, I expect similar performance, but without quite as much thermal drama.

Meanwhile, the item is for sale in the store. If you order one today, you'll be assured of getting the new version in about two weeks when the boards come back from OSHPark.

Saturday, July 12, 2014

Pi Power - the rest of the CarPuter solution

A couple of people responded to my Twitter announcement of Pi Power by asking about achieving soft shutdown of an R-Pi when a car's power switch is turned off.

That's not a problem I'm 100% sure I'm prepared to solve, but I'll meet you half-way.

There's two parts of the problem: one is easy, the other is much harder than it sounds.

Detecting power on the accessory bus is easy:


You put 12 volts from the accessory bus on the left connector, and connect the right one to the R-Pi ground and a GPIO pin configured as an input. When the accessory bus shuts off, the pin will go low. Write yourself a little daemon that waits for that pin to go low and executes "shutdown."

And that's the easy part.

The hard part? Actually cycling the power on and off.

The assumption of the above circuit is that the R-Pi itself is powered from the battery bus - that is, it's power that never goes away even when the key is out. You need that, because if you power a *nix computer from a power supply that can just disappear, well, that's not terrific for the filesystem. So that's why we went to all the trouble of the circuit above.

But here's the thing... How do you know when a *nix system is shut down? If you're shutting it down, there's no processes left that can tell an external component that the kernel is all the way dead. You need a kernel process of some sort that will trigger an external event at or near the end of kernel shutdown. How you achieve that in the R-Pi kernel is an unknown to me.

You could guess... You could say, "well, we'll just leave the power on for a minute after shutdown and then just yank it." But how do you know that some rogue process/driver doesn't delay shutdown?

Even if you do solve that problem... What if you start shutting down the processor and the yahoo at the wheel turns the key back on? You've already started shutting down the OS. At the end, it's going to sit there like a rock. You still need to cycle the power - or at least reset the CPU - if the power came *back*.

All of that argues for something really smart - like an ATTiny85 or something like that - to intelligently communicate with the Linux kernel itself to control an external power switch and/or the R-Pi reset line.

That's not to say it can't be done... but it's not something trivial and tiny like Pi Power.


Pi Power is a go!

Finally! The power supply the Raspberry Pi should have come with!

Pi Power is a 2 amp rated switching power supply that should work with basically any voltage from 7 to 15 VDC on a standard 2.1mm center-positive barrel connector. It's ideal for car-puter use, as the input has a 16 volt TVS across it to protect from transients.

It plugs into the GPIO connector, and I use an extra-tall stacking header so that you can still use both the GPIO connector for something else, and plug into the display header underneath.

I've not had a chance to find where the edges of the specifications are, but I was able at home to draw an amp through it and saw no more than 20 mV of ripple on my scope, and a rock-steady voltage output of 4.96 volts with both 1A and 0 draw!

Running a Raspberry Pi with a keyboard and WiFi plugged in, it draws anywhere from 250 to 300 mA at 12 volts.

It's available in the store now at $15.



Tuesday, July 1, 2014

Pi Power schematic

Here's the schematic for the v0.1 PiPower boards that went off to OSHPark:

It doesn't use the MC34063, which is my new go-to DC-DC converter, because the output current requirements are too high for the 63's built-in transistors. Instead, I've gone with the LM3485, which is quite similar except that it controls an external power MOSFET, and it's an SSOP rather than an SOIC package (probably because it doesn't need the extra surface area to dissipate the heat from the internal current switch).

C2 is the main difference from a typical 34063 buck converter design (along, obviously, with the external Q1). It's purpose is to 'soft start' the current limiter so that the startup current doesn't trigger a shutdown.

I expect the first prototype to be done mid-month.

Tuesday, June 24, 2014

Raspberry Pi power supply

I've been playing with an RPI. So far there's one thing in particular that irks me: its power arrangement. 1A+ @ 5V over µUSB? Really?

No me gusta.

So I've got an idea to design a "cape" (or whatever you call RPI add-ons) to sit on the expansion interface. The board will be as small as possible, but will have a 2.1mm barrel jack and take in 6-12 VDC and supply up to 2A @ 5V regulated by a LM3485 buck converter. Mischief managed.

The board will have a "long tail" DIP jack to mount on the bottom which will allow you to stack other expansion boards on top.