Author Topic: servo woe......cannot reverse rotation direction  (Read 3550 times)

0 Members and 1 Guest are viewing this topic.

Offline ozbotTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Helpful? 1
servo woe......cannot reverse rotation direction
« on: December 15, 2008, 03:53:27 AM »
Now I have greased up the gears and attempted to use the first tutorial program.  What i've found is that I can only seem to get one direction of rotation.  Am using these lines to test servo:

i=250;
while (i>0)
{
servo_left(x);
i--;
}

Between 40 & 44 in the "servo_left(x)" will give me varying speed, but if I go below 40, instead of a direction reversal, the gears just click slightly forward & back continuosly. This behavior is on both the left and right servo's.  I have not attempted to send PWM by the 1, 1.5, 2 ms, as I do not yet know the code for that.  I have inspected the gear assebly & there are no physical/gearing problems. 
I had replaced the 5K feedback pots (as they were crap quality, lots of drift) with a 2K2 either side as a voltage divider.  If that didnt balance it, I would still be able to forward and back my servo in an offset range, no?

I have had one wheel spontaneously start rotating in the unusable direction once, when not even referred to!  that might indicate a (sporadic) wiring problem, but have gone over it twice now.

Am using an ATMEL ATmega8, have tried 2 different micro's & same results.  Kinda hopin I missed somethin obvious, this is drivin me nuts.......

 
I was so disappointed to learn that half the people I know are under average........but the other half more than make up for it.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: servo woe......cannot reverse rotation direction
« Reply #1 on: December 28, 2008, 01:15:11 AM »
Code: [Select]
i=250;
while (i>0)
{
servo_left(x);
i--;
}

You probably realized this by now, but x doesn't change in that code. Change x to i ;D

Also, make it go from about 10 to 80, and add a delay in it. Otherwise the code will be finished in a fraction of a second.

Offline tristantech

  • Jr. Member
  • **
  • Posts: 34
  • Helpful? 0
    • TristanTech
Re: servo woe......cannot reverse rotation direction
« Reply #2 on: December 29, 2008, 08:39:40 PM »
Try this code I wrote:

Code: [Select]
#include <avr/io.h>
#include <util/delay.h>
int main()
{
int i;
DDRB = 0xff;
PORTB = 0xff;
while(1)
{
//Hold the motor in neutral for 2 seconds (Each signal is 20ms, so repeating that 100 times = 2000 sec

for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(1.5);
PORTB = 0x00;
_delay_ms(18.5);
}
//Turn 90deg clockwise for 2 sec
for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(2);
PORTB = 0x00;
_delay_ms(18);
}
//Turn to -90deg ccw, while passing the neutral state for 2 sec
for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(1);
PORTB = 0x00;
_delay_ms(19);
}
}
return 1;
}

Connect the servo control wire to any pin in PORTB.

Hey! Visit my website @ http://www.tristantech.net

Offline ozbotTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Helpful? 1
Re: servo woe......cannot reverse rotation direction
« Reply #3 on: January 05, 2009, 06:59:02 AM »
"You probably realized this by now, but x doesn't change in that code. Change x to i"
sorry, shoulda been more clear, was testing by putting 44, then 43, 42.... where x is.

anyways, twas a bad servo (mg995=fail) ......replaced it (hobbytech m-2763) and now have my first functional photovore.

I think I put to much heat on the servo control board while soldering on the resistors.

thx all.
I was so disappointed to learn that half the people I know are under average........but the other half more than make up for it.

 


Get Your Ad Here