Tuesday, July 29, 2014

An improvement for the USB µISP

I wanted the USB µISP programmer I designed a couple posts ago to be agile down to 1.8 volt systems, but the problem with that idea is that the voltage "break point" for a 5 volt ATTiny2313 is too high to register a 1.8 volt logic high.

But it struck me... why power the ATTiny with 5 volts? I went to the trouble of adding a 3.3 volt LDO to the thing... Why not have that power the controller as well as the target (if selected)?

If you do that, you can also dispense with the level shifting hardware for the USB pins - you can just connect them directly up! Because of the 74HC125 bus buffer, you can program 5 volt systems just fine, since it will happily level-shift the SPI signals up to 5 volts. When the bus buffer is powered by 1.8 volts, the logic high threshold for a 3.3 volt 2313 is still met, and the reverse is true when the bus buffer is powered by 5 volts.

So the net result is that the v0.2 of the µISP should be able to program AVRs operating at all allowable voltage ranges, and can optionally power either 3.3 or 5 volt targets!

Sunday, July 27, 2014

My take on an AVR ISP programmer

I've been using the SparkFun Pocket AVR for all of the time I've been doing it.

It does well enough for what I need, but it does have a couple of deficiencies that I'd address, if I had my druthers.

Firstly, it comes with a Mini USB plug. It's the only thing in our house that has one of those. Everything else is either full size or micro-B. I'd much prefer either over the now oddball mini B connector.

Secondly, though it comes with a switch to select whether or not to apply target power, there is a leak through the buffer control pull-up resistor that applies power even when target power is disabled. Others on the SparkFun comments for the product have noted this, pointing out that it's not safe to use with 3.3 volt devices. Even if it were, your choice is to either power the target at 5 volts or not power it at all.

Adafruit was the source of the original design. They sell a USB Tiny AVR kit. It didn't have the problem of leaking USB power to the target despite target power being disabled because it simply lacked the pull-up resistor. But that means that if you leave the USB end disconnected that the buffer pin will float, potentially taking the buffer chip out of its high-impedance state when you're not actually programming. Also, like SparkFun's programmer, there's no choice other than 5 volt target power or nothing.

So I sat down to make the best-of-breed USB Tiny ISP. My design is all surface mount, so it's quite small. It has a 6 pin ISP socket rather than a 10 pin, because 6 pin is all I use, and if you must, you can always make a wiring shim to turn 6 into 10. Like the original design, there is a 74HC125 bus buffer chip, and when target power is turned off, it is itself powered from the VCC pin of the ISP plug, so it is guaranteed to feed target-power based logic levels at all times. My addition to the design is a 3.3 volt LDO and a 3 pin .1" header that can be used with a jumper to select whether to provide the target with 3.3 volts, 5 volts or no power at all. I also kept the SparkFun addition of a PTC on the USB power input to protect the host PC. In the SparkFun version, they added a pull-up resistor on the BUFFEN line to insure that when the programmer wasn't actually programming the target that the buffers would be tri-stated. The problem with their design is that nothing prevents 5 volt power from being applied to the target through the pull-up from the CTL line when it is high. A simple 1N4148 diode fixes that problem.

In fact, the SOT-23-5 layout for the LDO can, in principle, take a 1.8 volt LDO as well, should you be designing for that voltage instead of 3.3. Turns out that the problem with a 1.8 volt programmer is that the ATTiny still running at 5 volts has a logic-high threshold of over 2 volts. A 1.8 volt programmer would need similar diode-and-pullup treatment on the "near" side of the bus buffer chip, and I'm not going to bother with that. You could power the ATTiny at 3.3 volts. You'd then have to move the zener-and-protection-resistor trickery from the USB bus pins over to MISO. I might consider looking into that as a next step in the design if 1.8 volt programming is a real demand.

JP1 is the self-programming interface. Since the 2313 is SMD, there's no (good) opportunity to program it out-of-circuit, so there needs to be an ISP for it, and since the buffer chip isn't bi-directional, the target ISP socket can't be used. Since I have a pogo pin ISP adapter I got from SparkFun, I can program the 2313 with that and to save space, bury it on the bottom of the board under the 2313.

I need help completing the Magic Trackpad Plugger

The Magic Trackpad "plugger" is a board with a 3.3 volt regulator that's designed to be the exact size of two AA batteries. Its purpose is to allow you to power an Apple Magic Trackpad with a USB connection rather than two AA batteries.

