PWM frequency suddenly changed

My servo seems to have suddenly changed it's PWM frequency. This is the second time it's happened with completely different hardware. The first time I was a complete novice and thought I'd done something wrong.

Now I'm still pretty new but my servo steps used to drive a wheel about 300 degrees... today it suddenly drives the same wheel about 450 degrees. I have no explanation except I think the PWM frequency must have changed somehow. I don't set it in my code... Is that possible?

I have no other explanation how the movement can have change so significantly.

Firstly you're in the wrong forum: I'll suggest to mods that they move this to Motors.

Second, you should provide more detail. "300 degrees" is not a value that most servos are aware of, since most are 0-180 degrees. So I think you should provide hardware details, connection schematic, and your code.

Are you using servo.write() to control your servo?

Post your code !

...R

Hi, what are the servo units that you are using?

Tom...... :)

My servo seems to have suddenly changed it's PWM frequency

Assuming this is a digital servo, that's not anything the Arduino has any control over.

  1. Sorry about the incorrect posting
  2. The 300 degrees is leveraged movement, I think the larger servo steps is causing the larger total movement
  3. I’m using writeMicroseconds()
  4. microseconds
  5. Analog servo (Hitec HS-45HB)

#include <Servo.h>

Servo myservo; // create servo object to control a servo
int x = 970; // servo position (zero)
int x1 = x; // previous servo position
int x2 = x; // next servo position

void setup() {
Serial.begin(57600);
myservo.attach(3); // pin 3 to the servo object
myservo.writeMicroseconds(x); // zero servo
delay(1000); // wait for move before detach
myservo.detach();
}

void loop() {
if ( Serial.available() ) {
x2 = int(Serial.parseInt());
myservo.attach(3);
myservo.writeMicroseconds(x1);
// if out of range move to center
if ( x2 < 950 or x2 > 2050 ) { x2 = 1500; }
// loop to slow movement, clockwise
if ( x2 > x1 ) {
for ( x = x1; x < (x2-10); x = x+10 ) {
myservo.writeMicroseconds(x);
delay(50);
}
}
// loop to slow movement, counter clockwise
if ( x2 < x1 ) {
for ( x = x1; x > (x2+10); x = x-10 ) {
myservo.writeMicroseconds(x);
delay(50);
}
}
myservo.writeMicroseconds(x2);
delay(500);
x1 = x2;
myservo.detach();
// Serial.print("Arduino says: ");
// Serial.println(x2);
}
}

Hi, so if it was a leverage problem, do you have a problem?

Tom..... :)

Yes, the leverage applied hasn't changed, only the resulting movement has changed. I was just explaining the confusion I caused by the 300 degrees of motion.

I'm in exactly the same place. My program runs, it ran fine prior to the problem, it runs without error now... the servo just moves in larger steps. I can hear the difference.

So... larger steps + my program issuing the same number of steps = further servo movement.

At least that's what I THINK is happening. All I know for certain is it now moves my wheel a LOT further than it did last week and I don't know why. Same code.

Let me say it a different way. I used to set myservo.writeMicroseconds(970) to move the servo to what I consider zero postion. And myservo.writeMicroseconds(2030) to my max postion.

But now, to reach the same physical positions…

zero position = myservo.writeMicroseconds(1190)
max position = myservo.writeMicroseconds(1880)

The steps I now need to get to the same postion is SIGNIFICANTLY reduced. I need more steps, like I had before, for finer resolution.

Help please.

I can only assume some physical damage inside: perhaps the pot's messed up?

Here it says 1500 is neutral, with a range of 600 to 2400 (0-180 degrees).

I still don't understand the 300 / 450 thing.

Hi, uncle, what do you consider to be zero? I consider zero to be zero deg, that is the arm is at the start of its travel, full CCW, then you go CW to 180deg which is full for the servo. As JimboZA has said thats 600 to 2400. Can you post us a picture of your setup, I suspect your leverage system may have caused the servo to jump its gears teeth and now to be out of sync with the feedback pot. Does the leverage system increase or decrease the output movement? Have you tried a simple sketch that makes the servo swing from zero to 180deg and back just to make sure you still have proper sync and span, if the servo jams or does not go full 180deg swing then its got problems.

Tom..... :)

The leverage system has no impact on the servo it’s a piece of thread tied to a lever which moves a wheel. My zero and max are simply arbitrary positions on the wheel that I have marked as the min and max positions. The servo can drive beyond both zero and max.

The confusing part is, not only did it work a week ago… this is the second one I’ve built. Same code just with adjusted numbers for the slight differences in servo position from build 1 to build 2.

I know the next response, perhaps the numbers are wrong. But they are impossibly different. AND different from last week. I mean the difference IS the problem. The same code is now spinning my leveraged wheel MUCH further.

Zero used to be 970 (this is my build #2 and the numbers were adjusted to fit the new servo mount… everything worked), now it’s 1190… with no explanation as to why. I changed nothing.

Servo is epoxy’d into postion, I can not just try another one. But I have run another servo on the bench and they seem the same.

I must have a resolution this weekend, I’ve sold this device and pickup is Monday.

Hi, fine ,I see that yours may not be the same as the one cited by JimboZA. I googled and got a unit like this. http://www.servodatabase.com/servo/hitec/hs-45hb

It doesn't have a particularly encouraging review, and plastic gears, they also cite 900 to 2100 as the pulse width required. Not 600 to 2400 as in JimboZA spec. Puzzling, but I'd say if yours has plastic gears, they could have stripped or jumped out of sync. How are you powering the servo?

Tom..... :)

Can you manually rotate the servo arm (unpowered, slowly, and without breaking anything) to find out where the physical limits are and how they relate to your microSecond values?

Are your symptoms consistent with the possibility that the servo-arm slipped on the servo output shaft - everything normal but in a different position?

...R

Tom, it doesn't appear to be a gear problem, I have a servo tester and when I use that, it appears smooth and had a full range of travel. I don't mind the plastic gears because there is VERY little stress on this installation and it has performed well in my first build. (this is the second build) I do use the Arduino for powering it and I know it's not recommended. however the problems cause by power are not what I'm seeing. I tried powering a digital server and it just didn't work. Low power can also cause jitter, I do not have a jitter problem. So while generally not recommended... I agree. Build #1 has proved to be no problem running this specific servo directly from the Arduino.

Robin, the servo rotates normally unpowered. I know what you mean, and it feels good... normal. Full servo travel by hand is about 180 degrees. I'm using right at 90 degrees right in the center. So there's about 45 degrees below and above my useful range.

Very good question about the servo-arm slipage. The servo end is screw attached so no problem there. The linkage end is not as solid but I tried adjusting it to see if it would affect my problem and it's not even close. moving it makes such a small difference it's just not a factor.

Thanks so much for the suggestions guys. I'm still trying to figure this one out.

I guess it's possible that the servo's internal pot has moved position or has become damaged in such a way that the resistance is no longer balanced about the centre position.

Have you another known good servo that you can try ?

...R

Changing the servo (or even testing another one) is quite difficult because it’s epoxy’d in place. So a replacement will introduce it’s own inconsistencies of inexact placement.

However, you’re right, there’s nothing else left to try…

It sort of worked. The new servo is mounted beside the old one so I can’t make an exact comparison. But it did give me a range closer to my original settings. So I’m going to call this resolved with a servo that went “bad”?

Maybe “bad” is not a good description for this but the servo functionality changed after installation. The change was slight and probably wouldn’t be noticed without some project like mine where I have exact marks on movement to a position.

Maybe I need a better servo next time. (I hope this one lasts)

Thanks to everyone for the help! :slight_smile: