Author Topic: Noob question ...Free running servos?  (Read 1931 times)

0 Members and 1 Guest are viewing this topic.

Offline Hasan999Topic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 1
Noob question ...Free running servos?
« on: December 31, 2009, 06:23:33 PM »
Axon Microcontroller....

I built a 4 legged Robot... I realize the fact now that when I give commands to servos, they will hold tight and move accordingly, but otherwise they are free to move ! (i.e. my Dog-Robot will fall down)

how do I make the servos be fixed at their positions throughout the program.

I'm using servo(PORTA,1,X); commands for servos, not PWM or any timers.

btw, I already tried giving the same servo command with the fixed position (continuously in background), but then the servo vibrates on that position ! (I dont want my robot to be shivering  :-\ ) - how do I make the servo remain at one position, tight, while it waits for its next command.

Thanks..
« Last Edit: December 31, 2009, 06:34:25 PM by Hasan999 »

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Noob question ...Free running servos?
« Reply #1 on: December 31, 2009, 07:49:02 PM »
Post your code.

To get a servo to hold it's position, it has to continuously get a pulse for that position. If the delay is too long between pulses, it will 'let go' causing vibration. You must have something causing this delay.

Offline Hasan999Topic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 1
Re: Noob question ...Free running servos?
« Reply #2 on: January 01, 2010, 03:39:15 AM »
Quote
Post your code.

