Tuesday, April 29, 2014

Electronics Arbitrage

Arbitrage is defined as the simultaneous buying and selling of securities, currency, or commodities in different markets or in derivative forms in order to take advantage of differing prices for the same asset.

Case in point: The CUI VSK-S10-12UA-T. DigiKey wants $31.79 for one. And they're backordered anyway. I use them to build Hydras.

But the CUI VSK-S10-12UA is only $20.13.

Check the specs - it's just about exactly the same thing. The only difference is that it's through-hole PCB mount instead of chassis mount. In fact, it wouldn't surprise me greatly if the chassis mount variant didn't simply consist of a plastic chassis mount container holding one of the board mount modules!

Well, how much could it possibly cost to make a board with four holes in the corners?

The answer is $3.40. Well, that's just for the board, and assuming a medium-run order ($1/in²). For the normal order from OSH Park, multiply that by 5/3. Add a power LED and resistor and a couple of screw terminals and it'll be a dollar or so more than that. You could even add the recommended external filter caps and TVS while you're at it and still be certainly spending less than eleven dollars.

This doesn't even break down much over quantities - The chassis mount variant is still almost $10 more when you buy 500 of them at a time - more than $4000!

Now, I'm not sure my little store would be able to beat DigiKey and CUI at their own game - I'm not sure there's quite enough profit or a big enough market for me to sell ersatz VSK-S10-12UA-Ts done this way. But I'm sure going to do it to build Hydras from now on...

Saturday, April 26, 2014

Contactor driver boards now available

For those wanting to build OpenEVSE or Hydras that need to charge at higher than 30A, the lack of 12 VDC coil relays at elevated contact current specs has been a problem. Typically at higher power contactors are the norm (a contactor is just a relay with an AC line-powered coil rather than a low voltage DC coil). In the past, most folks have used pilot relays to drive their contactors, but I've got a better solution.

Schematic of the Contactor Adapter board

It's a simple opto-isolated triac driver. Those of you paying attention may notice startling similarities to the Toast-R-Reflow power board. In fact, it's the exact same thing, but with surface mount components and a much, much less beefy triac.

Instead of being rated for 800 watts per channel with two channels, this board is only rated to switch 100 mA of current, but that's plenty for any reasonable contactor coil. Note that the snubber circuit is a requirement because the contactor coil is a decidedly inductive load. In this case, the snubber cap is rated at 1 kV and the resistor at 1/3W.

The input is designed to accept 12 VDC. The board is a drop-in replacement for a pilot relay, except for one detail - the input is polarized - you need to connect the high side of the relay coil output to the positive input terminal. For OpenEVSE, this is the common terminal of the relay block. For Hydras, it's the "top" terminal (furthest from the pilot block) for each car.

These are available in the store.

Power works in mysterious ways

The GPS reverse geocache boards arrived, and unfortunately will require a revision.

Removing the $30 GPS module to re-use it is the biggest issue, but that's going to be a whole 'nother can of worms.


The system is designed to run off two AA batteries. Measurements of the current draw with the system operating are around 150 mA and with it off the meter shows 1 mA. If you do the math, a 2000 mAh AA battery will be able to supply a milliamp for almost 3 months, or around 10-12 hours of power-on time - that's just fine.

The difficulty is that when I put the board to sleep... it wasn't going all the way to sleep.

To recap, here's the schematic again:

The GPS Pack v1.0 schematic

The controller is directly connected to the LCD data pins. The subtle issue is that the LCD apparently has pull-up resistors on the data lines. That is, a resistor from the data line to power. If you apply a high logic level to the data pin, you're applying power. That power will attempt to flow through the pull-up resistor and power the LCD and the whole rest of the switched circuit!

This also had the distressing side effect of fouling up programming the chip. The programming signals were attempting to "power" the LCD, which was loading them too much. In past projects, I shared programming and LCD data pins, but had never attempted to de-power the LCD, so it worked. Forcing the power pin to on allowed programming this board to work even with the LCD attached.

The fix is two-fold. First, when putting the system to sleep, before turning the power off, you have to set all of the LCD lines manually to low. That will cut off the source of parasitic power. Then switching off the power pin will function as intended. Secondly, unlike past projects, protection resistors will need to be placed between the shared programming pins and the LCD. Hopefully that will be enough to allow programming to work. The only other way to go would be to force the power circuit on when RESET is held low (which it would be during programming). I'm somewhat less satisfied with that, though. I'd rather the protection resistors just do the trick.

