Hello!
I'm building a robotic arm for a college project, it is powered by an Arduino Uno, and 3 servos with 15kgf of torque, the arm has been build with stainless steel and a 12v/1.5a font provides the power for all the structure. But I'm facing a problem when the arm try to grab an object, the base servo starts to twitch making impossible for the arm to grab the object, has can been seen on the video below:
And here's the arm code (I used the servo library):
#include "Ultrasonic.h"
#include <Servo.h>;
// Pino VCC -> 5V
// Pino GND -> GND
#define echoPin 13 // Pino 13 -> Echo
#define trigPin 12 // Pino 12 -> Trig
#define LED 8
Ultrasonic ultrasonic(trigPin,echoPin);
int parado = 0;
int inicio = 0;
Servo gservo;
Servo aservo;
Servo bservo;
void setup()
{
gservo.attach(11); //fio do servo da Garra
aservo.attach(9); //fio do servo da Articulação
bservo.attach(10); //fio do servo da Base
}
void mexendo(void) {
aservo.write(110);
delay(15);
bservo.write(180);
delay (1500);
gservo.write(100);
delay(1500);
aservo.write(100);
delay(1500);
aservo.write(90);
delay(1500);
aservo.write(75);
delay(1500);
aservo.write(60);
delay(1500);
aservo.write(45);
delay(1500);
aservo.write(30);
delay(1500);
aservo.write(10);
delay(1500);
aservo.write(5);
delay(1500);
gservo.write(75);
delay(300);
gservo.write(70);
delay(500);
aservo.write(30);
delay(1500);
aservo.write(60);
delay(1500);
aservo.write(90);
delay(1500);
aservo.write(110);
delay(1500);
bservo.write(55);
delay (3000);
bservo.write(1);
delay (3000);
aservo.write(100);
delay(1500);
aservo.write(90);
delay(1500);
aservo.write(70);
delay(1500);
aservo.write(60);
delay(1500);
aservo.write(40);
delay(1500);
gservo.write(80);
delay(1500);
bservo.write(55);
delay(1500);
aservo.write(90);
delay(300);
aservo.write(110);
delay(1500);
gservo.write(100);
delay(3000);
}
void quieto(void) {
aservo.write(110);
delay(1500);
bservo.write(55);
delay (1500);
gservo.write(100);
delay(1500);
}
void loop(){
int i=0;
long distance=ultrasonic.Ranging(CM);
while(i<4) {
distance=(distance + ultrasonic.Ranging(CM))/2;
i++;
}
if(distance<10) {
digitalWrite(LED,HIGH);
mexendo();
inicio=1;
} else {
digitalWrite(LED,LOW);
if(inicio==0) {
quieto();
delay(1000);
parado=1;
}
}
}
I've searched for the solution changing the code and the electronics, but I didn't find anything that could help me to resolve this issue, somebody could help me?