Pages: 1 [2]   Go Down
Author Topic: Slowing down servos. How to write it into the program.  (Read 1501 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
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.

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

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
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Writing Arduino code is fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9686
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The below might be of interest.

http://arduino.cc/forum/index.php?topic=61586.0
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 499
Posts: 19070
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2]   Go Up
Jump to: