Society of Robots - Robot Forum

Software => Software => Topic started by: logicguy on February 20, 2010, 09:44:19 PM

Title: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: logicguy on February 20, 2010, 09:44:19 PM
Hello!

I'm currently using an ATMega168 for the 50 $ robot, but the hex file that is needed to modify the servo doesn't work on other type of microcontollers, since it's compiled for ATMega8. Can someone help me with the code that is needed to get my servo to rotate to 0 degrees so that I can later modify it ?

Thank you in advance.
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: logicguy on February 21, 2010, 06:11:23 PM
I found a post that is written by the Admin, but I'm not sure if it rotates my servo exactly to 0 degrees. I modified it to fit the variables that are written for the photovore source code:

Code: [Select]
/*********ADD YOUR CODE BELOW THIS LINE **********/
LED_off();//turn LED on

while(1)
{
servo_left(30);
delay_cycles(20);
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/

Do those commands rotate my servo to exactly 0 degrees ? I have tested it and it works, but this is what is happening when I run the program:

(http://img99.imageshack.us/img99/8371/dsc00149.th.jpg) (http://img99.imageshack.us/i/dsc00149.jpg/)

Can someone with a modified servo tell me if that is the correct orientation ?

Thanks.
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: Razor Concepts on February 21, 2010, 06:19:57 PM
It is correct if everything is working correctly.

The servo horn will be in different positions for different servos, since they are just screwed on arbitrarily from the factory.
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: logicguy on February 21, 2010, 06:57:10 PM
Thank you for your response.

You are right, I checked the other servo that I bought, and it changes to a different position with a different max/min orientation.

You are also saying that those values will orient my servo to 0 degrees, but that's not important, the importance is that it's rotating during the modification ?
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: Razor Concepts on February 21, 2010, 07:24:29 PM
No, it will orient your servo to 0 degrees, and so during modification you should not spin the gears, so that the pot remains at that 0 degree location.

I just meant that when the manufacturer builds the servos, they do not put the servo horn at a specific degree angle, they just slap it on there at any position and screw it in.
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: Webbot on February 21, 2010, 09:23:53 PM
... so if you want the servos to look the same then unscrew the 'white circle', run the program to center it, and then screw the 'white circle' back on in any position you like.
Title: Re: Hold servo .hex doesn't work on ATMega168 (need source code) - 50 $ robot
Post by: logicguy on February 22, 2010, 11:35:18 PM
Thank you for your suggestions.

I'm about to modify my servo, so are you  sure that the code will put my servo to 0 degrees ? Admin says that I must modify the "30" value until the servo is centered which worries me a little, since I don't understand why I should modify the 30 value when it should center it automatically.

I also ordered an ATMega8 just to be sure if I screw something up with my first servo so that I can run the .hex file and possibly modify it successfully.

This is an urgent notice, I will present this robot next week.