[here's the main part of the programming, without showing the #define etc, cuz its kinda long]

int time=0;

for(lp=0; lp<5000; lp++){

delay_ms(20); SSS; time+=20; // SSS controls each servo when it receives command in Switch, below:

switch(time) {  // time in ms

case 2000: s1(135);break    // at time = 2s, Move servo1 to 135 degrees
case 6000: s2(135);break    // at time = 6s, Move servo2 to 135 degrees
// and so on..
};}


Quote
You must have something causing this delay

Yea.. a delay of 20ms  :P

Quote
To get a servo to hold it's position, it has to continuously get a pulse for that position

I would have done that, if I had not read this in "Axon function list" Source_code section:
http://www.societyofrobots.com/axon/axon_function_list.shtml

Remember to NOT send a command to a servo more than once every 10 to 20ms, or it could potentially damage the servo. Adding a few ms delay after your servo code would be a quick safe solution.


What to do now?... I have 24 servos !... I can't risk a damage to any, i've already built my robot.

Thanks
« Last Edit: January 01, 2010, 03:54:54 AM by Hasan999 »

Offline z.s.tar.gz

  • Supreme Robot
  • *****
  • Posts: 540
  • Helpful? 5
  • Linux Guru
Re: Noob question ...Free running servos?
« Reply #3 on: January 01, 2010, 08:55:03 AM »
If push comes to shove you can always run them through some external gearing like http://www.societyofrobots.com/mechanics_gears.shtml#wormgears
Just have the servos turn the top one, and the bottom one can't slip.
Save yourself the typing. Just call me Zach.

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Noob question ...Free running servos?
« Reply #4 on: January 01, 2010, 11:00:02 AM »
Quote
Post your code.
[here's the main part of the programming, without showing the #define etc, cuz its kinda long]

int time=0;

for(lp=0; lp<5000; lp++){

delay_ms(20); SSS; time+=20; // SSS controls each servo when it receives command in Switch, below:

switch(time) {  // time in ms

case 2000: s1(135);break    // at time = 2s, Move servo1 to 135 degrees
case 6000: s2(135);break    // at time = 6s, Move servo2 to 135 degrees
// and so on..
};}


Quote
You must have something causing this delay
Yea.. a delay of 20ms  :P


Thanks

You have a delay ALOT longer then 20ms. if you are looping that switch statement, then there is a delay of seconds in-between servo pulses.

I have never used the admin's library for servo control. I have always used hardware timers which time the servos exactly right to hold steady.

Have you tried a program with nothing but

Code: [Select]
for(;;){
s1(135);
delay_ms(20);
}

That should satisfy the 20ms requirement. See if that holds the servo steady.
« Last Edit: January 01, 2010, 11:03:27 AM by madsci1016 »

Offline Hasan999Topic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 1
Re: Noob question ...Free running servos?
« Reply #5 on: January 01, 2010, 11:20:33 AM »
I tried...with:

for(int i=0; !button_pressed(); i++){
servo(PORTE,7,700);
delay_ms(20);}


still it vibrates on that position !.. pretty noticable and that will eventually make my robot shivering !

however, i tried the same with delay_ms(10);  ....it does vibrate, but its hardly noticable !... should I use this?..

Question now is... will a delay of less than 20ms damage the Servo? [HS-422]

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Noob question ...Free running servos?
« Reply #6 on: January 01, 2010, 12:26:45 PM »
That is a question for someone who knows Admin's library better. Have you tried Webbot's library?

I do know that a friend of mine was using an Axon to control a arm that had 8 servos, and ended up using a Servo controller board like this one

http://www.lynxmotion.com/Product.aspx?productID=395&CategoryID=52

because he had trouble using the axon directly.

I would find it very surprising if you are able to control 24 servos using software PWM and get smooth steady results, at least without taking up all your cycles and can't do any other operations.

Offline Hasan999Topic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 1
Re: Noob question ...Free running servos?
« Reply #7 on: January 01, 2010, 01:10:05 PM »
Quote
That is a question for someone who knows Admin's library better.
I'm waiting for Admin himself... I hope he posts here... ::)

Quote
Have you tried Webbot's library?
Nope.. just went through it, didn't understand  ;D

Quote
SSC-32 Servo controller
I was first about to buy that one actually, but didn't buy just because it cannot store any programming !

Quote
if you are able to control 24 servos using software PWM
Actually, without PWM  ;) ...and it works ! (except for, again, Servos need to be held fixed)

Quote
because he had trouble using the axon directly.
Hey... I was wondering, how come the RobotRealm Software could control the Servos so efficiently !... i.e. Once a servo is enabled, its position is fixed !... and I checked its Servo_Controller.c attached..(although I couldn't understand much, but) I'm pretty sure it is done using normal Servo(Port,#,Position) method, and I can't see any "delay" commands either ! ...So does that mean, for( ; ; ) { servo(PORTA,1,700); } without delay, would not damage the servo?
« Last Edit: January 01, 2010, 01:16:02 PM by Hasan999 »

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Noob question ...Free running servos?
« Reply #8 on: January 01, 2010, 01:31:25 PM »
I think you should do a little reading on how servos work. They are PWM devices. if you got a servo to move, then you sent it a PWM signal. Your problem is you are not sending a 'continuous' PWM signal.

The controller, is just that, a controller, It doesn't store programming, you still need a MCU (like the Axon) to send it Serial commands and it translates commands into servo actions. It sends a 'continuous' PWM signal to the servos, with the last position requested until it gets a new command. This is how it "holds' the servo so efficiently. 

If you only send a single pulse of a PWM signal, then the servo will start to go to that position, but after a few hundred ms, it will shut off and spin freely. This is why you are trying to achieve a 'continuous' signal to keep the servo on.

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Noob question ...Free running servos?
« Reply #9 on: January 01, 2010, 01:43:08 PM »
Read this part of the code you posted. This is why it works and your code does not.

"The servo timing requirement requires that the system not be interrupted during
*   the critical first phase timing of servos otherwise servo cliches will occur.
*
*   ....
*   The timing of the servos needs to be done in a staggered fashion. You cannot
*    turn on the servo, wait and then turn it off as with 29 servos you will quickly
*   exceed the 20ms base period of most servos. Thus the technique instead will
*   turn on all servos at once and then independantly turn off those servos in
*   succession based on their timing period. For example, if you have two seros
*   at 1ms and 1.5ms phase you would turn both on, wait for 1ms, turn off the first
*   servo, then wait 0.5ms and finally turn off the second. This requires the timing
*    to be sorted in an ascending manner such that the delay from one servo to the
*   next can be easily calculated. While ideally this would be implemented in a
*   parallel manner the short delay due to a single thread is acceptible to most
*   servos."


I.E. if you wait longer then 20ms to send another pulse, your servo will shut off, spin freely, and cause your robot to shake.
« Last Edit: January 01, 2010, 01:45:22 PM by madsci1016 »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Noob question ...Free running servos?
« Reply #10 on: January 05, 2010, 01:02:34 AM »
My typical code only takes a few ms, so as long as servo commands are in a loop, I never have any problems.

If you have 24 servos, thats too many for PWM.

If you pulse just one servo at a time, and you have 24 servos, the smallest time the loop will take is 24ms (1 ms each). This means you don't need to add any additional delays. However, it'll also take up to 48ms (2 ms each), which could slow down any complex algorithms. But I doubt your algorithms require much processing, and on average you'll find a cycle takes like ~35ms. No big deal at all.

But again, it depends on what servo type you are using.

You could also look into WebbotLib, which uses interrupts instead to control servos.

 


Get Your Ad Here