Go Down

Topic: Slowing down servos. How to write it into the program. (Read 1 time) previous topic - next topic

AWOL

You haven't annoyed us, but please bear with us when we're trying to decide at what level to pitch solutions.
I'm assuming that you're a modeller, and most modellers I know like to build up to a solution themselves, rather than being given the completed article.
"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.

ash901226

i think my way of doing if it is just one servo to control

first i would declare a variable Current position
then i would declare a variable called target position
then i would make a function
in that function i would use an idea from blink without delay to increment the current position
if the current position still haven reach target loop again until it does
when it does keep the value of current position and then stop

retrolefty


i think my way of doing if it is just one servo to control

first i would declare a variable Current position
then i would declare a variable called target position
then i would make a function
in that function i would use an idea from blink without delay to increment the current position
if the current position still haven reach target loop again until it does
when it does keep the value of current position and then stop


The fundamental problem with that is that there is no feedback from the servo as to what position it presently is at if moving, from how far it has progressed from the previous position command given, and when it finally reaches the desired new position.

Servos have different speeds and speed can be effected by the amount of mechanical load placed on the servo. So one has to have a pretty well priory worked out 'characterization' for the specific servo under it's real world load condition, to even be able to estimate approximate position attained Vs time elapsed from last position command to new desired position.

It would be nice to have a higher order servo.write function something like:

moveServo(lastPosition, newPosition, step_Size_to_use, total_desired_Elapsed_time_for_completion)

But it would need to be non-blocking with some way to test when the function as completed? Probably really needs to be an addition integrated with the existing servo library.

Lefty

ash901226



i think my way of doing if it is just one servo to control

first i would declare a variable Current position
then i would declare a variable called target position
then i would make a function
in that function i would use an idea from blink without delay to increment the current position
if the current position still haven reach target loop again until it does
when it does keep the value of current position and then stop


The fundamental problem with that is that there is no feedback from the servo as to what position it presently is at if moving, from how far it has progressed from the previous position command given, and when it finally reaches the desired new position.

Servos have different speeds and speed can be effected by the amount of mechanical load placed on the servo. So one has to have a pretty well priory worked out 'characterization' for the specific servo under it's real world load condition, to even be able to estimate approximate position attained Vs time elapsed from last position command to new desired position.

It would be nice to have a higher order servo.write function something like:

moveServo(lastPosition, newPosition, step_Size_to_use, total_desired_Elapsed_time_for_completion)

But it would need to be non-blocking with some way to test when the function as completed? Probably really needs to be an addition integrated with the existing servo library.

Lefty




i know that a servo will not return a value, but in this case i would think that the by increment/decrement   the value of current position will atleast give the arduino of what is the current position of the servo rite now... i guess you could say that its the same as how we control a stepper motor for a cnc machine... we do not know the actual position/ how much the stepper have rotate. but atleast we have some basic idea of where it should be....
btw retrolefty one thing that would say about servo that is better then a stepper motor is that if a stepper motor get stall, it will loose step and making the position we thick we at and the actual be false.
but for a servo once it receive a command to go to that point, the servo circuitry will make sure it reach that point. so we could actually safely asume that what we think we at and where it is actually is might just be true most of the time.(i say most of the time is due to unforeseen behavior).

and retrolefty if you dont mind hacking your servo to get angular measurement heres 2 link that might be useful
http://forums.trossenrobotics.com/tutorials/how-to-diy-128/get-position-feedback-from-a-standard-hobby-servo-3279/ and
http://www.lynxmotion.net/viewtopic.php?f=2&t=2748

sierrasmith71

Have a look at.... http://www.bajdi.com/arduino-servo-sweep/  for an article describing the VarSpeedServo library for Arduino..I have used this library and it works very well indeed!!

Best regards and good luck

David Garrison

zoomkat

The below might be of interest.

http://arduino.cc/forum/index.php?topic=61586.0
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Nick Gammon


It would really help you understand what your code is doing if you put every { on a new line, and used Tools + Auto Format.

Code that jerks
                all over the
    page is very
hard                     to read.


I love answers like this because they fall into the "show, don't tell" category.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

briggsy

Gentleman,
                  I used the VarSpeedServo from the library and with a bit of tinkering it works well. Thank you for all your help.

Go Up