
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:
" 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?
dave, I wrote a pretty detailed response about how all servos work the same
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
Here's how you can do it correctly... (similar to what Richard had responded with)
Init Script
Movement Script
As promised, here are videos that I created which explain how a servo works and what PWM is...
I feel kinda stupid here. Sorry I should have proof read my code. The way I actually have it written is just like bhuston presented it. I cut and pasted and for some odd reasion that screwy code posted. I did notice thst ez robot web site went down in the middle of my post. Maybe thats what happened. Thanks for the help and I'll try out the various examples you guys took the time to show me.
Told you we'd figure it out
I've been doing it the way bhouston posted as well. No where in the manual did I see different. I believe the manual also says 1-100 for speed where in actuality it is 1-10. Maybe this will clear some things up on my end also
For reference, here is the manual for servospeed which mentions 0 - 10.
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
Servo Speed is 0 to 10. From the script manual: "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
Thanks for the basic lesson in scripting 101 DJ.
Also thanks everyone else who chimed in wanting to help. It good to know there are good people out there wanting to help.
After watching the first vid DJ shared I gotta say I miss the heartbeat pulse.