If I use servo.write(180) I can see the indicator light on my 5V 8A power supply extinguishes momentarily and of course the Arduino resets. If I move the servo to 180 via a loop that has a delay of 15 within it, all is good; it just moves slower. If I use the loop with a delay of 5 in it, the power supply is pulled down and the Arduino resets. It is a high torque servo but still, the stall current is 1A. I also have led indicators. They function correctly under any of the aforementioned software configurations with the servo disconnected. Is there any back EMF with a servo? - Scotty
I suspect you have a servo that cannot actually go to 180° - which would be very common. Then if it tries to go past its end-stop the motor stalls and draws a heavy current - which might damage the servo.
You should experiment to find the actual range of your servo. The Servo.writeMicroseconds() comand will give you finer control. The range of values is roughly between 500 and 2400 microsecs.
...R
Using a breadboard to get power from the power supply to the servo?
Or worse, powering the servo from the 5v pin.
This can work for a single, small, unloaded servo.
It might even work for a single, large, unloaded servo so long as you don't make it work hard for more that a small time and give the capacitors time to recharge.
So your bigger servo works using the sweep tutorial with a delay of 15ms between each new movement command.
And it fails if you shorten that delay to 5ms.
It also fails if you tell the servo to move directly to the end point keeping the motor at full power for a longer time.
I suspect that your system will fail even with the 15ms pause if you slightly load the servo by putting your finger on the servo arm and giving some resistance to the movement.
The fix is very clear. Properly power the servo.
Google "servo separate power"
scottyjr:
If I use servo.write(180) I can see the indicator light on my 5V 8A power supply extinguishes momentarily and of course the Arduino resets. If I move the servo to 180 via a loop that has a delay of 15 within it, all is good; it just moves slower. If I use the loop with a delay of 5 in it, the power supply is pulled down and the Arduino resets. It is a high torque servo but still, the stall current is 1A. I also have led indicators. They function correctly under any of the aforementioned software configurations with the servo disconnected. Is there any back EMF with a servo? - Scotty
If its a high torque servo it needs much more than 1A. Standard micro servos use 1A or so.
But you've not identified the servo to us, nor the power supply, so all we can say is the servo and power supply are not compatible.
Thanks All for your responses.
Robin2 - I thought you might be onto something so I changes the servo.writes to 170m and 10 degrees. Power supply still dips and Arduino resets. I did try another power supply (a 2A wallwart) but had the same results.
vinceherman & Idahowalker- The servo power leads are connected directly to the power supply. The breadboard hosts an Arduino Nano, two resistors, two leds, two pushbuttons and a capacitor. The servo and the breadboard share a common ground.
MarkT - The servo is a Hiwonder 20KG Digital Servo Full Metal Gear High Torque, Aluminium Case for Robot DIY (Control Angle 180). I described the power supply as 5V and 8A. What other information is needed?
- Scotty
Code:
#include <Servo.h>
boolean OPEN = false;
boolean CLOSE = false;
byte open_switch_pin = 3;
byte close_switch_pin = 4;
byte opened_led_pin = 5;
byte closed_led_pin = 6;
int angle = 0;
Servo myservo;
int pos = 0; // variable to store the servo position
void setup() {
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
CLOSE = false;
OPEN = false;
pinMode(open_switch_pin, INPUT_PULLUP);
pinMode(close_switch_pin, INPUT_PULLUP);
pinMode(opened_led_pin, OUTPUT);
pinMode(closed_led_pin, OUTPUT);
myservo.write(0);
}
void Read_Switches() {
OPEN = !digitalRead(open_switch_pin);
CLOSE = !digitalRead(close_switch_pin);
if (OPEN) {
CLOSE = false;
digitalWrite(opened_led_pin, HIGH);
digitalWrite(closed_led_pin, LOW);
}
if (CLOSE) {
OPEN = false;
digitalWrite(closed_led_pin, HIGH);
digitalWrite(opened_led_pin, LOW);
}
}
void Debug() {
if (OPEN) {
Serial.println("OPEN");
}
if (CLOSE) {
Serial.println("CLOSE");
}
}
void loop() {
Read_Switches();
Debug();
if (OPEN) {
myservo.write(170);
delay(1000);
//for(angle = 0; angle < 180; angle++)
//{
// myservo.write(angle);
//delay(15);
//}
}
if (CLOSE) {
myservo.write(10);
delay(1000);
//for(angle = 180; angle > 0; angle--)
//{
// myservo.write(angle);
// delay(15);
//}
}
}
scottyjr:
Robin2 - I thought you might be onto something so I changes the servo.writes to 170m and 10 degrees.
That is not a sufficient test.
What happens at 100° ?
If there is no problem at 100° then try 110, 120 etc until you find the point where the problem arises.
...R
The vendor's page says that the servo's working voltage is 6-7.4V, so that power supply isn't actually up to spec. I assume it's powering the Nano as well?
scottyjr:
MarkT - The servo is a Hiwonder 20KG Digital Servo Full Metal Gear High Torque, Aluminium Case for Robot DIY (Control Angle 180). I described the power supply as 5V and 8A. What other information is needed?
No, post links to the datasheets or product pages - you haven't identified the power supply model for instance,
and you are forcing people to do your googling for you, which isn't a sensible use of everyone's time.
"5V and 8A" power supply is definitely not enough information. For instance if its cheap and chinese that 8A is probably nonsense.