Snekboard

An open-hardware Python microcontroller for LEGO®

Jan 29, 2020

Project update 2 of 11

Powering LEGO motors from a single Lithium Polymer cell

by Keith P

My history with micro electronics started with 5 V devices back in the 70s and, these days, I’m building with either 3.3 V or 1.8 V devices. Inside the chips, voltages can be even lower. That’s great for power consumption as reducing voltage is one of the best ways to reduce power used by digital electronics.

Motors, on the other hand, really want higher voltages. Raise the voltage and you can reduce the current by the same ratio and have the same wattage. Reduce the current, and you can use smaller wires and you lose less power in the form of heat.

Let’s see how Snekboard runs its electronics at 3.3 V while the LEGO motors receive 9 V.

Lithium Polymer Batteries

The Snekboard power supply starts with a single cell lithium polymer battery. This generates between about 3.7 and 4.2 V, and can supply a surprisingly large amount of power. Cellphones usually have just one of these cells too, although generally larger than the one provided with Snekboard. Lithium polymer cells are a popular choice for portable electronics because they hold a lot of energy in a small package, hold their charge for a long time when unplugged, can be recharged hundreds of times and are reasonably inexpensive.

The only trick when dealing with lithium polymer cells is that they need to be carefully monitored while charging. Charge too fast or too much and they’ll get hot, potentially catching on fire (!). Charge them too little and they won’t last as long. With a string of cells connected in series, charging them all at the same time requires a sophisticated "balancing" charge controller. This makes sure that each cell gets fully charged, without over charging any of them.

Snekboard Battery

In other portable projects I’ve worked on, the power supply only needed to provide 3.3 V for the digital circuitry. For these, a single cell lithium polymer battery works great — they put out more than 3.3 V, but not a huge amount more.

I decided to use design for Snekboard, and selected a common size which fit within the footprint of the circuit board, 48 mm × 30 mm × 6.0 mm. This size holds about 900 mAh.

A single cell is very easy to charge — Snekboard uses a Microchip MCP72831 charge management controller. This requires only a couple of external capacitors and a resistor to set the charge current.

3.3 V Regulation

Because the battery voltage is not much more than voltage needed by the electronics on Snekboard (3.3 V), a simple linear regular is sufficient. This converts the excess voltage into heat, but as long as the current draw isn’t too high, it’s not a bad solution. The benefit to a linear regulator is that they’re small, reliable and put out clean power, even in the face of large changes in current draw.

Snekboard uses a ST LD29150 regulator, which can supply up to 1.5 A of current. This is far more than the components on the Snekboard need, which means Snekboard can supply lots of current to devices connected to the GPIO header.

Plenty of 9 V

Generating 9 V is a lot harder, and we need lots of it to drive four LEGO motors. Snekboard includes a Diodes Inc PAM2422 step-up DC-DC converter. This part is rated at 4.5 A and the circuit includes two 470 µF capacitors, a 10 nH inductor and a high current schottky diode.

Keeping The Lights On

When a DC motor is first turned on, it draws a large amount of current to get it turning. When the 9V power supply is asked to suddenly change how much current it’s producing, it places a huge demand on the battery. The battery voltage will drop, and if the current demand is high enough, it may drop below the voltage required to keep the processor running.

I tried solving this with software; ramping the power sent to the motors slowly enough to avoid sudden spikes in power usage. However, getting that working reliably proved difficult as it depended on what kind of motor was attached as well as how much load that motor was under.

Borrowing an idea from another project I’ve been involved in (Altus Metrum’s rocketry avionics), I decided to add a circuit that would monitor the battery voltage. When it drops too low, the 9 V power supply is disabled, reducing the load on the battery. As the battery recovers, the 9 V power supply is re-enabled, and that is configured to slowly increase the voltage to the motors.

You can see that in the circuit below, U13 is a comparator which reduces the battery voltage by 0.88 using a resistor divider and compares that against the output of the 3.3 V regulator. The output of that comparator is connected to the DC-DC converter Enable pin.

Snekboard Regulator (Click to Expand)

In normal usage, you can’t tell that this circuit is limiting how fast motors are turning on. The only way I was able to validate its operation was to connect everything up to an oscilloscope and watch the battery voltage, enable line and motor voltage all at the same time.

Powering from USB or Battery

The final feature we’ll discuss is how Snekboard is able to run off either the built-in lithium polymer battery or directly from USB.

In other designs I’ve worked on, the devices were designed to operate only from the battery, and the battery was expected to always be present. In this mode, power from USB only needs to go into the battery charge circuit. For Snekboard, I wanted it to operate without a battery, and I wanted to be able to draw lots of current from the external power supply. And that meant automatically switching between battery power and external power, depending on which was available.

I tried using two diodes, but the reverse current through the idle diode was enough to feed back from the battery to the input of the battery charger. That caused the battery charge indicators to light up, drawing power even when the device was unplugged and turned off.

So I went and found a fancy TI TPS2121 automatic power selector device. This has the additional advantage of lower voltage drop than the diodes, plus another current limiter, which is a nice backup safety plan.

Snekboard Switch (Click to Expand)

Final Notes

Building the Snekboard power supply was a fun challenge; providing lots of current for 9V motors while keeping the processor running took several iterations. The final design is robust enough to allow users to change motor speed and direction without any concerns about how that might affect the operation of the board.


Sign up to receive future updates for Snekboard.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects