TL; DR
Impatient? Here's the short take.
- Provide suitable power to your servos See Hardware Interface..
- Download and install the Sweeper Library.
- Start with the example sketches provided, experiment and learn. See the video to see them in action.
- Read more when you need to know more.
Hardware Interface
- Servos need independent power! Initially, I used a 6V, 1A wall wart. Ran 6 SG-5010 and 2 SG90 servos simultaneously for a few minutes and the wall wart was just barely warm. I didn't try to find the limits of this setup. It worked for testing. Servos are really happiest (most of them) with 5V, not 6V. So I'm now using a 5V, 2A switching supply. If you use a lot of motors (more than 4 to 6 or so?) you may need a beefier supply. YMMV. If your motors are loaded heavily, obviously you'll need more power. Test your system by running a single motor, then add more one at a time. If the motors stop moving reliably, then you should increase the power available. The worst case is likely to be when several motors all need to move rapidly at the same time.
- I built a simple board to connect power and the control signals. The schematic and a picture of it are attached. (See ServoIntrf.png and ServoInterface.pdf.) Doesn't get much simpler. The two big caps are there to smooth out surges during servo motion. But if you aren't into building hardware, simply search Ebay for "Sensor Shield Digital Analog Module Servo Motor for Arduino UNO R3". The file ServoBoard.jpg shows a picture. For about five bucks with shipping, this is a good way to go.
Installing the Sweeper Library
Sweeper.zip is the zipped Sweeper library. To install library, download the zip, open the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library, and then select the Sweeper zip file that you just downloaded. No need to restart Arduino, the Sweeper Library will now be available. Note that you must also install the Servo library, if it's not already done, to use the Sweeper library. The elapsedMillis library must be installed to run the demos. These can be installed with the Library Manager.
Read more »
Amazing and ambitious projects! I like the idea of using paper structurally to make robot bodies and limbs.
Your approach to servo control is also interesting. Continually sending commands from a central controller is a good way to partition motion control and allow multiple units for motion and sensing. Since I don't plan such a complex control system, I used the interrupt scheme to keep the loop() open for other tasks without impacting timing of the servo actions. I don't like trying to coordinate synchronous actions with asynchronous communications if I can avoid it. Too many "moving parts" makes me crazy! I think the control structures I use could be constructed on the fly from input commands, but I haven't tried that yet.
To deal with the problem of initial position and motion limits, I've written a program that allows one servo at a time to be addressed and exercised. I've considered the idea of putting the results into EEPROM, but so far that hasn't been needed. More future work?