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. is the result - it's a public stratum 1 server. The catch is that it's IPv6 only. :)

More power supply fun: Micro Boost

I don't know why, but I found myself looking at the Minty Boost today. It's been around for a very long time, but I noticed that it was all through-hole stuff. Even so, the layout is extremely compact, and I wondered for a moment whether one could do something similar with surface-mount components.

Long story short, I was able to recreate the Minty Boost design with surface mount components. The board I came up with was slightly larger than theirs, but I actually put a couple of #4 mounting holes in mine. Believe it or not, that accounts for a lot of the difference.

I started to price it out and noticed immediately that the boost converter they were using was a whopping $6. No wonder they are charging $20 for the kit!

Well, shoot, that just doesn't seem reasonable to me.

I immediately lit upon the NCP1402, which I had used with great success on a GPS reverse geocaching project a few months ago. The only problem with that was that it topped out at 200 mA, which isn't enough for the Minty Boost's 500 mA spec.

Well, that led me to the NCP1450, which is almost exactly like the 1402, but with an externalized MOSFET switch. Since the switch is external, there's no longer a current spec - you use however beefy a MOSFET you need. The NCP1450-5 and a NTGS3446 together are less than a third the cost of the LT1302 they're using. In fact, I could sell the "Micro Boost" on Tindie for $10 without a case (that's the board with all of the electronics assembled, plus a 2xAA battery holder), and I'm fairly sure it would fit in the $2 AdaFruit clone of the Altoids tin.

But would anyone want one? Can't you just buy these at Walgreens now?

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

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.
The Pi Power is a Raspberry Pi power supply. It is rated to take in anywhere from 6 to 15 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 15 volts it's in the mid 70s.

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. 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. The output voltage is 1.242 * (R1+R2) / R2. If you prefer the voltage slightly high instead of slightly low, you could use R1=68k and R2=22k instead (5.08 volts).

Don't try to exceed 15 volts input voltage. 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.

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.

Why crowd-fund?

A couple people suggested I go the crowd-funding direction with Pi Power.

I'm still not entirely sure why I should bother.

I tried a Kickstarter for the AD8495 breakout board. It didn't meet its goal, and so I wound up just going with a slightly higher price for it and selling it myself. It hasn't done very well, and the coup de grace was that AdaFruit started selling their own <sad trombone>.

I've set the price for a Pi Power at $15. How did I arrive at that price?

Well, what does it cost to build 1000 of them?

It turns out that in researching the crowd-funding angle for Pi Power - this time at IndieGoGo - I went through that whole exercise. I went with a US based PCB fab and assembly house. The assumption was that I'd ask them to build 1000 units and I was not in a hurry, so they'd take about two months from the time I said "Go!"

For the DigiKey BOM, I selected full reels of parts where the quantities and/or pricing made sense (why anyone would buy less than a reel of 0805 1% 1/8W resistors for $12 is beyond me). For the rest, I chose DigiReels (you get the cut tape price plus a $7 reeling fee).

And the answer? Around $8500. So $8.50 each. The 'doubling law' says I'm supposed to charge $17, but I'll go with $15. And I'll even throw in the 26 pin stacking header for free (1000 of those is less than 50¢ each).

Now, if you do the math for smaller quantities, what you quickly run into is that the cost of the fab making the PCBs starts to exceed the cost of an OSH Park medium run order ($1/in^2 each), and if I'm going to do that, then it just makes more sense to place, paste and bake the batches myself on demand.

I have very, very serious doubts that a crowd-funding effort for Pi Power can come up with $8500 in 60 days. Yes, there are projects that do that and even better. But they're the exception, not the rule.

So what does it take to get there? 1000 units is a lot. At one order a day (including weekends and holidays), it would take nearly 3 years to sell them. And one order a day would be a miraculous level of success.

Crowd funding makes sense for some things, certainly. But when the per-piece costs of what you're doing dominate the equation, I think it doesn't bring a lot to the table.

Am I wrong? Missing something? I'd love to hear from and/or discuss this in the comments.

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.