Award
Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Servo Speed - Only Fast, Medium And Dead Slow Available

Assistance Requested

Help Dave Schulpius with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Dave Schulpius claims to have checked these sources:
 
#1

Hi gang,

I have no problem getting servos to change speed using the ServoSpeed command in scripts and if I don't set the speed they run at 100%. However, I've had an issue with servos not using the full speed range available. In the scripting manual for this command it tells us:

Code:

" The servo speed is a number between 0 (fastest) and 10 (slowest)". 


With some of my smaller servos like the Micro sizes Hitec HS-85MG or the Mini HS-225MG I only have a couple speed settings with the ServoSpeed command that works: 0 is full speed, 1 is 1/2 speed and 2 will let the servos move as slow as the minute hand of a clock. Anything above that is as good as stop. I have noticed with other bigger servos I'll get better speed changes as I go toward 10.

Is this normal with different brands or sizes of servos? Is there any way to stretch this out so I can get better speed choices between 0 and 10?

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

This will vary from one servo to another. Not every servo has the same resolution. Also the servos that have better resolution are digital and usually more expensive. A cheap analog servo may only respond to a few position speeds. I have tried some of the mini servos I have under continuous rotation and servo controller and they seem to vary in sensitivity. I look forward to see what DJ says about it.

#3

@Dave... Just in case you didn't know (which you probably do and not sure it will actually affect your results any).... You have to set an initial servo position before setting the speed. You do this once, then you can adjust servo speed as you wish... However, if you use release then you will have to reset servo position then speed again....

Code:


servo(D0,90) # initial servo position
servoSpeed(D0,5) # Now you can set the speed

#4

Dave I noticed it too. As an FYI I use Torxis servos for head pan/tilt. I have really limited my posting on this forum as of late because well I don't find it a comfortable experience. Thanks Chris

#5

Thanks @Josh, I was afraid of that. I dont like to use the digital servos too often as they whine when holding load. I know I can swap out the control board with a controller that switches at sonic speed to quite it down but that's not practical sometimes and it's expensive.

@Richard, thanks, I did know that but I wasnt aware of having to reset them after I've released. Good to know. Thanks for the guidance.

@kamaroman68, good to know others are experiencing the thing with the servo. So sorry you don't feel comfortable around here. I guess that's inevitable when there are so many personalities around and each with their own agenda. I'm glad your still around though and willing to help out a guy like me from time to time. Winky

#6

There is no way I can think of a servo not responding to the speed - because the speed has little to do with the servo. If the servo is not responding well to the speed, I would assume the code is incorrectly written or the servo is incompatible with all other servos Smile

The speed literally just ramps the pwm from position A to position B over time. The servo is unaware of this happening - because this is how a servo works.

You can post your code example and someone can help you fix it? I'm sure it'll be easy Smile

If either of you are having doubts, I highly recommend watching the two videos on this page: http://www.ez-robot.com/Tutorials/Help.aspx?id=168

One of the videos explains how a servo works with pwm. The other video shows how the pwm ramp works for servo speed. The sad part is, if the servo is not able to "respond to a ramping pwm", then I don't know how it would move at all, ever.

#7

Sure DJ. The code I'm using are below . However I am getting the servo to move it's just that when the speed is set higher than the number two setting it moves so slow you can't see it. I'm using analog Hitec HS-85MG and the Mini HS-225MG so they aren't cheaply made servos. Not as quality as the ones you sell in the EZ Robot store but still well respected. Could it be that EZ Builder is optimized fro the custom servos you guys sell?

Here's the code I'm using. :

Code:


Servo(D0, 25)
ServoSServoSpeed(D0, 0)

Sleep(4000)

Servo(D0, 160)
ServoSServoSpeed(D0, 1)

Sleep(4000)

Servo(D0, 90)
ServoSServoSpeed(D0, 3)

#8

I think the code should be:

Code:


Servo(D0,90)
ServoSpeed(D0,3)

#9

@Dave
.... also, the call for servo speed should come before the servo move command...

Code:


ServoSpeed(D0, 0)
Servo(D0, 25)

Sleep(4000)

ServoSpeed(D0, 1)
Servo(D0, 160)

Sleep(4000)

ServoSpeed(D0, 3)
Servo(D0, 90)

#10

dave, I wrote a pretty detailed response about how all servos work the same Smile There is no such thing as a servo that won't work the ez-b, because the servo works by receiving a PWM (pulse). I highly recommend watching the servo videos, i'll post them in this response to make it easier.

In short, the servo moves to position based on the PWM that it receives from the controller (in this case, the ez-b). The "servo speed" is how quickly the ez-b switches from the Previous PWM to the New PWM. If it is set for 0 (zero), the PWM is switched to the New PWM instantly. If it is set to a number other than 0 (zero), the PWM gradually grows or shrinks to the desired position.

As for the code, thank you for posting it. The manual explains how the Servo() needs to be executed BEFORE ServoSpeed() on Initialization. I will modify the manual right now to read ONLY BEFORE initialization. Once you have initialized the servo and the speed, you will always set the ServoSpeed() before the Servo().

Currently, your code is asking the servo to move to a position, and then changing to a speed - which doesn't really make sense. It's kind of like holding the gas pedal in your car and then throwing it in gear Smile

Here's how you can do it correctly... (similar to what Richard had responded with)

Init Script

Code:


# Initialize the servo. The order of this init is only done once when connection is established to the ez-b.
Servo(D0, 25)

# Sleep doesn't always need to be here. I like to ensure the servo has moved into position before configuring additional parameters. Easier for debugging
sleep(200)

# Set the speed of this servo
ServoSpeed(D0, 0)



Movement Script

Code:


:loop

# This will move the servo instantly
ServoSpeed(D0, 0)
Servo(D0, 25)

Sleep(4000)

# Move servo slower
ServoSpeed(D0, 1)
Servo(D0, 160)

Sleep(4000)

# Move servo slower
ServoSpeed(D0, 3)
Servo(D0, 90)

Sleep(4000)

# Move servo even slower
ServoSpeed(D0, 4)
Servo(D0, 10)

Sleep(4000)

goto(loop)




As promised, here are videos that I created which explain how a servo works and what PWM is...