Society of Robots - Robot Forum

Software => Software => Topic started by: Carter05 on September 02, 2008, 05:38:32 PM

Title: servo centering code errors
Post by: Carter05 on September 02, 2008, 05:38:32 PM
I'm trying to build the servo centering code from the Axon source files and it's giving me all sorts of errors. I guess it's fair to say I've never downloaded anything to a micro controller before so it could be just me! I have attached a screenshot in the hopes someone can point me in the right direction.
(http://img399.imageshack.us/img399/4237/helpyf5.th.jpg) (http://img399.imageshack.us/my.php?image=helpyf5.jpg)
Title: Re: servo centering code errors
Post by: pomprocker on September 02, 2008, 05:56:44 PM
i can't really see all your code in that screen shot.

I think those PORT declarations are predefined macros somewhere in io.h or something like that.
Title: Re: servo centering code errors
Post by: airman00 on September 02, 2008, 05:58:24 PM
you are missing all those header files that you need to put in

You are using an Axon?
Title: Re: servo centering code errors
Post by: Carter05 on September 02, 2008, 06:56:56 PM
Ya I'm using an Axon. I finally got the batteries and such today so I figured I'd play around with it. I'm using the servo centering code strait from the axon source file download. As I said, I've never done this sort of stuff before. Also just click the picture and it will enlarge to full size.
Title: Re: servo centering code errors
Post by: airman00 on September 02, 2008, 07:18:29 PM
Follow the getting started tutorial all the way through . At the end of the tutorial you should have a source file called "control.c". Open that up and delete everything in that file. Now paste the code below.

Code: [Select]
void control(void) {
while(1)     // begin infinite loop
{
servo(PORTE,2,700)    // Call the macro to control the servo , where 700 is the amount of cycles
       // where PORTE is the port and 2 is the pin on the port. The servo is connected to PORTE.2 according to this example

delay_ms(20);   // delay 20 milliseconds so we don't confuse the servo
        }    // end while

} // end subroutine

To better understand the relationship between cycles and time and angle check out this program I made .( windows)
http://erobots.blogspot.com/2008/08/update-for-servo-position-calculator.html (http://erobots.blogspot.com/2008/08/update-for-servo-position-calculator.html)
Title: Re: servo centering code errors
Post by: Carter05 on September 02, 2008, 08:18:31 PM
I guess I'm more confused on the elementary thing of which things I need to include to get any code to run right.
Title: Re: servo centering code errors
Post by: airman00 on September 02, 2008, 08:27:18 PM
I guess I'm more confused on the elementary thing of which things I need to include to get any code to run right.

follow the Getting Started tutorial on the Axon page
Title: Re: servo centering code errors
Post by: Carter05 on September 02, 2008, 09:19:37 PM
I figured it out! Thanks man. Another question, how come I don't need to add all of the #include files that are listed? Such as the servo_controller.c?
Title: Re: servo centering code errors
Post by: airman00 on September 02, 2008, 09:20:27 PM
I figured it out! Thanks man. Another question, how come I don't need to add all of the #include files that are listed? Such as the servo_controller.c?
because you aren't using teh stuff in servo_Controller.c  you only include the stuff you use in your code.
Title: Re: servo centering code errors
Post by: Carter05 on September 02, 2008, 09:25:36 PM
Ah I see, I understand it all now! Thanks for your help. I'll have many more questions as I go I'm sure.
Title: Re: servo centering code errors
Post by: Admin on September 02, 2008, 10:00:50 PM
servo_controller.c isn't actually a working program yet. It was something I am working on, and just left in the zip file of other source files. Just ignore it for now and don't run it.