Friday, June 02, 2017

12V Cellphone and GPS Socket for 6V Positive Ground Studebaker

The Car

Sam (my Step-Father) has a 1952 Studebaker Champion that he has restored. During one of our too infrequent visits he was showing me his latest work when I noticed a small 12V battery (like you would find in a UPS or alarm system) in the trunk with a cigarette lighter socket attached via a short cable. He explained that the car had a 6V positive ground electrical system and he used the 12V battery to power his GPS when he drives to car events and for charging his cellphone while he is in the car. He said a 12V outlet for the car would be nice and asked if I thought I could build one. Challenge accepted!

Sam's 1952 Studebaker Champion
Design Steps

Initially I used electrical tape to insulate the power socket from the metal dash (which is at +6V) so the body of the socket could be connected to battery negative. This allowed the use of boost converter to generate 12V from the 6V battery.
First attempt insulated the power socket from the 6V positive ground metal dash.
While this worked and was installed in the car for over a year, insulating the outlet was an extra step and failure of the insulation between the socket and the metal dash paneled seemed to be a likely failure point. Before sharing the design I wanted a more robust solution that would be easy to install.

I considered a fully insulated power socket but could not find one that would fit the existing dash opening. I also considered using a plastic bracket to mount the power socket but that would spoil the factory look the dash. Sam was so kind as to offer to use a pigtail socket that he stows under the seat when not needed but I was determined to find a way to use the existing mounting spot in the dash.

The eureka moment came when I wrote out the the system assumptions and requirements and noticed that devices plugged into the power socket make no other connections to the vehicle electrical system. This means that the power socket does not require an absolute voltage output, but actually needs only a 12 volt difference between the power socket center terminal and the body or chassis connected terminal. So if I apply 18V to the center terminal of the power socket, any device plugged into the socket will see 18V - 6V or 12V between the socket's terminals. Sometime just writing a spec can help set the direction for a project!

A search of Pololu's DC-DC Boost Converters found no 18 V boost converters but I did find this beauty. This small module had a 5A input switch and adjustable output (9-30 V) for $17. Notice that the design (U3V50) is offered in several fixed voltages (but not 18V) and two adjustable voltage ranges. Be sure to get the higher (30V) adjustable range, U3V50AHV. Perhaps Pololu will offer an 18V option in the future.

Once I received the module, I added some wires, powered it up and dialed the voltage to 18V. The product page at Pololu has some great information about the module's efficiency. There is even a chart showing efficiency when set for an 18V output with several input voltages.

Looking at the chart we can see that a 5V input provides an 18V output at 1 amp at better than 80% efficiency. So our 6V nominal input should give us even higher output and higher efficiency. I tested the module with a USB car charger and a PortaPow USB Power Meter. The image below shows the unit providing over 10W while charging an iPad.

The module got hot before the current started dropping off as the iPad reached full charge but the module never reached the high-temperature cut-off. The Pololu module is very robust but I would not try to draw more than 1 amp from the 12V power socket. So no high power stereos or ham radio rigs. But you should be able to charge your phone or run your GPS all day long.

The Studebaker's existing lighter socket was power via a switched negative wire with a bullet connector on the socket center terminal and an empty spade terminal on the socket body (our positive chassis 6V power source). To make the installation easier, I added a different color wire to each of our module connections and a matching connector for each terminal. I also insulated the module with clear heat-shrink tubing.

Blue wire to the power socket center terminal (module Vout)
Green wire to the power socket center terminal (module Vin)
Black wire to switched negative terminal (module GND)

Installing the new module was simple, requiring only unplugging the existing wires from the socket and connecting those wires to the module. So we unplugged the wire from the existing socket center bullet terminal and connected this to the module GND wire. Then we connected the body/chassis wire from the power module to the tab on the light socket (electrically connected to the chassis positive ground via the metal dash). Finally the output voltage wire (boosted to 18V) of the power module was connect the lighter socket center terminal.

After inserting the connectors, the wires were bundled and zip-tied to the firewall. The install only took a couple of minutes. The interior appears stock other than a plastic socket cover that indicates that it is actually a 12V outlet.

