
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?
@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.
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
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.
Here's the code I'm using. :
Code:
Code:
.... also, the call for servo speed should come before the servo move command...
Code:
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
Here's how you can do it correctly... (similar to what Richard had responded with)
Init Script
Code:
Movement Script
Code:
As promised, here are videos that I created which explain how a servo works and what PWM is...
As for understand the order of commands when programming... It's best to look at peograming as a list of instructions - is what they are anyway.
So think of it like this... Every command in a program list is executed from top to bottom. Similar to how you read a book. Each word or command or instruction is in order of execution.
Always put commands in the order you want them executed. It's once you've done it a few times
"The servo speed is a number between 0 (fastest) and 10 (slowest)"
PWM is 0 to 100 (0 off to 100 full)
There are also speed variables thay are associated with movement panels that are 0 to 255, but I am not sure whay they actually set other than variables.
Alan
Also thanks everyone else who chimed in wanting to help. It good to know there are good people out there wanting to help.
My problem is I am trying to control LEDs (eyes) instead of servos. The LEDs are directly connected to servo ports, controlled using PWM scripting. Works great to turn on-off and control intensity, but I can't figure out how to slow down the on-off. Tried initializing servo (LED) [Servo(d9, 90)], followed by setting the speed [ServoSpeed(d9, 0-9)], then turning on and off [PWM(d9,0-100]. The result is always switching on-off fast.
What am I missing ?
You don't use servo commands with LEDs, just PWM.
Here are two scripts to ramp up and down an LED on port D11. You can change how fast it ramps by adjusting the sleep and by adding or subtracting more than 1 from the current PWM variable
Code:
Code:
Alan
Alan
You should just quit your day job and hang out here on the forum and help the masses. You don't really need to eat and have a roof over your head, do you?
Alan
The moral of the story is yes, I am lazy... I hated working so I saved my money, bought stock/investments and stayed out of debt. All so I could stop work as soon as possible... I traded "things" for free time.... So long to the rat race...