Lots of Motors
The limits of an Arduino Uno R3
Section titled “The limits of an Arduino Uno R3”If you’re using an Arduino Uno R3 with Bottango, there are some limitations you need to be aware of. (Note, an Arduino Nano is effectively identical to an Uno R3 in terms of Bottango usage. Everything said about an Uno R3 applies to a Nano throughout this documentation)
Let’s compare an Arduino Uno R3 to a modern computer that has, for example, 16 gigabytes of RAM and an 8 core processor running at 2.5 GHz. An Arduino Uno R3 has 2kb RAM and a single core running at 16 MHz.
If it’s not immediately apparent the huge difference in power, the modern computer has 16 MILLION kb RAM compared to the Arduino’s two. And the modern computer’s processor is as much as 125,000% faster than the Arduino’s.
All of this is to set your expectations of just how much a single Arduino Uno R3 can do. Bottango’s code is optimized, but it is fairly intensive in amount of processing compared to the average Arduino program. As such, in this chapter we’ll go over the best practices of getting great performance, and how to get the results you want.
In short, a single Arduino Uno can only control a maximum of 8 servo motors with Bottango, and even less (5) if you’re using a PCA9685 + Uno R3 + Bottango.
Split Your Motors Across Multiple Microcontrollers
Section titled “Split Your Motors Across Multiple Microcontrollers”If you want to stick with an Arduino Uno R3 and you want to control lots of motors, one of the easiest ways to build what you need is to just split the motors across multiple microcontrollers.
Bottango has no problem communicating with multiple Arduinos at once, and in fact is optimized to do just that! If your build can facilitate it, and you want to stick with an Arduino Uno R3, just get one per 8 motors needed.
Switch to a more powerful microcontroller
Section titled “Switch to a more powerful microcontroller”There’s a lot to love about the classic Arduino Uno R3. It has years and years of support and community built around it. But as the years have gone by, there are a lot of newer options with way more capability, often at costs equal to or even lower than an Arduino Uno R3.
For the most basic “level up” from an Arduino Uno R3, you can move to an Arduino Mega. With an Arduino Mega (and all microcontrollers that are not an Arduino Uno R3) you’ll be able to control up to 16 motors on your microcontroller. The driver will detect automatically for you and raise the limit to 16 for you. A mega will start to get a little laggy as you get closer to 16, but it will for the most part keep up.
My go to recommendation for Bottango though is an ESP32 development board. With an ESP32 you can control 16 (or even more!) motors without breaking a sweat. There’s a few extra steps you’ll need to take to get it up and running, but nothing too difficult.
Remember Power
Section titled “Remember Power”Having the hardware to create the signals required to animate a lot of servos is just one part of the problem. You also will need to scale up power. The more you scale up the number of motors in your project, the more difficult it will be to safely power all your servos.
For one hint, when you split servos across multiple microcontrollers, you’re not only making the signal generation easier. If you have a working and safe power circuit for 5 servos, you can “copy paste” and create a second duplicate circuit and additional power supply to power 10 servos split over two matching copies of 5 and 5.
Need more than 16 on one microcontroller?
Section titled “Need more than 16 on one microcontroller?”If you want to go past the maximum 16 motors per microcontroller and are confident your microcontroller can keep up, you certainly can, but you’ll need to make a few changes. In the configuration file of the driver, update the max effectors field.
But proceed only if you understand what you’re doing. There’s not a lot of use cases (but also not zero) where more than 16 on a single microcontroller makes sense versus splitting the work among multiple boards. And just because you update limits from 16 to 160, doesn’t mean your hardware can actually do what you’re asking of it.