I use 2 hitec HS-785HB sail(winch) servo's, the specs indicate they rotate 3.5 turns when normaly driven, normal servo's then do a 1/4 turn.
With the arduino ServoTimer1 library I can get upto 9 rotations, normal servo's get 1/2 turn.
Instead of an arm, my servo's have a gear that drives another gear, thus obtaining a 3 or 5x reduction and 3/5 x more power altough they are 3/5 x slower, it takes 15 seconds from one end to the other.
So I get more than 180 degrees, would it possible to modify the library to get 0-360 degrees? or even 360.0 degrees (using 3600 to avoid floating point math) to get higher precision?
I tried to replace all 180's to 360 in the library and the .h file but the servo goes crazy when I drive them over 180 degrees, what else should I modify?
As it stands, I think you'll just have to send in values with the right reduction factor, and get less precision. For example, if you want to move to 720 degrees, but have a 5x reduction gear installed, you just position the servo to (720 / 5) instead of trying to bend the library to understand the number 720.
It might be nice for the servo library to have an optional "reduction" argument, but since you could have all sorts of weird gears installed on a servo, like a 3.82x reduction, it would be hard to manage without having to use floating point. (Using any floating point math takes an additional ~2KB of program space.)
That was an old post, Erik posted in [u]this thread[/u] that he is now using ServoTimer2 .
Erik, you can use the map function to scale values from 0 to 360 to the values needed by the servo library. You will need to play around with the min and max values to get the exact range you want, but the map function that returns values suitable for ServoTimer1 would be:
map( postion, 0,360, 750, 2250); // this returns pulse widths between 750 and 2250 us for inputs ranging from 0 to 360 degrees.
See the Arduino reference page for more info on map
Yup, the map() function is a plain linterp or linear interpolation. It comes out the same in this case, numerically. It's more flexible if you have a strange conversion that you can express from empirical measurements instead of design components. I just liked the method of actually using design numbers (like "5x reduction") to express the mapping directly.
Didn't notice the other posts, I was just looking for recent servo related posts to read through.