I am using an Arduino UNO to control 6 servos and a conveyor belt, power is supplied via a PSU, everything works when less than 3 servo's are named and attached to pins however nothing works when more than 3 are attached and named,
Can anyone help?
I am using an Arduino UNO to control 6 servos and a conveyor belt, power is supplied via a PSU, everything works when less than 3 servo's are named and attached to pins however nothing works when more than 3 are attached and named,
Can anyone help?
Can you provide details?
The detail that I am most interested in at the moment is a wiring diagram.
Can you get a pen and paper, draw how everything is wired up, take a picture of that diagram and post the picture here?
While you are at it, post your code (use code tags).
Do you mean literally "when more than 3 are attached and named" in the sketch, but not called upon to move, maybe not even connected?
Luke2431:
Can anyone help?
As well as the wiring diagram that @vinceherman has requested please post your program.
...R
It certainly won't work if you trying to power the servos from the 5V pin on the Arduino. Always use a separate power supply for motors and servos, and connect the grounds.
Luke2431:
I am using an Arduino UNO to control 6 servos and a conveyor belt, power is supplied via a PSU, everything works when less than 3 servo's are named and attached to pins however nothing works when more than 3 are attached and named,Can anyone help?
"A PSU" - which PSU?
"6 servos" - which servos?
These are the important details. Its almost certain you have inadequate power for the servos, they,
like all devices using motors, need a lot of power.
in the program i have just simply named the servos and attached the servos to a pin however only one servo is in use the other 5 are not in use when this occurs
If a servo has been attached, the Arduino is telling it to go to it's initial position, which means it's drawing current. You have six doing this.
The number one problem people have with servos is inadequate power. It rather looks like it is your issue too, but since you're reluctant to provide details, it's hard to be sure.
this is my basic setup however i am powering a conveyor belt from the power supply unit also running at 12V and the power to supply the servos is coming from a 5V fixed supply
OPs image so we don't need to download
Luke2431:
this is my basic setup however i am powering a conveyor belt from the power supply unit also running at 12V and the power to supply the servos is coming from a 5V fixed supply
What are the specs on the 5v power supply?
Can you take some pics of your project and post them here?
Can you post your code here? (use code tags)
Do you have a DMM? What happens to the 5v level when the servos misbehave?
Luke2431:
in the program i have just simply named
It is possible to have a lot of simple errors or a lot of poor design even in a short program. If you want help post the program.
...R
#include <Servo.h>
Servo waistservo; //Servo name to control servo
Servo gripperservo;
Servo wristelevation;
// this constant won't change. It's the pin number of the sensor's output:
const int pingPin = 7;
const int motorPin = 6;
void setup() {
// initialize serial communication:
Serial.begin(9600);
waistservo.attach(3); // attaches the servo on pin 3 to the servo object
gripperservo.attach(11);
wristelevation.attach(5);
pinMode(motorPin, OUTPUT); // set motor pin as an output
digitalWrite(motorPin, HIGH); // set motorPin to high
}
void loop() {
// establish variables for duration of the ping, and the distance result
// in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH pulse
// whose duration is the time (in microseconds) from the sending of the ping
// to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
if (inches == 0) // if inches = 0 turn conveyor off
{
digitalWrite(motorPin, LOW);
waistservo.attach(3); // attaches the servo on pin 3 to the servo object
delay(15);
waistservo.write(1); // sets the servo position according to the scaled value
delay(1000); // waits for it to get to the position
waistservo.detach();
delay(1000);
waistservo.attach(3); // attaches the servo on pin 3 to the servo object
delay(15);
waistservo.write(179); // sets the servo position according to the scaled value
delay(1000); // waits for it to get to the position
waistservo.detach();
delay(1000);
}
delay(1000);
// if inches greater than 0 turn motor on
if (inches >0)
{
digitalWrite(motorPin, HIGH);
}
}
long microsecondsToInches(long microseconds) {
// According to Parallax's datasheet for the PING))), there are 73.746
// microseconds per inch (i.e. sound travels at 1130 feet per second).
// This gives the distance travelled by the ping, outbound and return,
// so we divide by 2 to get the distance of the obstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) {
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the object we
// take half of the distance travelled.
return microseconds / 29 / 2;
}
Only 3 servos are named in the example posted.
Post the code that fails, and tell us what "fail" means to you.
I wonder if the use of pulseIn() is causing the problem?
...R
What are the devices connected to "pingPin" and "motorPin" and how are they connected and powered. They don't seem to have been mentioned and they certainly don't show up on your "diagram".
Steve