Power to the Robots
It’s well known that robots crave power. In this case, however, we’re talking about electricity rather than world domination (whether your robot craves world domination is between you and the robot, but in any case it’ll need electricity to get anywhere). This post is a quick overview of how I’ve powered my PiWars robots – there may be other options, but this is a set of parts and connections that will definitely work!
Shopping List (for the impatient!)
These are the parts I’ve used, I make no claims that these are the absolute best options but they have been tested and found to be effective in a couple of PiWars robots. You may be able to find better or cheaper options!
- Drone Lab 4S 1500mAh batteries – http://www.radioc.co.uk/DroneLabs-1500mah-4s-50c-100c-Lipo-Battery-p/6510.htm (these appear to have been replaced by a more sophisticated model, but it’s a good brand and I imagine the replacement will be just as capable)
- Battery charger – https://hobbyking.com/en_us/imax-b6ac-v2-professional-balance-charger-discharger.html
- A bunch of XT60 connectors to make up charging cables and your robot’s power input – https://hobbyking.com/en_us/nylon-xt60-connectors-male-female-5-pairs-genuine.html (add some decent capacity wire and heat-shrink sleeving, you should have those anyway for other bits of your robot)
- 20A (allegedly) switchable voltage UBEC – https://hobbyking.com/en_us/yep-20a-hv-2-12s-sbec-w-selectable-voltage-output.html
- Low voltage alarm – https://hobbyking.com/en_us/hobbykingtm-lipoly-low-voltage-alarm-2s-6s.html
- Charging bag – https://hobbyking.com/en_us/lithium-polymer-charge-pack-25x33cm-jumbo-sack.html
- A bag of super-cheap, tiny, voltage monitors – http://www.ebay.co.uk/itm/Mini-2-5V-30V-0-28-Display-LED-Digital-Voltmeter-Voltage-Tester-Meter-Red-uk-/261999557985?var=&hash=item0
If you buy two batteries, and exclude shipping costs, this comes to around £85. It seems like a lot, and it’ll bump the cost of your robot build up considerably, but a lot of that cost is in parts you’ll re-use like the charger and the batteries themselves. You’ll also save yourself a lot of grief – many issues in previous competitions have turned out to be due to insufficient power to the Raspberry Pi, especially when suddenly having to operate in a very noisy environment in terms of RF (we think it pushes up the bluetooth and wifi transmit power to cope!).
Firstly you’ll need a battery. You have a few choices here, and your selection will have a significant effect on everything else so pick carefully!
- Regular alkali batteries. These are non-rechargeable, with a nominal voltage of 1.5v per cell.
- NiMH (Nickle-metal-hydride) batteries. These are rechargeable, and normally used as a like for like replacement for regular AA and similar batteries. Worth noting that they have a lower voltage, at 1.2v per cell.
- LiPo (Lithium Polymer) batteries. Used by drones, these require special charging gear, connectors and handling, but are capable of huge current outputs. Rated at 3.7v per cell and supplied as grouped sets of cells in series.
You can power your robot from any of these options. The first two are the simplest, they use batteries you can buy in your local supermarket and the NiMH cells can be charged using any regular battery charger (typically you can buy the charger and a pack of four AA cells together). The maximum current from both these options, however, is quite low. If you’re running a chassis like the PiBorg one you’ve got four motors that can easily draw a couple of amps each; this will run down packs of AA batteries in short order. It’ll work, but you’ll spend a lot of time charging and the size and weight of the number of batteries needed might be a problem. That said, this is far and away the simplest option!
My robots use LiPo batteries. They’re able to provide a lot of current, have high voltages relative to packs of AA batteries for the same size, and are available in a wide range of physical sizes.
Choosing a LiPo Battery
Having decided to use LiPo batteries, your first problem is selecting one. They’re available in a wide variety of capacities, voltages and physical sizes and some of the terminology around them is a little obscure. Here are three of the ones I’ve used:
They’re all LiPo packs, but they’re not equivalent! The properties you care about are written on the sides, and are:
- Capacity. Measured in milli-Amp hours (mAh) this is a measure of the size of the battery, and is (theoretically) the current that could be supplied by the pack for an hour before the pack is discharged. Larger capacities translate to longer time between charges, and also to physically larger batteries. In the image, the top two batteries both provide the same voltage, but the bigger one will run for considerably longer than the smaller one (2600mAh as opposed to 1500mAh for the DroneLab battery in the middle)
- Voltage. Some batteries may specifically indicate voltage (the DroneLab ones here do at the bottom right of the label), but what you’ll definitely see is an ‘S number’. This is the number of LiPo cells placed in series within the pack. As each cell has a nominal voltage of 3.7v, you’ll get 11.1v from three in series and 14.8v from 4. You can see the bottom battery in the image is rated as ‘3S 11.1V’, and the middle one ‘4S 14.8V’.
- C-rating. This is a unit that makes me wince every time I see it, and if you’ve done any kind of dimensional analysis you’ll see why! The C-rating of a LiPo pack is multiplied by the capacity of the pack in mAh to give the maximum current in mA that can be drawn from the pack. So, for the middle battery in the image above we have a capacity of 1500mAh and a C-rating of 50 to 100, meaning we could draw at least 50 x 1500 = 75000 mA, or 75 Amps from this battery! For a racing drone this number matters, but for almost any realistic PiWars robot you’ll never get close to the maximum discharge rating on any LiPo.
- You might sometimes see a ‘P-rating’. For example, the top battery in the image above is described as ‘4S1P’, meaning one parallel group of four cells in series, It’s unusual to see batteries of this size with anything other than 1P, and it’s often omitted entirely as in the case of the other two batteries shown.
The other important property is how big the battery is! You’re going to have to fit it in your robot, and PiWars robots are not very big. The top battery in the image was used for my PiWars 2 robot, but for the last event I ended up using the much smaller batteries below it – there simply wasn’t any way to fit the bigger pack into the chassis, and the smaller batteries have more than enough power.
When choosing a voltage it’s worth mentioning that motors can typically be supplied with about 20% higher than rated voltage with no issues. So, if you have 12v brushed motors on your robot (a reasonably common choice) you can quite happily run them from a 4S pack at 14.8v, it’s probably better to do that than run them slightly under their rated voltage from the 3S pack at 11.1v. Faster motors are happier motors!
Working with LiPo Batteries
In the list above I mentioned ‘special gear and handling’ required for these batteries. LiPo batteries are great because they have a very high energy density (the amount of energy in a physical volume) and because you can release that energy very quickly (the battery can supply a very high current). The flip side to these benefits is that, if treated badly, these batteries may damage either themselves, your robot, or you! A battery that can supply a 100A current is obviously more dangers to short-circuit than one that can only supply 2A. These batteries get unhappy if you…
- Over-discharge them. They’ll carry on supplying electricity, but they’ll start to swell up, will become impossible to recharge and in extreme cases will heat up to the point they’ll ignite.
- Damage them. That high energy density should only be released in the form of electricity, but if you puncture a LiPo pack you’ll find it’s release rapidly in the form of fire. Be gentle with them!
- Attempt to draw too much current. You won’t do this unless you short-circuit the pack, and you’ll notice immediately if you do that!
This might all sound scary, but really LiPo batteries are easy enough to use and the advantages outweigh the potential downsides. Treat them with a degree of respect and they’re perfectly safe to use.
Safety issues aside, LiPo batteries are both more complex, and more expensive, than other options. Complex because you need a special charger to handle them and because you need to monitor each individual cell (batteries are formed from multiple cells) to prevent over-discharge, and expensive because not only are the batteries themselves relatively expensive, but because you need all this extra stuff! Specifically, you’ll need to get:
- The LiPo itself. In reality, you’ll probably want to buy at least two identical ones so you can charge one while using a second. They charge fairly quickly, but this means you never have to worry about whether your robot is going to have enough juice to do a particular challenge.
- A charger. These are smart devices able to monitor each individual cell within the LiPo via the ‘balance connector’, a set of thin wires coming from the battery which allows the condition of each cell to be checked. The charger will run from either mains voltage or 12v (the latter being used by aircraft enthusiasts to charge batteries from e.g. a car battery in the field), and will be able to charge, safely discharge and balance (the process of reconditioning a battery so all its cells have the same charge).The charger on the left has a direct mains input. You want one like this unless you already have a high current 12v power supply. The smaller one on the right needs a separate power supply, avoid these.
- A charging bag. These are flame-proof bags you can put your LiPo in during the charging process. This is a case of ‘better safe than sorry’, unless your charger or battery are defective in some way you won’t have any problems, but if you did have a fire, well, better to have it enclosed!
- A low battery monitor. This is something you can attach to the battery when its in your robot, and which will scream at you if, or when, you run the battery down enough that further discharge could cause damage.As you can see, it’s compact enough to leave in the robot. This is showing green lights for all four cells in this 4S pack – if any of them drop below 3.3v the red lights will flash and a very loud and annoying noise is produced. That’s your cue to power down the robot and switch batteries!
- Enough connectors to wire the battery up to your robot’s circuitry. LiPo batteries have a range of possible connector types, you’ll need to have the matching connector to whatever battery you use. You may also need to make up an appropriate cable to connect the battery to your charger if not already supplied. Buy a bag of male and female pairs and prepare to do a bit of soldering. The most common connectors are XT30 and XT60 (the XT30 being smaller and rated for less current, but still more than enough for our purposes).
Powering your Robot
Now you’ve got a battery or two and all the bits required to support them, you need to integrate it into your design. There are two things you need to consider here:
- Electrical design. How you’re going to get power from your battery to where it’s needed, given you need to provide both high voltage to your motors and low, regulated, voltage to your electronics.
- Physical design. You’re going to want to swap your batteries out to charge them during the event, and you need to ensure the battery is protected from impacts and other damage while attached to the robot.
To handle the electrical design you need something that can provide a clean, stable, 5v feed from your much higher battery voltage. Because this is powering a Raspberry Pi and any other electronics you’ll have (such as the low power side of motor drivers, all your flashing lights, bluetooth and other radios, HATs on the Pi) it’ll need to be able to deliver a reasonable current. What you need here is a UBEC, or Universal Battery Eliminator Circuit. These are switch-mode power supplies, typically built for drones or RC vehicles to power their electronics, and so are perfect for our purposes. They come in a range of voltages and current capacities – when choosing one you want to be well within the rated current of the UBEC, so while 3A sounds like it should be plenty to power the Pi, it’s really not worth messing around. Go for this one!
This claims to be rated for 20 Amps. I don’t really believe this, but it’s much much higher than we need which means we’ll be working well within its limits. The output voltage is switchable, so select the 5v (really 5.2v when measured, which is fine), connect the heavy wires to your battery with an appropriate connector and the light wires will provide a clean, stable, power supply for all your electronics.
To make your life easier, and diagnose common errors with voltage levels, I recommend picking up a bag of these tiny little voltmeters. They’re self-powered, reasonably accurate, and add more blinking lights to your robot, so it’s really a win all-round. It’s always reassuring to know that voltages are what you think they are!
Your LiPo doesn’t like being dented, and it really doesn’t like being punctured. Keep it happy, and your robot not on fire, by mounting it properly! You’ll also want to be able to swap it out easily during the event so you’re always running with a nicely charged battery, so it needs to be accessible. The one surface of your robot which won’t get hit by anything is the top, so it makes sense to access the battery from above if possible and to protect it from impact and other sources of aggravation from all other sides. This is going to depend on your robot’s chassis; my solutions are shown below:
Viridia’s battery drops into a rectangular hole formed in several laser-cut pieces of acrylic. It’s protected underneath by a solid acrylic plate, and held in place using a couple of hair bands. These put enough pressure on the battery to prevent it being bounced out but not so much they’re actually deforming it. The battery can be removed easily from above without having to undo anything, the discharge and balance connectors are accessible at the top of the pack (you can see the robot end, not connected, of the main battery cable just to the left of the battery in this image).
Triangula’s battery is supported by an acrylic plate below, and pulled into one of the aluminium main struts using a velcro cable tie. This isn’t perfect, as the battery can slide sideways into the backs of the motors, but in reality this never really happened. The cable tie has enough pressure to hold the battery securely, and it’s easy to remove for charging. In both cases the battery is held within the ‘crash structure’ of the robot and protected from external impacts.