ETHERNET CONTROLLED ROBOTIC ARM
Robotic arm is used to do particular repetitive task and this robotic arm can be 4DoF or 6DoF according to the requirements. In this robotic arm servo are used for moving for the smooth working of the robot.
Arduino UNO
It’s like a brain of the robot, it is easy to used and with the help of this board we can make different DIY projects like electronic, automation etc projects. Arduino UNO works on C and C++ language which is called Arduino IDE. Technically, Arduino UNO is an open source electronic based hardware and software platform .
Servo Motor:
Servo motor is a electrical motor which is used to rotate the object at some degree of angle. Servo motors used at every joint of a robot to perform a specific repetitive task at its precise angle of movement that is 90 and 180 degree of angle.
Ethernet Module:
Ethernet module is used for internet access and control and it also read and switch any i/o point from any location on the network in which each of the i/o points can be monitored or switched from any point on the network.
Robot Arm:
Robot arm is used to do specific repetitive task. It is used in many industrial applications. It is designed to perform any desired task such as welding, pick and placing, gripping, spinning, rotating boxes etc depending on the industry like in manufacturing plant for welding, pick and placing in production for assembling etc. You can buy this robot arm online.
Connections:
Code:
#include <Servo.h>
#define GRIPPER_SERVO 9
#define UPPER_JOINT_SERVO 6
#define LOWER_JOINT_SERVO 5
#define BASE_ROTATOR_JOINT_SERVO 3
#define GRIPPER_OPEN 0
#define GRIPPER_CLOSED_SOFT 1
#define GRIPPER_CLOSED_MEDIUM 2
#define GRIPPER_CLOSED_HARD 3
#define GRIPPER_OPEN_ANGLE 150
#define GRIPPER_CLOSED_SOFT_ANGLE 75
#define GRIPPER_CLOSED_MEDIUM_ANGLE 65
#define GRIPPER_CLOSED_HARD_ANGLE 0
#define SERVO_ANGLE_UPPER_LIMIT 170
#define SERVO_ANGLE_LOWER_LIMIT 0
#define SERVO_ANGLE_RESTING 90
#define MIN_MOVEMENT_DELAY 2
#define MOVE_GRIPPER 'G‘
#define MOVE_ARM 'A‘
Servo gripper, upperJoint, lowerJoint, baseRotator;
unsigned int movementDelay = 5;
int gripperState;
int targetUpperJointAngle;
int targetLowerJointAngle;
int targetBaseRotatorAngle;
float currentUpperJointAngle, currentLowerJointAngle, currentBaseRotatorAngle;
float upperJointStep, lowerJointStep, baseRotatorStep;
unsigned long lastStepTime = 0;
void setup()
{
Serial1.begin(115200);
gripper.attach(GRIPPER_SERVO);
upperJoint.attach(UPPER_JOINT_SERVO);
lowerJoint.attach(LOWER_JOINT_SERVO);
baseRotator.attach(BASE_ROTATOR_JOINT_SERVO);
gripperState = GRIPPER_CLOSED_SOFT;
targetUpperJointAngle = currentUpperJointAngle = 140;
targetLowerJointAngle = currentLowerJointAngle = 45;
targetBaseRotatorAngle = currentBaseRotatorAngle = 85;
moveGripper(gripperState);
moveTo(targetUpperJointAngle, targetLowerJointAngle, targetBaseRotatorAngle);
}
void loop()
{
if (Serial1.available() > 0)
{
char command = Serial1.read();
if (command == MOVE_GRIPPER)
{
updateGripperState();
moveGripper(gripperState);
delay(250);
}
else if (command == MOVE_ARM)
{
updateArmMovement();
}
}
if (millis() - lastStepTime >= movementDelay)
{
if (targetUpperJointAngle != round(currentUpperJointAngle)) currentUpperJointAngle -= upperJointStep;
if (targetLowerJointAngle != round(currentLowerJointAngle)) currentLowerJointAngle -= lowerJointStep;
if (targetBaseRotatorAngle != round(currentBaseRotatorAngle)) currentBaseRotatorAngle -= baseRotatorStep;
moveTo(currentUpperJointAngle, currentLowerJointAngle, currentBaseRotatorAngle);
printPosition();
lastStepTime = millis();
}
}
void updateGripperState()
{
if (Serial1.available() > 0) gripperState = Serial1.parseInt();
else
return; clearSerial1();
}
void updateArmMovement()
{
int mDelay;
if (Serial1.available() > 0)
mDelay = Serial1.parseInt();
else
return;
int upperJointAngle;
if (Serial1.available() > 0)
upperJointAngle = Serial1.parseInt();
else
return;
int lowerJointAngle;
if (Serial1.available() > 0)
lowerJointAngle = Serial1.parseInt();
else
return;
int baseRotatorAngle;
if (Serial1.available() > 0)
baseRotatorAngle = Serial1.parseInt();
else
return;
clearSerial1();
movementDelay = mDelay >= MIN_MOVEMENT_DELAY ? mDelay : MIN_MOVEMENT_DELAY;
targetUpperJointAngle = upperJointAngle;
targetLowerJointAngle = lowerJointAngle;
targetBaseRotatorAngle = baseRotatorAngle;
upperJointStep = (currentUpperJointAngle - targetUpperJointAngle) / 100;
lowerJointStep = (currentLowerJointAngle - targetLowerJointAngle) / 100;
baseRotatorStep = (currentBaseRotatorAngle - targetBaseRotatorAngle) / 100;
}
void clearSerial1()
{
while (Serial1.available() > 0)
Serial1.read();
}
void moveGripper(int state)
{
switch (state)
{
case GRIPPER_OPEN:
gripper.write(GRIPPER_OPEN_ANGLE);
break;
case GRIPPER_CLOSED_SOFT:
gripper.write(GRIPPER_CLOSED_SOFT_ANGLE);
break;
case GRIPPER_CLOSED_MEDIUM:
gripper.write(GRIPPER_CLOSED_MEDIUM_ANGLE);
break;
case GRIPPER_CLOSED_HARD:
gripper.write(GRIPPER_CLOSED_HARD_ANGLE);
break;
}}
void moveTo(int upperJointAngle, int lowerJointAngle, int baseRotatorAngle)
{
upperJoint.write(upperJointAngle);
lowerJoint.write(lowerJointAngle);
baseRotator.write(baseRotatorAngle);
}
void printPosition()
{
Serial1.print(movementDelay);
Serial1.print(" ");
Serial1.print(gripperState);
Serial1.print(" ");
Serial1.print(round(currentUpperJointAngle));
Serial1.print(" ");
Serial1.print(round(currentLowerJointAngle));
Serial1.print(" ");
Serial1.println(round(currentBaseRotatorAngle));
}