The voltage of a conventional 12V automotive system actually vary over a wide range. Wikipedia says that "Equipment intended to be powered by the receptacle needs to account for intermittent contact, and voltages outside the nominal 12V DC, such as maximum voltage 9–16V continuously. To function in this environment, 12V automotive accessories are designed to operate over a wide range of input voltages. For example, the Amazon top selling Schoche reVolt dual USB car charger specifies an input voltage range of 10 to 16 volts.

I measured the output voltage under different engine conditions to get a feel for the range produced by the boost converter on the Studebaker. At key on with the engine not running the socket put out 12.75V. The voltage varies once the engine is running though because the generator output varies with engine speed. The voltage varies because the socket output is actually 18V - generator output voltage.  The socket voltage output dipped as low as 11 volts at some engine speeds. The module could be modified to produce a stable voltage difference of 12V but this appears to be unnecessary for the vast majority of applications.


Sam upgraded the install with a matching cigarette lighter plug and socket. He removed the heating coil to keep it from being able to make electrical contact with the power socket voltage.

The new lighter plug gives the dash a factory look while retaining the ability to power modern 12V electrical accessories. 


The module worked with every device tested and has been installed and working in the Studebaker for over four years now. If you want, it is simple to build your own 6V Positive Ground to 12V power socket converter.

1 - Order the Pololu Module (U3V50AHV)
2 - Adjust module to 18V
3 - Add wires, terminals and insulate the module (tape or heat-shrink)
4 - Install and enjoy!

I was pleased with the look and performance of the project. I hope this approach can help you solve your own power system design problems!

Wednesday, February 22, 2017

Creating a Stencil from a Bitmap Image

I began searching online for a Minecraft stencil when my son (5th grade) had a school assignment to find a way to earn money to donate to the Make a Wish Foundation. He wanted to use bleach to stencil tee-shirts with MineCraft artwork to sell to his friends at school. We supported his efforts and purchased a small supply of shirts from the local variety store (Dollar Tree).

We first tried cutting stencils using Freezer Paper and ironing that onto the shirt. It worked for some shirts but the bleach had little impact on some colors. So back to the craft store for some fabric spray paint. The freezer paper stencils did not hold up well when the kids used the shirt spray paint. The stencil wanted to peel off of the shirt. We discussed coming up with a reusable stencil that would give us more detail and hold up better. 

This seemed like a great job for the laser cutter but I was not sure how to make a stencil. It took an an entire evening of working with a drawing program but I finally figured out a process that seems to work. Here are the steps I followed.

First, find a bitmap of the Minecraft item that you like. I used a Google Image search to find the image below. 

Here is how that image appears in CorelDraw. I will leave all of objects selected to make it more clear when we shift between a bitmap and objects. 

Next use your favorite drawing program to auto-trace the image. For CorelDraw you can get good results using Trace: Outline for High Quality Image. Move the Detail slider all the way to the right to ensure you get all of the squares. Smoothing did not seem to matter and I used 0 (slider all the way to the left) for Corner Smoothness. If the tracing went well you will get a group of objects that looks similar to the original image. Note the new selection handles for the newly created objects.

Next select all of the traced objects and apply a black fill.

Now change the Outline to 8.0 pt, solid line, in white.

This looks like a stencil and can be used if you want to print it and cut by hand. I read that you can get great results if you print on card-stock and laminate the card-stock before cutting the pattern out with an Xacto knife. But I want to use a laser cutter so there are still a few steps left. 

The laser cutter wants lines showing where the beam should cut. So we want lines that define the outline of the black boxes in the image above. But those black boxes are actually the fill inside the boxes defined by the 8.0 pt white rectangles. So we need to convert the fill of each square into it's own object without the white outline. 

I suspect there are easier ways to convert the black fill to objects but I did it by converting the objects to a bitmap (150 dpi, Black and White, 1-bit) and then tracing the new bitmap. Below is the bitmap produced when you convert the objects to bitmap. 

Next we Trace Outline for High Quality Art.  Set the Detail slider full right, and both Smoothing and Corner smoothness full left. You should get a group of objects like shown below. Again notice the selection handles for the new objects created by tracing.

Finally, we select all of the objects and set the Outline to Hairline, solid black line, set the fill to none and adjust the size to match the desired stencil size. You are limited only by the cutting bed size of your laser cutter. Here is the pickaxe on a letter size sheet. 

Finally save in the preferred file format for your laser cutter, I used DXF, and you should be ready to cut the stencil on your laser cutter.

The laser will cut along the lines, giving you a stencil. I ended up using thin plastic sheet that worked well. Below are some photos of the stencils and shirts the kids make using them. The green images are fabric paint. The lighter images were made applying bleach to black fabric.

We were pleased with the results. I hope this workflow can help you create your own stencils!

Sunday, February 12, 2017

Charging LEGO EV3 and NXT FLL Robots with a USB Cable

Diagnosing the performance of a robot when programming missions for a FIRST LEGO League challenge is always interesting. You think about tire slippage, did the robot move too far before a turn or should it turn a little more? Another variable that can come into play is the charge level on your robot's battery.

A robot's performance is most consistent when operated from the same battery charge level each run. Some recommend using batteries  at 80% charge for the ultimate uniformity but this seems to difficult to achieve in regular use. The lowest effort way to ensure consistent state of charge for a robot battery is to always keep them charged. But swapping batteries or getting a robot back to an AC charger between FLL rounds is not always convenient. I wanted an easy way to charge a robot between rounds and came up with this USB charging cable that I will show you how to build. Spoiler alert, there is a surprise ending.

Charging LEGO Batteries

All LEGO robot batteries have internal charge circuits that control the charging current and voltage. The external power adapter only supplies power to the charging circuit inside the battery pack. The official LEGO charger is listed on their website as a 9V charger but is actually labeled as having a 10V output with a capacity of 700 mA.  The LEGO batteries I tested appear to draw around 600 mA during charging when powered from a 10V source. I suspect the 1V higher output voltage and 100mA higher output capacity on the charger are engineering margins select by LEGO to ensure the batteries and chargers work even under worst case conditions.

So we should shoot for providing 10V and should be able to supply around 700 mA. We can also calculate that the 600 mA current observed during charging we should be able to return about 600 mAh back to the robot in the one hour between rounds. And I would like to be able to power the charger using a USB battery pack.

Designing the Charger

So I need to find a way to convert a 5V from a USB battery pack to 10V for the LEGO battery pack. My go to source for prototyping with DC-DC converts is and their model #799 Adjustable Boost Regulator seems like a good match and is only $12. There is another Pololu boost converter, the U3V12F9 that is cheaper, only $4 but leaves little performance margin. I will pay a little extra for some extra operating margin since this is a prototype. You should always prototype first for function and optimize later after validating your operating envelope. For comparison, the 799 has a 2 amp input switch rather than the cheaper unit's 1.4 amp input switch. 
Pololu Pololu Adjustable Boost Regulator 4-25V

The 799 needs a minimum input voltage of only 1.5V and has an output that can be adjusted from 4V to 25V. The device has a 2A input switch (which means it can only draw in 2 amps of current and your output current capacity will drop the more you boost the output voltage). The performance chart below has a line for a 5V input and 12V output that indicates a peak output of around 700 mA (the green line). We will be boosting to only 10V so we will have an even higher current limit. 

Looking at the chart, we can see the efficiency improves as the input voltage gets closer to the output voltage. For a boost from 5V to 10V we can estimate an efficiency of 85% and an estimated output current of (5V/10V) * 0.85 or 850 mA. We only need 600 mA or so giving us a nice engineering margin. 

So now I only need the small DC jack that plugs into the battery pack and a USB cable that I can use to splice everything together. I grabbed one of the micro USB cables that seems to come with everything these days and used my digital calipers to measure the LEGO battery pack power jack. It turns out the DC adapter is a 1.35 x 3.5 mm plug. Below is the link for the part at Digikey, my favorite source for parts due to their great online search engine and amazing shipping speed. 

The Build

Incoming +5V from USB on right, 10V leaving to the charge plug on the left. Note that the wires were doubled up going to the connector on the battery pack end. The wires were already there, might as well use them. 

