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 Pololu.com 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
https://www.pololu.com/product/799

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

https://www.dexterindustries.com/ev3-current-consumption-measurement/


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.



https://smile.amazon.com/1byone-Portable-Charger-External-Smartphones/dp/B01BXMZGTS/ref=sr_1_1?ie=UTF8&qid=1485531230&sr=8-1&keywords=usb+battery+pack+display

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.


https://smile.amazon.com/gp/product/B01D9Y6ZFW/ref=oh_aui_detailpage_o00_s02?ie=UTF8&psc=1

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

https://smile.amazon.com/Converter-Conwork-Adapter-Connector-Chargers/dp/B01DRQFCH4/ref=sr_1_1?ie=UTF8&qid=1486761863&sr=8-1&keywords=1.35mm






https://smile.amazon.com/gp/product/B01ID90K4A/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

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

No comments:

Post a Comment