Servo timing resolution question
Bill Henning
Posts: 6,445
Hi,
I am writing a Basic compiler for the Propeller, and I want to build in support for servo's - so I thought this would be a good forum to do a "sanity check" on my understanding of servo's.
My understanding is that (analog) servo's work on a PWM basis, with one full cycle being 20ms, most of which is at logic '0', and (typically) 1.5ms to 2.5ms is at logic '1', representing -90' to 90' with 1.5s being at the center position. (IS THIS CORRECT?)
I also understand that some servo's use a different range, and I have seen references for servo's that can take 0.5ms to 2.5ms range - and of course there are continuous rotation servos as well. I have ordered a fair assortment of servo's from Ebay, and plan to thoroughly test the code I end up implementing. I currently have Parallax standard & continuous servos, MG995's, and a small 9g servo.
I'd like to know:
Minimum necessary servo timing resulution: 10us? 5us? 2us? 1us?
Good enough servo timing resulution: 10us? 5us? 2us? 1us?
Nice to have but not needed timing resolution: 10us? 5us? 2us? 1us?
I notice that the BS2 specifies servo resolution in 2us increments, however given the mechanical nature of servos, and the 20ms update rate, is that truly useful or needed?
I appreciate any and all feedback!
(I will be trying the servo's on a BS2 pro development board and my own Propteus board mikronauts.com/2009/08/14/propteus-is-born/)
Thanks,
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
I am writing a Basic compiler for the Propeller, and I want to build in support for servo's - so I thought this would be a good forum to do a "sanity check" on my understanding of servo's.
My understanding is that (analog) servo's work on a PWM basis, with one full cycle being 20ms, most of which is at logic '0', and (typically) 1.5ms to 2.5ms is at logic '1', representing -90' to 90' with 1.5s being at the center position. (IS THIS CORRECT?)
I also understand that some servo's use a different range, and I have seen references for servo's that can take 0.5ms to 2.5ms range - and of course there are continuous rotation servos as well. I have ordered a fair assortment of servo's from Ebay, and plan to thoroughly test the code I end up implementing. I currently have Parallax standard & continuous servos, MG995's, and a small 9g servo.
I'd like to know:
Minimum necessary servo timing resulution: 10us? 5us? 2us? 1us?
Good enough servo timing resulution: 10us? 5us? 2us? 1us?
Nice to have but not needed timing resolution: 10us? 5us? 2us? 1us?
I notice that the BS2 specifies servo resolution in 2us increments, however given the mechanical nature of servos, and the 20ms update rate, is that truly useful or needed?
I appreciate any and all feedback!
(I will be trying the servo's on a BS2 pro development board and my own Propteus board mikronauts.com/2009/08/14/propteus-is-born/)
Thanks,
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
Comments
Yes, and so do digital servos.
.500 mS to 2.500 mS is enough for full range on most servos. Some will respond to signals outside that range and many will bind before reaching those extremes. If you want to be safe you can limit the range to .900 mS to 2.100 mS.
1 uS resolution is what I prefer. There are some servos that have 1 uS dead band. 2 uS might be ok for most purposes. I would not want to go any higher than that.
There are some specialty servos that use .760 mS as the center in an attempt to get faster response for use in RC helicopter tails. The idea is that with half the pulse width you can send more pulses in a given time frame. I would not be concerned about adding support for those though. That shorter pulse width is supplied by the gyros that the servo is connected to while the gyro receives normal pulses.
Also, 1.500 mS and 1.520 mS are the center settings for servos depending on which brand they are. Futaba uses 1.520 mS, most others use 1.500 mS.
Rich H
p.s. There are some servos that require a negative pulse, logic 1 for most of the time instead of logic 0. I have never had one like that but I know they are out there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
Post Edited (W9GFO) : 9/2/2009 4:50:14 AM GMT
Your resolution will change depending on what range of movement you require from the servo (and how smoothly you need it to pan). If it's capable of turning through 180 degrees and you limit it to 90, the resolution will be correspondingly finer. The resolution will depend upon the range you require and the amount of memory allocated for the timing variable. For instance, one "byte" ranges from 1 to 255. If you use 254 increments of 4 us each, the total range would be 1016 us, i.e. 1500 us +/- 508 us. At increments of 2 us, the range would be 1500 +/- 254 us (double the resolution but half the range).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
Typically a standard hobby servo is insensitive to differences of 4uS and below, but as Chris and I have observed if the error detection window of the servo is straddling the input signal this threshold value can be much lower.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
The Propeller can easily handle 1uS resolution.
If including support for servos in a Basic compiler I would certainly want to have as much control over the servo as a Basic Stamp, meaning 2uS resolution. Better to make it 1 uS for people like me who want the finest possible control.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
Having the finest resolution possible when the device doesn’t require it can waste resources that are better used elsewhere. For example, let’s say you can run 32 servos from the Propeller using 4uS resolution…dropping down to 1uS would require limiting the number of servos down to maybe 8. This is just an example and doesn’t represent any real limitations or numbers, but it does mean the code won’t have time for much else and this could be unnecessary. On the other hand 1uS may not be a problem in Bill’s application if he’s using PASM. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
Anyway, it just opinion. I think he should go for the best resolution possible because someone is likely to need it or make use of it. If 2us or 4uS is all that's possible then that's ok. It would work just fine for the vast majority of users.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Servo Boss, a 12 channel servo tester kit from Gadget Gangster.
Post Edited (W9GFO) : 9/4/2009 7:01:17 PM GMT
I wrote the program for the PDB and set it up so that one button centered the servo, one took it full clockwise and one full CCW. Other buttons were used to step the servo in 2uS increments and I recall having to make several steps just to get the servo to move at all. When it did it took more steps in the opposite direction to get it to move due to dead band. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
I have ordered a number of different servos for testing; I already have some Parallax and MG servos at hand.
For PropellerBasic, I have decided to use 16 bit values for pulse width, and the values will be specified in 1us increments (even if the response is in 2us or other increments) for high-level compatibility.
This will allow me to represent pulse widths from 1us to 65.535ms (0 will mean OFF) and the specific servo drivers can get as close to the requested pulse width as their design allows.
This will allow for high resolution drivers (at 1us) to slow/many servo drivers (at 4us or slower).
Better yet, it will offer "best fit" high level compatibility regardless of the specific servo driver!
W9GF0:
Thank you for the information! I will support at least 2us resolution, and will consider 1us if I have the available cogs to support it.
Sandgroper:
See above - I decided to leave the exact timing resolution up to the low level driver.
Chris Savage:
Thanks Chris. That's kind of what I suspected, and why I decided to pick the collective brains of this group to save testing time.
Beau Schwabe:
Given the mechanical nature of servo's I am not at all surprised by your findings.
Chris Savage:
Totally agreed. With the Prop there are so many choices... using the counters in all eight cogs we can have 16 PWM's with 12.5ns resolution; software solutions are a direct tradeoff between number of PWM/cog and number of cogs used.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller