Wednesday, 19 November 2025

More work on the Robot Arm - EEZYBot Mk 2

 In March 2017 I 3D printed a Robot arm.  The original post is here:

https://langster1980.blogspot.com/2017/03/another-robot-arm.html

I saw the arm in amongst a pile of boxes covered in dust and looking rather sad.  In a moment of pure nostalgia...and possibly guilt I decided the robot arm needed a new lease of life and some purpose.  To be fair this is also true for me.  I rarely make time for personal projects and blog posts these days...this will hopefully change.

I also managed to find the boards I had made by Elecrow and I must have intended something as It was populated and working!  

There were various broken 3D printed parts and linkages on the Robot arm that I have 3D printed and replaced.  I also upgraded the base servo motor and the gripper.

Here is the new and improved robot arm😆


EEZYBot Mk2 - my implementation - design credits to Daguismo the original designer

The sense of satisfaction at getting this working reminded me of why I chose engineering as a profession and I really must make more time for this.

To that end I wrote up some new arduino code which I then decided to have Google Gemini assist me with.  It actually did an excellent job and provided some significant improvements.

The arduino code is here: Robot Arm Arduino Code

The code essential works as follows:

1. Prompt the user via the serial terminal as to whether they want Local potentiometer control or Serial Control

2. Handle the inputs from the serial terminal (and the Python front end)

3. Handle the inputs from the potentiometers

4. Drive the servo motors appropriately

The table below provides further information:

SectionPurposeKey Mechanism
State & ModeDefines the two control modes (M0 Serial, M1 Potentiometer).The global variable currentMode dictates which handler runs in the loop().
handleSerialControl()Reads all incoming commands (M0, S5, U90, ; comment) from Python.Uses Serial.readStringUntil('\n') to read entire commands and a switch statement to process them. It ignores lines starting with ;.
handlePotControl()Reads the analog values from the potentiometers.readSmoothAnalog() averages multiple samples to prevent noisy/jittery movement.
Target SettingUpdates the target angle (targetBase, targetUpper, etc.).setServoTarget() takes the desired angle (from serial or a pot) and updates the target variable, but does not move the servo yet.
handleRamping()Manages the speed and movement of the servos.Runs every 20ms (RAMPING\_INTERVAL\_MS). It moves the servo's current position (posBase) only a small step (maxSpeed) closer to its final target position (targetBase). This creates the smooth, speed-controlled motion.
reportCurrentPosition()Sends the arm's actual position back to the Python GUI.Sends a dedicated string (e.g., P:B85,U90,...) every 100ms to synchronize the GUI sliders with the physical arm.

I also...with Google Gemini's assistance wrote a Python front end which provides a graphical user interface to the serial terminal - very cool.  I am not a great python coder...with the AI assistance a lot was achieved.

The Python Code is here: Robot Arm Python GUI

Here is a screen shot of the GUI


Here is how the code roughly works:

FunctionPurposeConnection to Arduino
connect_serial()Establishes the connection and starts the arm.Creates the serial.Serial object. It includes a 2-second time.sleep(2) to wait for the Arduino to reboot.
initialize_arm_position()Runs the initial setup (M0, S2, B85...) to guarantee a safe, stable starting state after connection.Sends commands line-by-line using self.ser.write().
serial_reader()Runs in a separate thread to constantly listen for incoming data from the Arduino.Uses self.ser.readline() in a loop. It looks for lines starting with P:.
update_gui_position()Synchronizes the interface sliders with the physical arm position.Crucially, it ignores position updates if the GUI is set to Serial Mode (M0) to prevent the Arduino's periodic report from overriding a position you just selected on a slider.
run_sequence()Manages script execution.Runs in its own thread to prevent the GUI from freezing. It sends commands separated by the configurable Delay. It checks the self.stop_requested flag to allow immediate interruption.
record_all_positions()Creates movement script lines.Reads the current angle values from the synchronized sliders and formats them into the line-by-line command structure (e.g., U90\nL150\n).

Finally here is a video of the arm performing a pre-determined function <massive grin>

I intend doing a lot more with this Robot arm now that I have it working reasonably consistently.  I have always wanted to couple a robot arm with an AI assisted camera to perform sorting operations...so that's next.  I expect I will need to create a leader arm to assist with creating the AI learning model.

Take care as always - Langster!











No comments :

Post a Comment