Pages: [1]   Go Down
Author Topic: Servo - convert writeMicroseconds to write angle  (Read 743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone know the math  to figure out how to get the servo write() angle out of the writeMicroseconds number?

Thank you in advance! ^^
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50507
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does anyone know the math  to figure out how to get the servo write() angle out of the writeMicroseconds number?
Why do you need to? The process is exactly the same as mapping from angle to microseconds, except that the ranges are swapped.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26538
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If in doubt, look at the source.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And in reality the servo library mapping is a crude assumption on the part of the servo library because it assumes all servos have the same physical positioning range using the same minimum and maximum pulse width values, which is simply not the case.

 If one wants servo.write(degrees) to accurately move the servo in real degree steps then they must carefully test their specific servo(s) and supply the servo library with the correct minimum and maximum pulse widths and build their own mapping to the physical travel limits for the servos being used. servo.writeMicroseconds() is your friend to gain the information needed to have well characterized servo movements possible in your projects.

Lefty
Logged

Pages: [1]   Go Up
Jump to: