PR Servo won't stop

I am using arduino servo library and I was able to make two servos work perfectly, now no matter what I do, they both exhibit the same behavior, i.e. When powered off I turn the arm all the way clockwise then when I power it on and connect to PWM, it turns all the way CCW, stops and then keeps buzzing as if the motor is still running but the arm has been stopped by the mechanical stops.

I've tried using write.microSeconds(500), 1000, 1500, 2000, 2500. For all cases, I get the same behavior. I connected an LED to the attached pin (without servo) and it's dim for the 500u case and gets brighter in steps as I step up the pulse width.

One servo is an sg90 the other is a HiTec HS-322HD. Both show the same behavior and both were working before. Both are supposed to go to the neutral position with a pulse width of 1500uS.

I've tried powering the sg90 from the arduino supply and I get the same thing. I have not tried the HiTec on Arduino supply, I'm afraid it might draw too much current. It runs on a 5v ac-dc adapter that I hacked by splicing in two wires to connect to my breadboard.

I've tried attaching to pins 8,9,10, and 11. All show the same behavior.

I have not opened up either servo. I have not tried to convert them to Continuous Rotation Servos.

Any help would be appreciated. I am stuck! :frowning:

and both were working before.

Before what?

rajk1:
and connect to PWM,

In addition to what @PaulS has said, what does the above mean?
You do NOT need to use PWM pins for a servo.

You DO need to post your program so we know what you are talking about.
And please use the code button </>so your code looks like thisand is easy to copy to a text editor

…R

#include <Servo.h>  // servo library
Servo servo1;  // servo control object

void setup()
{
  servo1.attach(11);
  Serial.begin(9600);
}

void loop()
{
  int position;
  int written;

  // Change position at full speed:
  Serial.println("sending 1000");
  servo1.writeMicroseconds(1000);
  written = servo1.readMicroseconds();
  Serial.println(written);
  delay(5000);

  Serial.println("sending 1500");
  servo1.writeMicroseconds(1500);
  written = servo1.readMicroseconds();
  Serial.println(written);
  delay(5000);

  Serial.println("sending 2000");
  servo1.writeMicroseconds(2000);
  written = servo1.readMicroseconds();
  Serial.println(written);
  delay(5000);

}

Thanks for taking a look.

I had the HiTec Servo plugged in and doing a simple, slow move of +/-45 degrees all night. I checked it in the morning and it was still working fine. I unplugged it and put it away. The next time I plugged it in to the identical setup with same code and it showed the weird behavior.

I then plugged in the 2nd relay. It had also been working previously before I unplugged and put it away, now it showed the same behavior.

I can't think of anything relevant that might have changed. I did get a windows update on the computer...

How are you powering the servo?

...R

The servo is powered by a 5v wall wart which I use to power the breadboard that the servo is on. The breadboard ground is connected both to the Arduino and the ground from the wall wart.

I've run the smaller servo from the Arduino supply, after removing the wall wart, and I get the same bad behavior.

BTW, incase it's not clear, I'm only using the Arduino board, not any other motor shields, etc. on top. The board is a Genuino which I bought as part of a beginner kit from Vilros. The setup is on a bench and uses the breadboard, wiring, and sg90 which came with the kit. I bought the HiTech servo seperately.

Thanks again Robin and Paul for taking a look.

Raj

You say "I then plugged in the 2nd relay" - I don't think you told us about the 1st relay

It would help if you make a pencil drawing showing how everything is connected and post a photo of the drawing.

In my experience if something works today it will work again in 6 months time unless something is changed in the meantime - perhaps a bad connection somewhere, a different power supply, extra equipment added or an inadvertant change in the program.

...R

rajk1:
One servo is an sg90 the other is a HiTec HS-322HD. Both show the same behavior and both were working before. Both are supposed to go to the neutral position with a pulse width of 1500uS.

I've tried powering the sg90 from the arduino supply and I get the same thing. I have not tried the HiTec on Arduino supply, I'm afraid it might draw too much current. It runs on a 5v ac-dc adapter that I hacked by splicing in two wires to connect to my breadboard.

Robin, above are the answers to your last two questions. I'll make a pencil drawing and post it later tonight.

Again, thanks for taking a look.

Raj

rajk1:
Robin, above are the answers to your last two questions.

You have not answered my question about the relay(s) that you mention in Reply #4

And you have not responded to the last paragraph in Reply #8

…R

Robin,

I’m not sure what you are asking about the relays. There is only 1 relay in the system but I can unplug it and replace it with another one to test if it does the same thing. They types of relays is described above and how they are powered is described above.

As far as reply number 8, I understand what you are saying, and I can’t think of anything that changed. I have since rewired the circuit to be much simpler and reduced the code down to what is attached above and I still get both servos failing in exactly the same way.

I’m attaching the pencil sketch. I hope it will answer some of your questions. If not, please elaborate…

Thanks,
Raj

Image from previous Reply so we don’t have to download it. See Image Guide

4cf26638b2b5b89a4979d1a52ff36e673093f3f6.jpg

…R

You seem to be powering the sevo from the Arduino 5v pin. Don't do that, it can overload the Arduino and may damage it. Give the servo a separate power supply with a common GND.

Your diagram does not show any relay. Does that mean that the relay(s) you mentioned in Reply #4 are no longer part of the project?

By the way that is the first sensible and unambiguous diagram of a breadboard that I have seen.

...R

Robin,

I do have a separate 5v supply that I use for the servo. It shares a ground (only) with the Arduino supply. The diagram is one configuration I have tested to rule out my hacked power supply as a source of the problem. Both supply configurations show the same bad behavior.

I mis-spoke (mis-typed?) Relay when I meant to say servo. Sorry about that. There are no Relays in the sytem. The diagram is the complete circuit that I am testing.

Thanks,
Raj

rajk1:
I mis-spoke (mis-typed?) Relay when I meant to say servo.

It’s an easy mistake to make but it had me very confused. Never mind.

Have you any other way to prove that the servos function properly - such as a regular R/C receiver?

I can’t see anything wrong with the code in Reply #3, but why not simplify things greatly and just try this (which I have not tested)

#include <Servo.h>
Servo servo1;

void setup()
   servo1.attach(11);
   servo1.write(90);
}

void loop() {
}

Then you can change the number 90 for other values. And switch to servo.writeMicroseconds().

Don’t immediately try values of 0 or 180 in case the servo you have cannot move to those extremes. Work up to the limits gradually.

If you have a problem it may be worth trying a different Arduino I/O pin.

And only try it with the servo powered externally.

…R

Hi Robin,

I bought a new servo on the theory that both of my existing servos have blown in exactly the same way. It turned out that the new servo worked!

I then plugged an old servo into the lead wires for the new servo and it too worked!

It turned out that the power wire I was using before to attach to the servo from breadboard was bad. I had replaced all of the wiring but hadn't changed the leads to the servo plug.

All three servos are working now!

Thanks for your help!

BTW, I tested my code on an arduino simulator: http://www.virtualbreadboard.com/
and it helped me rule out that I was not coding something wrong. The simulators has servos that can be plugged in and behave just like the real thing. I'm not sure if many people are using this simulator/emulator but I found it to be very useful. I think I will use it again to build a virtual system before I mess with real wires next time!

If you think people are not aware of it and it would be useful, I could do a post on the forum about it, if such things are encouraged. I just happend to find the tool and have no affiliation whatsoever with the company.

rajk1:
All three servos are working now!

Good to know.

That sort of wiring fault can be very frustrating. Also debugging anything is more complex when you don't know what to expect.

...R