Go Down

Topic: Servo library mostly working.. Mostly (Read 976 times) previous topic - next topic

So, I'm using the servo library to turn two HITEC HS-5645MG digital servos. It basically works, with one hitch: they don't turn the full 180 range, but rather more like 140. Being a good little n00b I emailed HITEC to ask if this was normal, and what to do, I got a cryptic answer:

"Thank you for choosing Hitec products. The 5645MG can handle a wider PWM signal which will allow the servo to travel 180 degrees."

I asked for clarification to no avail. What I seem to be understanding from this is that possibly the overall pulse frequency I'm using is too small? It seems like it wouldn't work at all if that was the case.

So, I set up a loop using the options available in the Servo.attach function to manually set the minimum and maximum pulse widths, write a 0 and a 180, and see how far the servo would go.. It wasn't any further.

Any insight?

DuaneB

Hi,

Use writeMircoseconds instead of write, try a range from -

writeMicroseconds(MIN_PULSE_WIDTH);

to

writeMicroseconds(MAX_PULSE_WIDTH);

This is the maximum range defined by the servo library in Servo.h

It might be larger that your servo can manage over the long term, so if it gives you more range than you need, create your own MAX and MIN to limit the servo to the range you need.

The values of MIN_PULSE_WIDTH and MAX_PULSE_WIDTH as defined in servo.h are

#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo 
#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo

You can define your own limits to be within this range in your sketch, for example

#define MY_MIN_PULSE_WIDTH       800     // the shortest pulse I will use
#define MY_MAX_PULSE_WIDTH      2200     // the longest pulse I will use

Duane B

rcarduino.blogspot.com
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

zoomkat

To get more rotational range out of a digital servo, you may have to purchase a digital servo programmer for your particular servo.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Duane-
Thanks. writeMicroseconds didn't work at all, actually, but I appreciate it; I had tried it earlier. I have the budget to buy the programmer, so I'm going to try that today. I appreciate the help, guys!

Brad

Go Up