A robotic arm is a form of a mechanical arm that is typically programmable and may be used in a variety of industrial settings to pick up and move different objects from one location to another. It might be the entirety of the mechanism or a component of a more sophisticated robot. Through articulated joints that provide rotational movement, the components of these manipulators or arms are joined together.
I decided to offer my custom Arduino-based controller that I created for it. Although I use it with the EEZYbotARM, it ought to work with any 4-servo robot arm.
It has the following features:
- Arm motion can be controlled using a joystick.
- Rotating potentiometer is used to control the rotation of the base.
- Two open/close buttons are used to control the gripper.
- IR remote control capability (optional).
- Can memorize up to 1000 patterns, either by manually coding or changing a file on an SD card or by recording the motion.
- Full 3D printed enclosure.
Step 1: Parts Required
- 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
The only thing that needs to be done to complete the circuit’s hookup is to connect all of the components to the appropriate Arduino pins. I advise testing things out by first connecting everything to a breadboard. Important: For instructions on connecting cables and headers to the Arduino Mini, read the notes below.
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
Both the positive pin on each servo and the Arduino RAW input are linked to the 5V in. The Arduino’s VCC and GND pins are connected to the positive and negative leads of all other components, respectively.
Along with Fritzing diagrams, I also supplied pictures of the front and back of the constructed circuit board. I’ve taken off the majority of the components from one Fritzing schematic so you can see how the connecting wires are arranged better. It should be noted that wires really run UNDER the LED, joystick breakout, and SD card breakout on the circuit.
Suggested Assembly Sequence
- Cut the circuit board to size, along the 41st row from the bottom.
- Along the 41st row from the bottom, trim the circuit board to size.
- Drill the holes according to the Fritzing diagrams’ instructions. There are 4 M2 screws and 6 M3 screw-sized holes, respectively. It should be noted that every hole aligns perfectly with an existing circuit board hole, making it simple to place them precisely where they need to be.
- As per the Fritzing graphic, cut the three copper trace segments.
- The connections for the red (positive) and black (negative) hookup wires must first be soldered in place as indicated. Important: The wires and components should be attached to the stripboard’s non-copper side. If you could “see through” the board, you would see the copper traces depicted on the diagrams. To check sure there are no shorts between the positive and negative connections, use a multimeter with a continuity tester.
- Solder on the four buttons.
- Attach the two M3 standoffs for the right side of the joystick breakout and the four M2 standoffs that will support the LED module. NOTE: A short between copper traces may result from the nut on the back of them. Use your multimeter to check this, and remove any copper as necessary to close any shorts.
- Male headers should be soldered to the Arduino Mini, but the headers for RST, RX1, and TX0 should not be present on the left side. To run wiring underneath the Mini, you need this area.
- Connect wires to the Arduino’s A4, A5, A6, and A7 connectors using solder. These wires should enter the Mini from the bottom side. (The Fritzing figure places them on top, although it is merely for illustration purposes.)
- Programming headers for the Arduino Mini should be soldered to it, either female (or male, depending on the sort of FTDI board you have).
- Testing the Arduino Mini by mounting it on a breadboard is optional but recommended. Using the Blink application, I checked each pin’s connectivity and the absence of any accidental solder bridges.
- Attach the Arduino Mini to the circuit board using solder. Keep in mind that you must carefully trim the wires from A4 to A7 to the proper length and install them all at once.
- Connecting wires for the joystick, potentiometer, 4-digit LED module, servos, and top two buttons should all be soldered in place. Keep these as flat as you can to the board. All of these are operated by one or more components. Note: I incorrectly depict the joystick centre connection (white wire) as going straight to the Arduino Mini A3 pin in the Fritzing diagram. It should connect to the copper trace that runs alongside the pin on the stripboard.
- Solder male header pins to the joystick and SD card breakout boards, if you haven’t previously. After that, solder these to the stripboard.
- The male header pins on the 4-digit LED module are pointing up when it is received, which is a little amusing. Faced to the right, carefully bend these down at a right angle. Four M2 screws should be used to secure the module to the stripboard. The male header pins should now be soldered onto the stripboard using four extremely short wire connections. Check out the circuit photo.
- All remaining wires and parts (power jack, power LED, IR diode, servo headers, potentiometer) must be soldered in place. In the image, pay attention to the potentiometer’s location and the size of its wire connections. The wire lengths must be accurate for it to mount in the 3D-printed enclosure even though it is not mounted on the board.
Step 3: Programming
Here is the code I used for my Arduino program. Although I won’t say it is flawless, it works great for me. There may undoubtedly be many adjustments and enhancements performed. I created the enclosure with the programming headers exposed because of this.
Step 4: Enclosure
Four M3 15mm bolts hold the enclosure’s two 3D-printed front and back halves together as well as the board. I used PLA and printed the two parts at a layer height of 0.2mm with a 20% fill. Flip the front piece over so that the front/exterior is on the build plate and the concave (inside of enclosure) side is facing up before cutting.
After the back half has been printed, use a soldering iron from the piece’s outer side to melt in the threaded female inserts. Keep in mind that you might need to slightly widen the holes first. You don’t want them to short any of the traces, so don’t melt them completely.
In case you want to make changes, I’ve supplied both STL files and the OpenSCAD design files.
Step 5: Using the Controller
From top to bottom, attach the servos to the male right-angle headers as follows:
- One of the arm control servos (your choice on which one)
- The other arms 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 capture and replay motions:
- To begin a recording, press the red button in the upper right corner. The name or number of the series of events you will be recording will appear as a lowercase “r” (record) followed by a three-digit number on the LED readout.
- Carry out the actions to document. Motion from the IR remote is not captured; only direct controls are.
- To stop the recording, press the red button one more.
- Press the left button from the upper pair to play back a program (yellow). The LEDs display “C” (choice) together with a numeric value. To choose the name or number of the recorded sequence you want to playback, move the joystick up or down. To start the process, press the yellow button a second time.
The Micro SD card stores all of the “programs” as csv files. Servo position, a letter code to identify the servo (H, V for the arm servos, C for the claw, and B for the base), and the time in milliseconds from the program start are all indicated on each line of a file. In this way, you can edit pre-written programs or even write your own from scratch.
Step 6: Enhancement Ideas/suggestions
Looking back, I should have constructed a little board to link the other end of a cat 5 cable to the servos instead of using male right-angle headers for the servo connections and instead used a female RJ45 connector. I could have easily had a long wire between the control box and the arm if this had been possible.
You may modify the included Arduino sketch to respond to any available remote control with a small bit of work.
The program’s parameters can be changed to make the arms control more precise/slower or more coarse/faster. Alternatively, you might make the joystick’s reaction non-linear.
Step 7: Circuit Diagram
Three typical PWM servos are used in the robot arm, and a variable resistor regulates each angle. The 10k ohm B curve rotary potentiometer was utilised.
Arduino Code
With this simple code, the rotary potentiometer’s value is read from an analog pin, converted to an angle, and then supplied to the matching servo.
#include <Servo.h> Servo myservo1, myservo2, myservo3; float th1=90.0,th2=90.0,th3=90.0; float val1, val2, val3; void setup() { Serial.begin(9600); myservo1.attach(9, 500, 2420); //MG995 myservo2.attach(10, 820, 2140); //DS3115 myservo3.attach(11, 820, 2140); //DS3115 set_servo(); } void loop() { val1 = analogRead(A1); val2 = analogRead(A2); val3 = analogRead(A3); th1 = map(val1, 170.0, 880.0, 0.0, 180.0); if(th1 >= 180.0){ th1 = 180.0; }else if(th1 <= 0.0){ th1 = 0.0; } th2 = map(val2, 150.0, 860.0, 0.0, 180.0); if(th2 >= 180.0){ th2 = 180.0; }else if(th2 <= 0.0){ th2 = 0.0; } th3 = map(val3, 860.0, 160.0, 0.0, 180.0); if(th3 >= 180.0){ th3 = 180.0; }else if(th3 <= 45.0){ th3 = 45.0; } set_servo(); } void set_servo(){ myservo1.write(th1); myservo2.write(th2); myservo3.write(th3); |
Hope you all find this article informative. Superkitz will be back soon with more interesting blogs.