Introduction: Robot Arm Controller
Robotic arms are cool - I especially love the EEZYbotARM by theGHIZmo. I printed the parts early last year, but didn't get around to assembling it until last month. I designed my own Arduino-based controller for it and decided to share it here. While I am using it with the EEZYbotARM, it should be suitable for any 4-servo robot arm.
It has the following features:
- Joystick-based control of arm motion.
- Control of base rotation with a rotary potentiometer.
- Gripper control via two buttons (open/close).
- IR remote control capability (optional).
- Can memorize up to 1000 patterns, either by recording the motion or manually coding/editing a file on an SD card.
- Full 3D printed enclosure.
Step 1: Parts and Tools
Aside from a completed 4-servo robotic arm, the following parts are needed:
- Stripboard - The board that I used contains a mix of horizontal and vertical strips. It can be found on eBay if you search for "8.5 x 20 stripboard".
- 4x 5mm M2 standoffs
- 4x M2 nuts
- 4x M2 short (<5mm) screws
- 2x 5mm M3 standoffs
- 2x M3 nuts
- 2x short (<5mm) M3 screws
- 4x M3 x 15mm screws
- 4x M3 threaded female inserts (example here)
- 4x 12mm tactile buttons (available from SparkFun COM-10302 or eBay)
- Thumb joystick and breakout board from SparkFun (COM-09032 and BOB-09110)
- 5K panel-mount linear potentiometer
- Arduino Pro Mini 5V from SparkFun (DEV-11113) plus male headers
- FTDI USB Serial Adapter for programming the Arduino
- TM1637 4 digit LED display (eBay)
- SparkFun Level Shifting microSD Breakout (DEV-13743)
- right angle male headers (strip of 12)
- one 5mm LED
- one 330 ohm resistor
- one 2.1mm circuit board mount barrel power jack (female)
- one IR Receiver Diode - TSOP38238 (optional) plus IR controller (I used the Infrared Remote Control from SparkFun - COM-11759 or available as part of an IR kit they sell)
- 22 gauge hookup wire, assorted colors
- 5V 1A power adapter
- A micro SD card
Tools that you will need:
- A soldering iron
- A multimeter to test the circuit and check for continuity between connections
- Wire cutters
- A solderless breadboard for testing (optional)
- A 3D printer for the enclosure
- A patient and enterprising mind to troubleshoot any connection issues
Step 2: Circuit Board Assembly
Hookup of the circuit really involves nothing more than connecting the various pieces to the correct Arduino pins. I suggest hooking everything up on a breadboard first to test it all out. IMPORTANT - see notes below on how to attach wires and headers to the Arduino Mini.
The Arduino connections are as follows:
- D2 - joystick select button
- D3 - IR diode
- D4 - rotating base servo
- D5 - claw servo
- D6 - vertical arm motion servo
- D7 - horizontal arm motion servo
- D8 - LCD CLK
- D9 - LCD DIO
- D10 - SD card CS
- D11 - SD card MOSI
- D12 - SD card MISO
- D13 - SD card CK
- A0 - record button
- A1 - playback button
- A2 - unused
- A3 - potentiometer
- A4 - close claw button
- A5 - open claw button
- A6 - joystick vertical
- A7 - joystick horizontal
The 5V in is connected to the Arduino RAW input, as well as the positive pin on each servo. All other components have their positive and negative leads connected to VCC and GND on the Arduino.
I've included photos of the front and back of the assembled board, plus Fritzing diagrams. In one Fritzing diagram, I've removed most of the components so you can better see the arrangement of hookup wires. Note that on the actual circuit, wires run UNDER the LED, joystick breakout, and SD card breakout.
Suggested Assembly Sequence
- Cut the circuit board to size, along the 41st row from the bottom.
- Drill the holes as indicated on the Fritzing diagrams. 6 holes just big enough for the M3 screws, and 4 for the M2 screws. Note that all of the holes are right on existing circuit board holes, so it is easy to get them in exactly the right positions.
- Make the three copper trace cuts as shown on the Fritzing diagram.
- First solder in all of the red (positive) and black (negative) hookup wire connections as shown. IMPORTANT: The components and wires are placed on the non-copper side of the stripboard. The copper traces shown on the diagrams are what you would see if you could "look through" the board. Use a multimeter with a continuity tester to make sure that there are not shorts between the positive and negative connections.
- Solder on the four buttons.
- Attach the four M2 standoffs that will hold the LED module, and the two M3 standoffs for the right side of the joystick breakout. NOTE: the nut on the backside of these may cause a short between copper traces. Check this with your multimeter and scrape away any copper as needed to eliminate the shorts.
- Solder male headers onto the Arduino Mini, but on the left side, do not include headers for RST, RX1, and TX0. This space is needed to run wires under the Mini.
- Solder wires on to the A4, A5, A6, and A7 connections in the center portion of the Arduino. These wires should come from the bottom side of the Mini. (The Fritzing diagram shows them on the top, but that is just to show placement.)
- Solder female (or male, depending on the type of FTDI board you have) programming headers onto the Arduino Mini.
- Optional, but a good idea: Insert the Arduino Mini into a breadboard and test it. I tested each pin with the Blink program to make sure that they were all connected and that I had no inadvertent solder bridges.
- Solder the Arduino Mini onto the circuit board. Note that you will need to carefully cut the wires from A4 - A7 to the correct length and get them in place at the same time.
- Solder in the connecting wires for the joystick, potentiometer, 4 digit LED module, servos, and top two buttons. Keep these as flat to the board as possible. These all run under one or more components. Note: On the Fritzing diagram, I erroneously show the joystick center connection (white wire) going directly to the Arduino Mini A3 pin. It should go to the connecting copper trace on the stripboard next to the pin.
- If you have not already done so, solder male header pins onto the joystick and SD card breakout boards. Then solder these in place on the stripboard.
- The 4-digit LED module is a little funny, in that it comes with male header pins facing up. Carefully bend these down at right angles, facing the right. Attach the module to the stripboard with four M2 screws. Now use four very short wire connections to solder the male header pins into the stripboard. See the photo of the circuit.
- Solder on the remaining components (power jack, power LED, IR diode, servo headers, potentiometer) and remaining wires. Note the position of the potentiometer and the length of its wire connections in the photo. It is not mounted on the board, but the wire lengths need to be correct for it to mount in the 3D printed enclosure.
Step 3: Programming
Here is the Arduino program code I used. I won't say it is perfect, but it functions well for me. I'm sure there are plenty of modifications and improvements that can be made. That's why I designed the enclosure to keep the programming headers exposed :)
Note that you may need to search the web and download a few Arduino libraries.
Step 4: Enclosure
The enclosure consists of two 3D printed parts (front and back) held together and to the board with four M3 15mm bolts. I printed the two halves in PLA with a 0.2mm layer height and 20% fill. Before slicing, flip the front piece so that the concave (inside of enclosure) side is facing up, and the front/exterior is on the build plate.
After the back half is printed, melt in the threaded female inserts with a soldering iron from the exterior side of the piece. Note that you may need to enlarge the holes slightly first. Don't melt them all the way through, as you don't want them to short any of the traces.
I've included both STL files, as well as the OpenSCAD design files in case you want to do modifications.
Step 5: Using the Controller
Attach the servos to the male right angle headers, from top to bottom:
- One of the arm control servos (your choice on which one)
- The other arm control servo
- The claw servo
- The base servo
To control the arm:
- Use the joystick (up and down or side to side) to control the arm motion.
- Use the potentiometer to turn the base.
- Use the buttons on the lower left to open/close the claw.
- Press the joystick ("select") to quickly open the claw.
To use the IR remote:
- Arrows control the arm servos.
- Use power, B, and circle/select buttons to open/close the claw.
- Use the A and C buttons to rotate the base.
To record and playback motions:
- Press the upper right button (red) to start a recording. The LED reading will show a lower case "r" (record) followed by a 3 digit number, which is the name/number of the sequence of events you will be recording.
- Execute the movements to record. Only direct controls are recorded, not motion from the IR remote.
- Press the red button a second time to end the recording.
- To play back a program, press the left button from the upper pair (yellow). The LEDs with show "C" (choose) plus a number. Move the joystick up or down to select the name/number of the recorded sequence that you want to play back. Press the yellow button a second time to run the sequence.
All of the "programs" are recorded on the Micro SD card as csv files. Each line of a file indicates the time at which to execute the movement (in milliseconds from the program start), a letter code to indicate which servo (H, V for the arm servos, C for the claw, and B for the base), and the servo position. Thus you can edit recorded programs, or even manually code your own.
Step 6: Enhancement Ideas/suggestions
- In hindsight, rather than putting the male right angle headers on the board for the servo connections, I might've put on a female RJ45 connector, then made a small board to interface the other end of a cat 5 cable to the servos. This would've allowed me to easily have more wire length between the control box and the arm.
- With a little work, you could alter the Arduino sketch provided to respond to any remote that you have handy.
- You can tweak parameters in the program to make the arm control finer/slower, or courser/faster. Or even make the response form the joystick non-linear.
We have a be nice policy.
Please be positive and constructive.