Control Servo Speed

Thread Starter

wk7au

Joined Apr 16, 2013
15
How do I control the speed of the servo ??

As an example , it took 2 seconds for my servo to moved from 0.5ms position to 1.5ms AND NOW I wanted to make it only spend 4 seconds to move.

I tried to add delays for it, it is some sort looks like this...-->

RB5=1;
DelayUs(1.3);

RB5=0;
DelayUS(18.7);

RB5=1;
DelayUs(1.4);

RB5=0;
DelayUS(18.6);

RB5=1;
DelayUs(1.5);

RB5=0;
DelayUS(18.5);

With this program, it isn't moving smoothly and yeah not nice
SO any suggestion for me to control the time taken for the servos to move or can I just say the rotation speed of the servos ?

THANK YOU :)
 

tshuck

Joined Oct 18, 2012
3,535
increase the granularity of your commands (provided it is still within the ability for the RC servo's control system to decipher) and increase the number of points it moves to.
 

Markd77

Joined Sep 7, 2009
2,806
It would be nice to have a function that you can just pass speed and target position to, and then it would calculate the intermediate positions for you.
Also why have you called the millisecond delay DelayUS? Surely Delayms would make more sense.
 

tshuck

Joined Oct 18, 2012
3,535
It would be nice to have a function that you can just pass speed and target position to, and then it would calculate the intermediate positions for you.
Also why have you called the millisecond delay DelayUS? Surely Delayms would make more sense.
Since the RC servo is controlled via a pulse width between 1ms and 2ms, sub-millisecond delays are appropriate.
 

Thread Starter

wk7au

Joined Apr 16, 2013
15
It would be nice to have a function that you can just pass speed and target position to, and then it would calculate the intermediate positions for you.
Also why have you called the millisecond delay DelayUS? Surely Delayms would make more sense.

ya it was ms, typo anyway.
 

Thread Starter

wk7au

Joined Apr 16, 2013
15
increase the granularity of your commands (provided it is still within the ability for the RC servo's control system to decipher) and increase the number of points it moves to.
sorry i don't really understand.My program just some sort looks like this..
for(i=0;i<50;i++)
{
RB5=1;
DelayMs(1.5);

RB5=0;
DelayMs(18.5);
}

I did modified this for(i=0;i<50;i++) to i<10 or watever but it doesn't worked well too.
 

ErnieM

Joined Apr 24, 2011
8,019
With it being called DelayUs, I'd have expected :
DelayUs(1300), etc
or
Delayms(1.3)
Maybe it's just me....
Passing a float to a routine that expects an integer is not a good idea. If it compiles at all it will give you unintended results.
 
Top