2190Views20Replies
Help wiring and programming a Robot Arm?
I have been building a robot arm for a competition, and I have the structure completed. I am very new to Arduino, and have little know-how when it comes to wiring properly and even less when it comes to programming. I have uploaded pictures of the robot arm as well as a crude circuit diagram of what I think needs to be wired. (Sorry if it is a bit confusing, I am reaaaaally new to this.) I am trying to control each joint (claw, wrist, elbow, shoulder, and rotary base) with a 10k pot. similar to how the Arduino servo knob command works. I plan on eventually making an instructable for this and will credit any help I get there.
Comments
Best Answer 8 years ago
Start with your power connections. DON'T run the servos via your Arduino, you'll burn it out.
Answer 8 years ago
That is what I was thinking. Did I wire it correctly for the power?
Answer 8 years ago
Looks OK
Answer 8 years ago
I have it wired up now and when I turn it on it just seizures.
Answer 8 years ago
Take off all but one servo, get that running. I'm not pretending to read the "drawing" of what you have. I might read a circuit diagram.
What code have you loaded on the Arduino ?
Answer 8 years ago
#include
Servo myservo;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int potpin = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;
int potpin5 = 5;
int val;
int val2;
int val3;
int val4;
int val5;
void setup()
{
myservo.attach(1);
myservo2.attach(2);
myservo3.attach(3);
myservo4.attach(4);
myservo5.attach(5);
}
void loop()
{
val = analogRead(potpin);
val2 = analogRead(potpin2);
val3 = analogRead(potpin3);
val4 = analogRead(potpin4);
val5 = analogRead(potpin5);
val = map(val, 0, 1023, 0, 179);
val2 = map(val, 0, 1023, 0, 179);
val3 = map(val, 0, 1023, 0, 179);
val4 = map(val, 0, 1023, 0, 179);
val5 = map(val, 0, 1023, 0, 179);
myservo.write(val);
myservo2.write(val2);
myservo3.write(val3);
myservo4.write(val4);
myservo5.write(val5);
delay(15);
}
Answer 8 years ago
Your code around the map statements is wrong - but this is cleaner anyway:
myservo.write( map( analogRead (potpin),0,1023,0,178));
myservo2.write( map( analogRead (potpin2),0,1023,0,178));
myservo3.write( map( analogRead (potpin3),0,1023,0,178));
//saves variables and code.
Answer 8 years ago
Ok I tried this:
Servo myservo;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int potpin = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;
int potpin5 = 5;
int val;
int val2;
int val3;
int val4;
int val5;
void setup()
{
myservo.attach(1);
myservo2.attach(2);
myservo3.attach(3);
myservo4.attach(4);
myservo5.attach(5);
}
void loop()
{
val = analogRead(potpin);
val2 = analogRead(potpin2);
val3 = analogRead(potpin3);
val4 = analogRead(potpin4);
val5 = analogRead(potpin5);
val = map(val, 0, 1023, 0, 179);
val2 = map(val, 0, 1023, 0, 179);
val3 = map(val, 0, 1023, 0, 179);
val4 = map(val, 0, 1023, 0, 179);
val5 = map(val, 0, 1023, 0, 179);
myservo.write( map( analogRead (potpin),0,1023,0,178));
myservo2.write( map( analogRead (potpin2),0,1023,0,178));
myservo3.write( map( analogRead (potpin3),0,1023,0,178));
//saves variables and code.
delay(15);
}
But I got this:
sketch_feb03a:1: error: 'Servo' does not name a type
sketch_feb03a:2: error: 'Servo' does not name a type
sketch_feb03a:3: error: 'Servo' does not name a type
sketch_feb03a:4: error: 'Servo' does not name a type
sketch_feb03a:5: error: 'Servo' does not name a type
sketch_feb03a.ino: In function 'void setup()':
sketch_feb03a:20: error: 'myservo' was not declared in this scope
sketch_feb03a:21: error: 'myservo2' was not declared in this scope
sketch_feb03a:22: error: 'myservo3' was not declared in this scope
sketch_feb03a:23: error: 'myservo4' was not declared in this scope
sketch_feb03a:24: error: 'myservo5' was not declared in this scope
sketch_feb03a.ino: In function 'void loop()':
sketch_feb03a:39: error: 'myservo' was not declared in this scope
sketch_feb03a:40: error: 'myservo2' was not declared in this scope
sketch_feb03a:41: error: 'myservo3' was not declared in this scope
Answer 8 years ago
Steve
Answer 8 years ago
Ok this works. I have control and everything is responding. However It has a severe twitching problem.
8 years ago
You might get better results by driving the pots from the REGULATED supply from the Arduino. I think you might be able to pick it off Vref too. DO NOT put anything BUT the pots on that pin.
8 years ago
your diagram looks fine, just replicate the servo pot example like you said here http://arduino.cc/en/Tutorial/Knob and change the pins, and it should work fine
Answer 8 years ago
Well the servo knob example is only for one servo. I tried modifying and all it does it seizures.
Answer 8 years ago
What do you mean by "seizures" ? Do you mean "seizes up", ie, twiddling the pots does nothing?
Are you getting a change in volts on the input to the Arduino AnalogIn pins ?
Answer 8 years ago
The bot is apparently only taking input from the A1 pot, and assigning that to all of the servos.
Answer 8 years ago
debug it a bit, take it down to just 2 servos, add some Serial.print's to verify the data before it hits the servo objects
Try moving the servo pins up past 0 and 1 (these are usually used by serial communication)
so have them start at 2 or so
8 years ago
I'm sorry I really have no idea how most of this works. I don't know what that means.