Tuesday, April 22, 2014

Another Hydra option

The "3.0" Hydra boards are due from OSHPark shortly. Those boards are the prototype for the "standalone" variant - that is, a straight-up double-head EVSE (trading the inlet handling circuitry for a GFI and an RTC).

I've done some more thinking about other directions to go.

Chris (the guy at the center of OpenEVSE) is planning a variant of the OpenEVSE board designed to work with contactors instead of 12 volt relays. He also has a very nice custom designed chassis for the OpenEVSE v2 board. He has been adamant that the separate i2c backpack display is more flexible  than mounting the display directly on the board. So far, I've done it my way because I've used clear-top cases. That has the advantage of letting you see all the wiring. It also has the disadvantage of, well, showing all of the wiring.

I've sort of had as a point of pride the fact that there are no dangerous voltage levels on the Hydra boards. But if I want, like Chris, to embed contactor drivers on the board, then that's going to have to change.

If I move the display back off the board and re-arrange things, I could make a Hydra board that had an AC input terminal and two contactor terminals segregated in an AC power section of the board. The space given over to the display could instead go to an AC-DC converter to give 3 watts of 5 volt power. A 5v->+/-12 DC-DC module would supply the pilot generator and there would be plenty left for an off-board i2c RGB backpack display and menu/select switch.

I'm not entirely sure I'm going to do this, though. For one, I don't personally have a need for more than 30A of L2, so I don't need contactors (though I know others would). Also, it feels a little like stealing Chris' thunder, though he doesn't currently have a double-headed product. I also have quite a few irons in the fire at the moment, and need to finish some projects before starting on another.

I'd be curious what others think. But then, I'd also love to have lots more people build Hydras.

Sunday, April 13, 2014

GPS reverse geocache backpack design

I've finalized the design of the GPS reverse geocache backpack.

The schematic

The heart of the system is the Adafruit Ultimate GPS module. It requires 3 volt power and logic, so it will have its own 3.3 volt regulator, and the TX serial line will be level shifted with a diode and resistor. In order to insure that the GPS module will warm-start when powered on, the backup pin will be connected directly to the battery pack.

The system is powered by two 1.5 volt alkaline batteries. Whether you go with AA, C or D depends on how long you need the box to be able to operate. The battery input is pushed up to 5 volts by an NCP1402. That 5 volts directly feeds the controller, but is switched by the controller to power both the GPS module and LCD panel (both at the same time - if the display is on, then so is GPS), as well as separately turning power on to the servo output. The battery voltage is also fed to one of the analog pins on the controller so that it can check the battery state. When the battery dips down close to 2 volts, then we'll have to warn the user or perhaps take failsafe action of some sort.

The intent of the design is that the controller will power down the accessories and then put itself to sleep, meaning that the only power drain from the batteries during sleep will be the 5 volt power supply, the backup power for the GPS and the very small power drain of the sleeping controller. The button will interrupt the controller, waking it up. It will then power up and reinitialize the display and GPS. The GPS should be able to warm-start quickly (Adafruit claims it can do so in seconds, provided it hasn't been off too long). The controller will do... whatever the firmware programs it to do with regards to the GPS position and/or time. If it decides to unlock the box, then it will turn the display and GPS off and operate the servo (the 5 volt supply can only give 200 mA, which isn't enough for everything).

All the rest is just deciding what the rules of the game are and providing a UI.

At the moment, what I have in mind is an "open" and "closed" mode. When the box is in the open mode, there's an editor to set the game parameters (GPS location, tolerance and whatever else). There will also be a way to set a "cheat code." If you hold the button down when waking it up, it will prompt for the cheat code, which will immediately open the box and revert to the "opened" mode. This is needed if the batteries get low or something else goes wrong.

As with all the backpacks, it's an 80x36 mm board sandwiched on the back of a 2x16 LCD display module.

Unfortunately, it's going to wind up being a little bit expensive - the GPS module alone is $30, the LCD is $12, the board is $7 and the controller is $3. It's probably going to cost $75 or so when it hits the store.

Checking your work

I thought it was worth blogging about this, because I'm pretty sure it just saved my bacon.

After you've made a few surface-mount board designs, you'll be used to the standard parts outlines. SOIC, SSOP, QFP/TQFP as well, of course, as your size-of-choice for passives (mine is 0805), and a few more.

But there is always a first time that you come across a part that doesn't come in a familiar footprint. Therein lies danger. Or, at least, danger of wasting money.

Case in point:

