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?
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.
@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....
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
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.
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
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: https://synthiam.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.
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 ARC is optimized fro the custom servos you guys sell?
Here's the code I'm using. :
I think the code should be:
@Dave .... also, the call for servo speed should come before the servo move command...
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.
Awesome detailed response @DJ.
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 ?
kazabond
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
Alan
Alan, I thought you had a HoneyDo list to take care of? What are you doing hanging out here on the forum all morning? Better not let the wife catch you helping all these other people and ignoring her needs.
Worse than that, I am supposed to be at work. I have a huge document to finish, but I can't get my head in it so I keep browsing the forum and seeing questions I can answer.....
Alan
Alan, it's guys like you that make this hobby fun for the rest of us. !
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?
heh.... I wish I could do nothing but robotics all day. I enjoy my job, but also looking forward to retirement (in 17 years, after the house is paid off....) so I can spend my days playing.
Alan
I ran my own business and made some decent money... My friends used to comment... "hey, why don't you buy a nice car now that you have the money?" or you should buy a bigger house" ... you have the money so live it up, trips etc...... I usually respond not a chance... You see I am really lazy... They just looked at me puzzled... Fast forward to age 45... My house is paid off, no debt with decent investments... I am pretty much retired so I do get to play with robots most of the day... All my other friends are still doing the 9 to 5 and still paying for their houses and cars and things...
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...