Software > Software

Servo Half Speed Code

(1/3) > >>

Sylvestre:
Hello,

I was wondering if someone could look at my code to see if its correct for running servos (HS-625MG) at half speed.  These are hacked for continuous rotation.  The center is 1500 and the range is 600 usec to 2400 usec

http://www.servocity.com/html/hs-625mg_ultra_speed.html


--- Code: ---else if (tempbyte==leftwheel)
{
act_setSpeed(&servo,1050);

    return 0;
}
else if (tempbyte==rightwheel)
{
act_setSpeed(&servo,1950);

    return 0;
}
--- End code ---

Thankss

Gertlex:
Other than some funky indentation, looks fine to me.

It occurs to me that I'm not sure whether continuous rotation servos' speeds vary linearly with the PWM... but it's probably close enough.

Webbot:
Looks like you are using WebbotLib - in which the second parameter to the 'act_setSpeed' is wrong (read the documentation). Its not the pulse length but rather a number between -127 and +127.

So just use say -64 and 64 instead of 1050 and 1950.

Sylvestre:
ok thank you for the help!

Sylvestre:
Ok I just tested.  I forgot to mention that I want this one servo (my commands are bit misleading, I will change them) to rotate clockwise and counterclockwise.   so when tempbyte = 1, rotate clockwise.  when tempbyte = 2 , rotate counterclockwise

When I tested with the code below, when 'leftwheel' was received, it just set to halfspeed, and then when 'right wheel' was received, it just went full speed.  it might've been the other way around. so how would i set to rotate clockwise and counterclockwise.  I thought thats what this was doing with the code below

--- Code: ---else if (tempbyte==leftwheel)
{
act_setSpeed(&servo,-64);

    return 0;
}
else if (tempbyte==rightwheel)
{
act_setSpeed(&servo,64);

    return 0;
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version