Battery connector soldered up ready for finishing. 
After adjusting the output voltage and verify everything worked, I applied epoxy to the terminals before adding the terminal cover. The epoxy helps spread the cable stress to prevent cracking the solder joint. I learned to use epoxy via multiple repairs of laptop power cords over the years. With epoxy it is a one time job rather than every 18 months. 

The adapter draws 1.41 amps when charging the LEGO EV3 battery pack. 
I used a PortaPow USB Power Monitor to measure the current draw when charging a LEGO EV3 battery pack. Note that the current draw of 1.41 amps is under 1,500 mA which is the minimum current spec for a port meeting the USB dedicated charger port (DCP). Most tablet USB chargers can provide the current needed to power this charger.

Measurements taken when charging the same battery pack at the same state of charge compared to the power draw from a bench top power supply indicate that the Pololu 799 boost-converter was around 84% efficient when charging the battery pack at 600 mA. This number is very close to our earlier estimated 85% efficient from the performance chart.

I added black hot melt glue to insulate and provide strain relief for the module.

After adding black hot melt glue to the other side.

After trimming one side. 

I applied big globs of black hot-melt glue to the final assembly (after calibration and testing) to protect the electronics and provide strain-relief for the cables. I use a silicon mat under the device when applying the hot-glue and fold the mat over and press down on the just applied glue to get it to flatten out. I had a nice thick barrier after a few turns of applying to one side then the other. I trimmed the edge of the glue with a small hand-plane to flatten them. I did not get a photo of the module after trimming the second side. It was still not a work of art but it was well protected by the hot melt glue. 

Other options include covering with Sugru or epoxy or even some adhesive lined heat-shrink tubing. But you do need to protect the electronics and keep the cables from applying stress to the solder joints. 

How Battery Capacity is Measured

The battery capacities mentioned here are milliamp hours (mAh). Generally a mAh rating tells you how much energy that battery can deliver to a load. So a 1400 mAh battery could deliver a current of around 140 milliamps for around 10 hours. The usable amount of charge in battery drops when you discharge them a higher currents do to internal losses. For example, the same 1400 mAh battery providing 1.4 amps (1400 milliamps) to a load would be expected to last less than an hour, probably less than 30 minutes.

LEGO has two different battery chargers for use with NXT batteries. The older gray batteries (1400 mAh) use a charger with a larger tip that outputs 10V AC, while the newer white batteries (2100 mAh) use a smaller tip that outputs 10V DC. The EV3 uses a new battery (2050 mAh) that is compatible with the LEGO charger with the small tip and DC output. I am going to show you how to build a charge cable that will let you use a high-current (at least 1.4 amp capable) USB port to charge your LEGO battery that accepts a DC input.

Why would a USB charger cable be useful for a LEGO robot? A battery's output voltage dips when load draw current. The larger the load the greater the current drop (measuring the drop in terminal voltage can even be used to measure the load). The drop in voltage gets greater as the battery capacity drops during discharge and can cause undesirable robot behavior.

You can start seeing odd behavior,when the battery is at a low state of charge and motor loads are applied. One reason is that motors typically have a moment of high current (and large voltage drop) right before the start to move. Under the right conditions, high load and battery that has only 1/3 of a charge left, the voltage can drop enough to change the motor's strength and response time. In some systems the voltage drop can also cause problems with the robot's controller and sensors. So anytime you see new problems or something that was working starts not working you should ask yourself if you are seeing performance issues due to low battery.

This high current condition is described as the motor's Locked Rotor Current (because the rotating parts of the motor have not started turning). A general rule of thumb is that a motor's locked rotor current will be about 5 times its normal running current. The chart below has data for EV3 motors and shows that the Locked current for the motors is around 5 times the free run motor current.

EV3 Motor and Sensor Power consumption

The chart above helps us figure out if charging between rounds would be enough to top off the robot's battery. First we need to calculate a worst case value for the power consumed during a round. Looking at the chart, a fully charged battery would be around 8.2 volts so we will use the 8.2V column of data. We can round the 1 Motor, 100%, Locked current from 0.955 amp up to 1 amp. Since the EV3 has 4 motor ports, we multiply that current by 4 to get a maximum of 4 amps. The table lists a running EV3 with sensors as drawing 0.123 amps. Let's round that up to 0.2 amps. So we have a total worst case current draw of 4.2 amps during a match.

