Introduction: 16 Channel Servo Tester With Arduino and 3D Printing
Pretty much every project I've done just lately has required me to test out some servos and experiment with their positions before they go into the assembly. I usually make a quick servo tester on a breadboard and use the serial monitor in the arduino IDE to get the servo positions, but this time I decided I'd treat myself and design an enclosed, permanent system to test my servos!
The design can control 16 servos simultaneously, using the Adafruit PCA9685 servo driver board. In order to save space, it only has 4 potentiometers for adjustment and a seperate set of switches are used to select the set of four you'd like to control. One problem I encountered in early prototypes was that the design was pretty hard to solder and then cram into a little box, so this most recent design is printed flat, soldered and folded up, making it super easy to assemble!
I used good quality potentiometers with an M9 mounting hole, but if you'd like to modify the Fusion 360 assembly to fit your requirements, feel free to download the file: https://a360.co/2Q366j4 (or just drill it bigger).
I hope you'll enjoy this quick project, I know I'll get a ton of use out of mine!
NOTE: I'm having trouble uploading the download package to instructables, so if you can't get it here get it from my website.
Supplies
- Arduino Uno: https://amzn.to/2XoMolo
- Adafruit PCA9685 16-Channel Servo Driver: https://amzn.to/2NQeNNT
- 5.5mm DC panel input - https://amzn.to/38Spubt
- 5V Power supply (5A in this case to allow many servos to be driven) - https://amzn.to/34vILMr
- 10K Potentiometer (Note that there's room in the design for different potentiometer types depending on what you have) - https://amzn.to/2sILzs1
- 10K Resistor x 2: https://amzn.to/374seRU
SainSmart 1.8" TFT Color LCD Display Module: https://amzn.to/2r1kcJk
Push-to-make switch: https://amzn.to/38TIwOj
Wire for soldering (single core was useful because of how easily it plugs into the arduino)
Step 1: Printing and Assembly
There's no real requirements for the 3D printing, there's no reason you can't print this with a fairly low resolution. If you've got a big printer it's possible to print the whole thing in one go, but if you've got a more standard printer with a print bed of around 200mm x 200mm, you can print the base in three separate parts. When you have all parts printed, the two halves of the base can be joined with 8 * M2 x 4mm screws.
You can now insert all of the components - potentiometers and switches can be screwed into their panels using the nuts they come with, and the boards can be easily screwed in with M2 x 6mm-10mm screws. It should be clear how the boards go in based on the pattern of the holes. The only component which is a little trickier is the monitor, since that particular model doesn't have a convenient mounting solution. I used some tape to secure it to the panel, but you could use glue or something similar.
Step 2: Wiring
The best approach is to wire each panel as fully as possible, then make all the cross-panel connections as you're closing up the case. I used superglue to hold certain wires in place and neaten the cable management, and you should also use heatshrink tubing where possible to isolate the contacts.
Step 3: Arduino Programming
There were a few quirks with the library that came with the screen, so I'd recommend you install the library included in my download. The programming for this screen is a little more complex than most screens I've experimented with, but overall the programming is still quite simple.
To give you an overview of how the code works, the program starts with a middle value of 350 for all servos, which seems to be a safe bet. It then initialises, filling the whole screen with black to make the background, then writing the names of all the servos ("Servo 3: " etc) and their initial values of 350. The actual looping section of the program firstly checks to see if the buttons have been pressed, and if so moves the arrow and registers the currently selected servo set. It then writes the values of the pulse widths for all four servos in the set based on a mapped reading of the potentiometers, writes these to the screen in yellow, and finally sets the servos to this position through the servo driver board. Any servos not currently being driven will retain their position based on the last input.
11 Comments
2 years ago
Buenas estoy haciendolo, pero la pantalla se que en Blanco, he realizado varias pruebas y en la zona del SETUP en la linea tft.initR(); VEO QUE DEBERIA DE IR ASI. tft.initR(INITR_BLACKTAB); pero en la libreria que has colocado no existe esto pero en la libreria de Adafruit si. me podrias ayudar, muchas gracias.
Reply 2 years ago
Me pasa lo mismo pero solo cuando uso UBS en el arduino. Cuando le pongo 5v lo deja de hacer. Trata lo mismo a ver que pasa.
Question 3 years ago
if I would add a 3rd push button switch to automatically center all four servos. how would I add that to the circuit? and how could I modify the code to make that work properly.
Answer 3 years ago
Look at the circuitry for one of the existing buttons, and then choose a digital port that is not being used.
Add code to check that port and when HIGH set the current 4 servo's to the desired location
I am not at my usual terminal but this is a start.
Reply 3 years ago
Thank you Marcwolf for replying but I actually figured it out already. I started the code from scratch making it control only four servos and Using the two push buttons for controlling centering and looping from 0 degrees to 180 degrees.
3 years ago
Something I would also add would be a function that will send back via serial comms a list of all the servo positions , comma separated, and a line feed at the end.
This can be activated by an additional switch called 'Dump'
This way you could create an entire sequence of movements and possibly play them back.
For real complexity you would then write a utility that you can add a extra column to the servo list which is the millseconds And as the system reads in each line it can check the old and required new position of the servo - and generate a set of micro steps between the two.
Pretty soon you can have a very accurate and powerful servo automation system. Generally it's just getting the servo positions first that is the headache.
If you use something that has a reasonable flash memory (esp32) you can save it all in one system.
Reply 3 years ago
Hi Marc, could you rxplain taht further? I am really interested on implementing that, but I am fumb as duck to figure out what nerd geek thingy that means!
3 years ago on Step 1
Can't think of a reason to test 16 servos at once but I have made a unit with an 8 bit PIC to control 2 to set centres, ramp end to end and a control knob to find that worn-out spot on the feedback pot. All in a box 3" * 2" * 1" including batteries.
Total cost $10, less than the cost of the Arduino!
Reply 3 years ago
Very easily - Try a complex animatronic head and you are recording sequences that you want to replay.
3 years ago
This would be a nice addition to Dilbert’s machine gun drone. It could handle the drone’s flight control plus position the machine gun very precisely. 😳
Question 3 years ago
Could it also test an ESC with a motor? Let's say from a quadcopter.