Society of Robots - Robot Forum
Software => Software => Topic started by: rezabot on May 18, 2008, 12:55:18 PM
-
Hello,
I am building a pretty simple robot, and the first thing I need to do is modify my servos. I downloaded the center.hex file off of the servo modifying tutorial and I was able to load it to my ATmega168 using my AVRISP mkII. Here is the output of AVRStudio:
Getting isp parameter.. SD=0x3e .. OKOK
Reading FLASH input file.. OK
Setting mode and device parameters.. OK!
Entering programming mode.. OK!
Programming FLASH .. OK!
Leaving programming mode.. OK!
It seems as if everything is working fine, however the servo does not move at all!! I am using HiTech HS-311 servos, I have the black to ground, the red to +6.26V, and the yellow wire connected to pin 2 on my microcontroller. Can anybody help me figure out why the servo does not respond to the hex file? Also, is it possible for someone to post the source code for center.hex so that I can see how it works. I really appreciate your help and I love this website!
GO ROBOTS!
-
I guess what I really want to know is: "what is the complete C source code for a ATmega168 microcontroller which will send a 1.5ms pulse to pin 2?"
-
I'm trying to make things as simple as possible in order for me to wrap my brain around the concepts, so I uploaded this code to my ATmega168:
#include <avr/io.h>
int main(void)
{
DDRD = 0xff;
PORTD = 0xff;
return 1;
}
Unless I'm mistaken, this should bring all of the D ports PD0...PD7 to +5V (if I wanted only PD7 to be high would I use 0x01 or 0x80?)
Now I am sure that my circuit is now breadboarded correctly, however I originally had it a little mixed up. The problem is that after I program the chip, none of the PD0...PD7 pins are going to +5V. Is it possible that I my chip is malfunctioning? or am I missing something?....Any help would be greatly appreciated as I have already spent hours trying to figure this simple procedure out.
-
you want to set the port high for 1.5 seconds and then bring it low. that would center the servo
-
I'm trying to make things as simple as possible in order for me to wrap my brain around the concepts, so I uploaded this code to my ATmega168:
#include <avr/io.h>
int main(void)
{
DDRD = 0xff;
PORTD = 0xff;
return 1;
}
Unless I'm mistaken, this should bring all of the D ports PD0...PD7 to +5V (if I wanted only PD7 to be high would I use 0x01 or 0x80?)
Now I am sure that my circuit is now breadboarded correctly, however I originally had it a little mixed up. The problem is that after I program the chip, none of the PD0...PD7 pins are going to +5V. Is it possible that I my chip is malfunctioning? or am I missing something?....Any help would be greatly appreciated as I have already spent hours trying to figure this simple procedure out.
You should almost never let the program flow reach the return statement of main() as this will cause the program counter to run off the end of your program and unexpected behavior can result depending on the state of the rest of your flash. Try putting a:
while (1);
before your return statement and see if you read 5V from your port D pins.
- Ben
-
Got it to work?
If you have a multimeter, check the frequency of the servo pin.
-
Thanks for your help fellow robots, however I believe that my ATmega168 chip is not functioning properly...