An FLL performance run last 2.5 minutes, which is about 0.042 of an hour (2.5/60). So the energy used during the match is (2.5/60) hrs * 4.2 amps or around 0.176 amp hours or 176 milliamp hours (mAh). So to fully charge the battery we would need to be able to return 176 mAh of charge to the battery in the roughly one hour between rounds.

The battery charges at around 600 mA and even subtracting our worst case 200 mA for power the EV3 between rounds, we should be able to charge the battery at 400mA. If you can charge the robot for 50 minutes, in theory you could return (50/60)  * 400mA or 333 mAh which is close to twice our worst case drain of 176 mAh. So we should have plenty of time to top off the battery.

Note that you will likely operate your robot at less than 100% charge because charging slows as the battery approaches full charged. But you will be operating in the upper ranges of the battery state of charge and should start each match at similar conditions.

Usage Notes

It has been handy to charge the robot from a USB port. I expect the actual impact on the robot's FLL performance is minimal. I expect you would get more benefit from cleaning the robots tires. It is also easy to toss the USB charging cable in the box with the robot and always have it. I never kept a charger in the box before. Once I did charge the robot battery from a USB battery pack while the robot was boxed up in my trunk as we drove to a scrimmage. Early the morning of the event I realized that we forgot to plug up the robot after our previous practice.

Often we use a USB battery pack with a display that shows the amount of charge on the battery (similar to below). Note you need to be sure to use only the 2 amp port with the USB charger adapter. The display let us measure how much charge the battery needed before reaching full. This raises another issue though.

The problem with amp hours as a measure of battery capacity is that it neglects the battery voltage. The battery pack above lists a capacity of 6,000 mAh so you would think it could charge an EV3 battery pack (2050 mAr) around 3 times on a single charge. But the USB battery pack probably has a single 3.7V battery where the EV3 battery pack has two 3.7V batteries.

In reality the battery pack has a 3000 mAh capacity at the same voltage as the battery pack. And the battery back is stepping the 3.7V internal battery up to 5V, our USB cable is stepping the 5V up to 10V and then the battery pack is stepping the 10V back down to the battery's charge voltage. In reality we could expect this pack to provide a little more that one full charge for a fully discharged EV3 battery pack, But using our very conservative estimate of charge used during a performance run, the pack could keep the EV3 battery pack fully charged through at least 4 performance runs (2050 mAh / 420 mAh).

This is the reason that most larger battery packs are quoted in Watt Hours (or at least list the Watt Hours). Watt hours is just the amp hour rating multiplied by the voltage. So the 3.7V battery with 6000 mAh  capacity is 22.2 Watt hours. And our 7.4V (nominal) EV3 battery pack is 15.2 Watt hours. Watt hours lets you accurately compare the energy storage capacity of battery packs with different voltages.

Here is a nifty little tool that will let you measure the amount of energy put into the charging system. This is useful information with two caveats. First, the Amp-hours reported will be larger than the actual battery capacity due to the power loss in the USB-Boost conversion and in the charging circuit inside the LEGO battery pack. Second, the only time the battery needs a full charge, allowing you to get a measure of the actual capacity, is when the battery is fully discharged before you charge it. But if you use your battery down to when you start seeing issues with your robot, you can get a feel for the usable capacity of the battery. And you have a great way to compare two batteries when  you are concerned that one might have an issue.

Or Just Order One From Amazon for $12!

I contemplated ways to make it easier to build the chargers and started searching for USB voltage boost converters and cables with the correct plug. Eventually I found the item below at Amazon. For $12 you get a USB to power jack boost converter. Mine even came with an adapter that fit the LEGO battery pack. There are 9V and 12V version of the cable and both appeared to work equally well for charging the LEGO EV3 and NXT white battery packs. You can order extra 1.35mm power jack adapters just in case your converter does not include an one (or if you want to have a spare incase you lose one).

I hope you find a USB charger a useful accessory to help keep your LEGO robot charged and ready for action!