I sell the board in my Tindie store, but it's not a compelling product, as it's not quite complete.

What I envision to complete the product is a replacement for Apple's metal plug with a #6 hole down the middle of it, and a stiff metal spring that can be soldered to the - connector on the board.

The idea is that the USB cable would run up through the middle of the spring and through the hole in the metal plug. You'd insert the board into the battery cavity and then screw the plug in. As the plug was screwed in, it would compress the spring, pressing the + contact at the front of the board into its mate as well as insuring a good contact between the spring and the plug.

I envision the plug being created by Thingiverse out of metal.

But I don't have the 3D modeling skills to create such a thing, nor to spec or obtain the spring.

Can anyone help me out?

Thursday, July 24, 2014

Pi Power IndieGoGo

I've decided to dip my toe into crowd funding again. This time, it's Pi Power.

If you've been following along, you'll remember the last try was for an AD8495 breakout board. That didn't work out, but admittedly, it was a very narrow audience.

I think Pi Power has a much broader appeal.

Check it out at IndieGoGo. If I can fund building 1000 of them, then Pi Power will be self-perpetuating, since the proceeds from the first 1000 would be able to be used to build another 1000 and so forth.

Tuesday, July 22, 2014

A variable bench switching supply?

I've been doing the switching supply thing a lot lately, it seems.

I think the next thing I do might be something along the lines of a bench power supply.

I don't need something hyper-isolated or lab quality, but I would like something that would have a constant voltage output combined with an ammeter.

My thought is that if I start with a very standard 18 VDC, 5A unregulated supply (that is, nothing more than a transformer, bridge rectifier and a big filter cap), I can follow that up with an adjustable buck converter followed by an ammeter and a voltmeter.

I think that requires further consideration...

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. :)

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

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.


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.

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.

Thursday, July 10, 2014

OpenEVSE II - ground failure testing

Chris H over at the OpenEVSE project brought UL standard 2231 to my attention the other day. What it amounts to is that UL mandates a ground impedance test for EVSEs.

This is kind of a wrench for the Hydra EVSE, since it requires you to intentionally create and then measure a ground "fault." But the Hydra EVSE puts the GFI coil on the AC input so that it can have only one GFI circuit. But if you're going to have a ground test as well, then you either have to siphon off the current for it before the GFI coil, or the GFI is going to see the ground test current as a fault.

The normal architecture of the Hydra is that the AC hot lines go into a distribution bus module where the hot lines are divided to go to each relay. That's the only place where the AC can be broken out. But if you put the GFI coil after that, then you have to try and squish four 10 (or even 8) gauge wires through the coil instead of just two.

The other way to go is to leave the GFI in front and then simply account for the leakage by desensitizing the GFI circuit accordingly. That only works, however, if the leakage is constant - which means that the traditional OpenEVSE relay test system won't work, because the leakage would depend on how many cars were being powered (never mind that the OpenEVSE system doesn't allow for continuous ground testing, which is required by the UL standard).

For OpenEVSE II, I believe I've come up with a workable ground test solution.

The OpenEVSE II HV + Contactor board schematic

The reason the original OpenEVSE solution couldn't test ground impedance continuously was that when both relays were turned on, then a circuit path existed from one hot, through one of the MID400s, to the ground line running between the two MID400s, then through the other one and back to the other hot - there was no requirement for the current to actually flow to ground. You could only make the current flow to ground by lighting up one hot line at a time (which you obviously can't do while charging).

My solution is to use a pair of rectifier diodes to break that cross-conduction path. That done, the test can be run continuously. With a comparator acting as a threshold, the microcontroller should see high logic levels no less frequently than once every 15 ms (3/4 of a cycle at 50 Hz).

The other optoisolator just above the bottom one is acting as an isolated voltmeter. The same voltage divider that supplies the threshold for the comparator is also used to supply a biasing offset for a transimpedance amplifier, which converts the phototransistor's collector current into a 1-5 volt output for an analog pin. The controller will simply look for a peak and scale it. The peak voltage will be 1.414 times higher than the RMS voltage because (unlike the ammeter) we can be sure that the input will be a pure sine wave. Peak reading should allow for the most linear portion of the phototransistor's operating range to be used, which hopefully will yield reasonably accurate results.

Note that the optoisolator in this case is actually an AC input one - there are two LEDs in opposing parallel on the input side. This means that both AC half-cycles will create light.

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.