Society of Robots - Robot Forum

Software => Software => Topic started by: benji on January 30, 2008, 05:12:34 PM

Title: servo problem
Post by: benji on January 30, 2008, 05:12:34 PM
i wrote this little code to turn my servo to -90

Code: [Select]

while (1)
      {                       
      PORTD.7 = 1;
      delay_us(200);
      delay_us(200);
      delay_us(200);
      delay_us(200);
      delay_us(100);
      PORTD.7 = 0;
      delay_ms(19);
      delay_us(100);}

i also made sure that the portd is an out and i did include the delay library and the xtal freq is set right,,,
problem is that the servo is turning into +90 with jerky steps,, somthin is wrong,,
anyone can help?
Title: Re: servo problem
Post by: Admin on February 01, 2008, 02:53:49 PM
Your delay is .9ms . . . make it to 1.4ms and see if it centers.

If it doesn't center then there is something else wrong with your code . . .
Title: Re: servo problem
Post by: benji on February 01, 2008, 03:53:46 PM
Quote
Your delay is .9ms .

thats the pulse width to make it turn to -90 i suppose
Title: Re: servo problem
Post by: Admin on February 02, 2008, 09:34:25 AM
Yea this is just to verify that your clock is what you think it is.
Title: Re: servo problem
Post by: benji on February 04, 2008, 05:05:19 PM
ill do this once i get my programmer pcb back,,
anyways i was thinking ,,im feeding my servo from a 6 volt battery but this batter cant provide more than 300mA but anyways im not putting any load on the servo,would this affect its motion?
and by the way, should the micro and the servo share the same ground?
Title: Re: servo problem
Post by: Admin on February 06, 2008, 12:22:26 PM
So what would happen if your servo requires 400mA, your microcontroller requires 20mA, and your battery can only supply 300mA?

I'm sure you can figure out the problem there ;)

Quote
should the micro and the servo share the same ground?
yes! keep your grounds common!
Title: Re: servo problem
Post by: benji on February 06, 2008, 04:14:23 PM
Quote
So what would happen if your servo requires 400mA,

that was actually the heart of my question
would my servo require such big current when operating with no mechanical loads?

i jus wanna use this battery when i check my codes with the motor with no loads at all
Title: Re: servo problem
Post by: Admin on February 07, 2008, 09:25:58 AM
Well if your motor requires 400mA and it only gets 290mA, its obviously going to be much weaker/slower.

And if your microcontroller requires 20mA but only gets 10mA, it just won't work, or will act very strangely.
Title: Re: servo problem
Post by: benji on February 11, 2008, 07:55:25 AM
hey folks, i jus hav a lil question
what happens when loading the servo motor with a very big load that it cant push?? would it burn?
Title: Re: servo problem
Post by: gmatkins on February 11, 2008, 08:26:57 AM
It "stalls". That means it draws a whole heap of current, but doesn't actually move. Unless I'm way off this shouldn't set it on fire or anything. Basically the rotor of the motor is held in a static position, which means after time the coil that makes the motor move will just behave like any other piece of wire.
Title: Re: servo problem
Post by: benji on February 11, 2008, 04:32:56 PM
well does this mean that the motor would be to trash? or it will still work after this but with less performance?
Title: Re: servo problem
Post by: Admin on February 11, 2008, 07:55:45 PM
If a motor has huge amounts of current, it will heat up.

If it heats up faster than it cools from the air around it, then the temperature will rise.

High temperatures will cause the motor coils to melt/fuse, and the motor driver inside it to fry/crack.

Servos are designed to take abuse, but not forever.

In short, if you stall a motor, you reduce the lifetime until its been 'trashed' (destroyed, hence you throw it away in the trash).
Title: Re: servo problem
Post by: TrickyNekro on February 12, 2008, 01:00:55 AM
In short, if you stall a motor, you reduce the lifetime until its been 'trashed' (destroyed, hence you throw it away in the trash).

But still!!! It has a nice small ESC on it!!!
You probably be a able to drive a small hobby - toy motor with the dead servo's electronics!!! (forward / backward)

And as mentioned before... servos can handle a lot abuse... but just don't over do it...
Also keep the gear box and try to find a motor fitting to replace the old-burned motor... This will reduce the whole maintenance cost of your project-robot
Title: Re: servo problem
Post by: airman00 on February 12, 2008, 10:55:25 PM
In short, if you stall a motor, you reduce the lifetime until its been 'trashed' (destroyed, hence you throw it away in the trash).

But still!!! It has a nice small ESC on it!!!
You probably be a able to drive a small hobby - toy motor with the dead servo's electronics!!! (forward / backward)

And as mentioned before... servos can handle a lot abuse... but just don't over do it...
Also keep the gear box and try to find a motor fitting to replace the old-burned motor... This will reduce the whole maintenance cost of your project-robot

Small hobby motors fit inside standard servos and can replace the previous motor in there
Title: Re: servo problem
Post by: benji on February 15, 2008, 05:22:30 AM
i got to turn my servo from -90 to +90 and +90 to -90 and so on,, but thats the servo speed (the one written on it)
so changing the PWM directly would let your servo operate at its maximum speed.
i dont want to move that fast , i want it to take longer, so should i change the PWM gradually?
wouldnt that by too much coding?
Title: Re: servo problem
Post by: Admin on February 15, 2008, 12:13:05 PM
Quote
i want it to take longer, so should i change the PWM gradually?
sure . . . it will be easy/obvious when you try it
Title: Re: servo problem
Post by: benji on February 22, 2008, 06:14:43 AM
well i did give a 1.5 ms on pwm and the servo is centered
,i then gave it a 2.1 ms on pwm (supposed to go to +90(datasheet)), it went to about +45
,, any one can give me the +90 and -90 pwms for the hitec HS-322HD servo?