To help with my understanding of my Industrial Robotics: Kinematics & Dynamics module I have decided to build, design and programme a small, simple, 3-DOF robotic arm using hobby servos. This is an open-ended project with no specific goal or endpoint. My aim is to use this project to learn more about embedded systems, object oriented programming, and robotics.
This is the code for v1 of the arm, in which it is manually controlled by 3 potentiometers. This code was written in C++ in Mbed Studio as I was using the STM Nucleo-F401RE microcontroller.
I then added a basic potentiometer class with basic functionality, I am planning to refine this later especially when I have more going on.
classPotentiometer//Begin potentiometer class definition
{
private: //Private data member declaration
AnalogIn inputSignal; //Declaration of AnalogIn objectfloat VDD; //Float variable to speficy the value of VDD (3.3 V for the Nucleo-64)public: // Public declarations//Constructor - user provided pin name assigned to AnalogIn. VDD is also provided to determine maximum measurable voltage
Potentiometer(PinName pin, float v) : inputSignal(pin), VDD(v) {}
floatamplitudeVolts(void) //Public member function to measure the amplitude in volts{
return (inputSignal.read()*VDD); //Scales the 0.0-1.0 value by VDD to read the input in volts
}
floatamplitudeNorm(void) //Public member function to measure the normalised amplitude{
return inputSignal.read(); //Returns the ADC value normalised to range 0.0 - 1.0
}
};
This is a class from my Microcontroller Engineering II module, studied earlier this year, that I reused.
Pot-Servo Class
As the arm was going to be using minimum 3 servos (we'll get to the end-effector later) I decided to write a class that combined the functionality of the Servo class and the Potentiometer class - PotServo. This allowed me to instantiate each joint and its control as a single object.
The first version of the arm will simply be three servos controlled by 3 potentiometers, this allows full manual control over base, shoulder and elbow rotation. This can be controlled with any microcontroller really, but for the schematic i've used the Arduino Nano, as its size is convenient for the PCB. When prototyping this circuit I used both the Arduino Nano and the STM NUCLEO-F401RE. The external power source is necessary as the board itself cannot drive all 3 servos simultaneously.
Schematic
PCB Design
This was my first time using KiCad, so I kept the design simple as a starting project.