I've designed a version 3.0 Hydra logic/display board that replaces the inlet processing hardware for pilot and proximity with the OpenEVSE GFI circuit. This way, you'll be able to wire a Hydra directly to a 240 volt socket and use it as a straight-up double-headed EVSE. Doing that was no problem, and there were no surprises on the way. But when I was done, there was a big empty spot on the board, which represented an opportunity to add something on. But what?

Well, OpenEVSE optionally can come with a realtime clock and backup battery, which allows ToU charging. How about that? It requires a single 8-SOIC, a 0.1uF cap, a coin battery clip and a crystal. Where things get interesting is the crystal - it's not available in the same 4 pad 2.5x1.3mm form factor as the 16 MHz crystals I use for "Arduino-izing" ATMega328s, and the collection of possible parts in the various EAGLE libraries I have handy is fairly large.

What to do?

I go with picking the actual part first. I went through DigiKey, looking for SMD crystals with the correct frequency and capacitance and then just picked one based on a combination of price and availability. I chose this one. Now the hard part: I sat on my hands until the part actually arrived in the mail.

Back in Eagle, I laid out the additional parts on the schematic. When it came to the crystal, I took a guess. When I was done, I ripped-up both of the ground planes and then printed out the board, making sure to use a 1:1 scale.

Here's the part sitting on top of the printed board layout

Now, with the PCB effectively simulated in ink and paper, I attempted to actually pick and place the part to make sure the pads were going to line up properly.

Looks good at first blush

In this case, the actual electrical contacts are on the bottom of the part, so looking at it from the top isn't good enough. We have to flip the part over and make sure that it's going to work.

That does look good after all

With the part turned over and pushed slightly upwards, we can see that the pads on the board definitely overlap the pads on the part, and that they don't extend so far that they hit anything that shouldn't be connected (like that little gold dot in the middle). So that layout is going to be just fine.

Note that the coin battery clip is visible in the pictures as well. I had used that part before, but double-checked it anyway. No problems there.

What I left out of that story is that in actual fact, my first guess for the part was wrong. The part was too narrow for the real crystal, and $45 worth of PCB and two weeks of turnaround time would have been wasted (in actual fact, what I likely would have done was just not stuff the clock parts and sold the boards as a variant without the RTC, or hunted through DigiKey looking for a crystal with the correct electrical specs and physical size). Instead, now I can order the boards with confidence that they're not going to give me any surprises.

Tuesday, April 8, 2014

Next: Reverse Geocache backpack

What do you get when you stick an ATMega328, a GPS receiver, a servo control output and a button on a 2x16 LCD backpack with a battery powered step-up power supply?

Stay tuned...

Thursday, April 3, 2014

Apple Magic Trackpad plugger is a go!

I got the Magic Trackpad plugger boards back from OSHPark today. The only minor change required is that it turns out that the entire inside of the battery cavity is not conductive. You have to use a stiff piece of wire and sort of jam it in the threads near the outside edge that would mate with Apple's metal plug in order to make the negative contact. So I will revise the board, moving the negative output terminal into the back corner to make that more convenient. But apart from that, it couldn't have gone better. The boards are the perfect size to center them inside the battery cavity, insuring that the positive connection will work. And the plan at the moment is to wedge a rubber test tube cork into the end of the trackpad to keep it all together. The cork will hold the negative wire in place and provide strain relief on the USB cable.

The boards will go into the store immediately. They come with the surface mount components assembled, as well as the solid core 22 AWG contact wires. You just add the chopped-off USB cable of your choice and the cork. It'll pay for itself easily in less than a year's worth of batteries!

Wednesday, April 2, 2014

Turning the Hydra into a two-head EVSE

It's a subject that has been broached before... What would it take to replace the inlet on a Hydra with just a straight up power cord?

It turns out it's not quite as trivial as it sounds.

The big missing item that would be required is adding a GFI circuit. The Hydra doesn't have one because the host EVSE is assumed to provide one. But having one is required by the spec (as well as being just downright prudent).

OpenEVSE includes a GFi, of course, and stealing their circuit for it would certainly be an option. The hard part is finding room on the board. The v2.2 board isn't very tight in terms of the component density, but that's deceptive - the trace density is rather high.

I could design a board that replaced the inlet management circuitry with a GFI. You certainly don't need both. But then I have two different boards - two entirely separate products, effectively. Given that I've only sold four Hydra boards so far (and two of those went to my employer), is it worth the bother?

I often feel like I'm sort of blogging in a corner by myself, unfortunately.