Power

Power for this project went through a few iterations. 

During development the CRICKIT (and through it, the control board) was powered by a 5V 2A wall wart.

5V 2A (2000mA) switching power supply - UL Listed

PRODUCT ID: 276
This is a FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in...
$7.95
IN STOCK

This worked fine.  When it came time to test it out untethered, a 3xAA battery pack was used. As before, this plugged into the CRICKIT and powered everything. This worked fine until the tail was added. At that point, the first time power was applied to the tail motor, the CircuitPython runtime crashed. In the course of investigating the problem it was found that things worked fine when the controller was connected to USB (for debugging), but crashed as before then battery powered.  It was then that an oscilloscope was used to look at the power signal (sampling it using the ground and 5v connections on the NeoPixel connector).  Here's a trace of the power when no motors are running.

There's a little noise, but it looks random and very low amplitude.  Now look at the same thing with all four servos running at half speed, and the tail wagging.

That's some significant variation of the voltage!  And that's not noise either. The frequent spikes are from the servos. Remember that at half speed we should be seeing a roughly 50% duty cycle wave from the PWMs that drive the servos. This looks about right. The less frequent drops in the signal are when the tail motor was powered. When you see the code you'll see that a burst of power is applied to the tail motor and turned off, allowing the spring to bring it back to center.

This is a problem. Motors don't really care so much about how clean their power is, but microcontrollers do. The noise from the PWMs don't seem to present a problem, but when the the tail motor kicks in that drop is enough to scramble the MCU.

The upshot of this is that the running several motors and the controller on the same power supply, especially if they are batteries, is going to be trouble. However, all of the controller boards we're using can be powered by a LiPo battery. Giving the controller it's own supply alleviates this problem.

The power supply circuit on the micro:bit is minimal and there's not a good way to avoid it being powered from the CRICKIT (through the 3.3v edge connector pad). Fortunately, the micro:bit (or the regulation on the micro:bit CRICKIT) is such that it's proven to be more resistant to the power supply fluctuations and hasn't suffered from being powered from the CRICKIT.

So, that will fix the problem from the fluctuations due to the motors. There's still the SAMD21 that runs the CRICKIT, and there's no way to supply it with a separate battery (or the battery from the controller board). In practice it doesn't seem as sensitive as the controllers. Just keep an eye on the charge on your battery; if it gets too low you'll have problems.  Alkaline AAs seems to be especially prone to causing problems.  Then again, this project runs five motors constantly which is quite demanding.

The final build went with a 6600 mAh LiPo and a 5v boost converter to power the CRICKIT and a 1200mAh LiPo for the controller board. Note that on the Circuit Playground Express CRICKIT, the Vout brass standoff was not used since it is being powered separately.  However the ground connection must be maintained.

 

For safety and easier mounting there are files on Thingiverse for cases for the 6600 mAh LiPo and the boost converter. Using these will avoid any chance of shorts on the bottom of the boost board, as well as protect the LiPo from accidental damage.

 

The LiPo (in its case)  is mounted under the rack, not quite all the way back. It's fairly heavy and having it too far back makes the robot prone to going up on its hind legs.

Cute, but not very effective for moving. The boost converter was mounted on the nose of the bot for east access. The converter case was modified to allow use of a screw-terminal block instead of the USB-A connector. If you are using a AA battery holder, it can be placed under the rack in a similar manner.

There is room between them for the controller's LiPo.

This guide was first published on Sep 25, 2018. It was last updated on Sep 25, 2018. This page (Power) was last updated on Nov 16, 2019.