Society of Robots - Robot Forum

Software => Software => Topic started by: rox2007 on January 14, 2008, 02:08:21 PM

Title: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 02:08:21 PM
Ok i followed the instructions in the modifying servos tutorial but i cant get the part where you stop the gears by moving the pothead.
I keep turning it left and right but it doesnt work.
Please help
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: airman00 on January 14, 2008, 02:30:32 PM
move it slowly and make sure you are giving it the right pulse at the corerct oscillator setting
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 02:31:27 PM
what exactly is the right pulse and oscillator setting for an atmega 168. i am passing 1.5ms on the internal 8Mhz clock
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 02:43:12 PM
i turn and turn and turn. The speed just get's slower or faster. it goes from one extreme to another. fast to slow...slow to fast....theres no midpoint where it just stops
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: airman00 on January 14, 2008, 02:59:14 PM
turn it very slowly and carefully


also try to give it 1.5ms @ 4mhz


what is your code ?
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 03:00:12 PM
#include <avr/io.h>

//Define functions
//======================
void ioinit(void);      //Initializes IO
void delay_ms(uint16_t x); //General purpose delay
void delay_cycles(unsigned long int cycles);
//======================

int main (void)
{
    ioinit(); //Setup IO pins and defaults

    while(1)
    {
      PORTC = 0xFF;
      PORTB = 0xFF;
      PORTD = 0xFF;
      delay_cycles(35);

      PORTC = 0x00;
      PORTB = 0x00;
      PORTD = 0x00;
      delay_cycles(35);

      //delay_cycles(500);
    }
   
    return(0);
}

void ioinit (void)
{
    //1 = output, 0 = input
    DDRB = 0b11111111; //All outputs
    DDRC = 0b11111111; //All outputs
    DDRD = 0b11111110; //PORTD (RX on PD0)
}
//************DELAY FUNCTIONS************
//wait for X amount of cycles (23 cycles is about .992 milliseconds)
//to calculate: 23/.992*(time in milliseconds) = number of cycles
void delay_cycles(unsigned long int cycles)
   {
   while(cycles > 0)
      cycles--;
   }
//***************************************
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 03:03:10 PM
that's my code. i was running at 8mhz and sending 1.5ms
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: airman00 on January 14, 2008, 03:04:02 PM
which servo are you using?
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 03:05:50 PM
HS-311, the ones recommended by the tutorial
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 03:25:33 PM
I finally got it to work...Thanx alot
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: ed1380 on January 14, 2008, 03:27:20 PM
just as i was about to post this
http://www.instructables.com/id/modify-the-hitec-hs-325-servo-for-continuous-rotat/
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: Rebelgium on January 14, 2008, 03:55:44 PM
Help people with the same problem, tell us what was the problem and how you fixed it.
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on January 14, 2008, 04:10:49 PM
well, i sent a 1.5ms pulse and ran my atmega168 at 4 mhz...and i rotated the pot until the gears stopped
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: airman00 on January 14, 2008, 04:42:11 PM
at what mhz?
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: javafiend on February 12, 2008, 10:58:14 AM
Since nothing else seems to be working, I used the OP's code but can't see where to change the frequency.  I'm using AVR Studio.
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: garriwilson on February 12, 2008, 07:39:31 PM
at what mhz?

Quote
well, i sent a 1.5ms pulse and ran my atmega168 at 4 mhz...and i rotated the pot until the gears stopped

 ;D
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: airman00 on February 12, 2008, 09:28:46 PM
at what mhz?

Quote
well, i sent a 1.5ms pulse and ran my atmega168 at 4 mhz...and i rotated the pot until the gears stopped

 ;D

to garriwilson

the 4mhz was edited in his post AFTER I replied   ;)
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: rox2007 on February 13, 2008, 01:27:08 AM
i did, sorry about that
Title: Re: midyfying servos - cant get the pot head to stop rotating
Post by: garriwilson on February 13, 2008, 07:22:15 PM
Oh my bad  ;)