Sections
You are here: Home Forum Development Discussion Having trouble with programing

Having trouble with programing

Up to Development Discussion

Having trouble with programing

Posted by Brian Banta at August 08. 2008

I'm trying to learn to program the make controller, but I can't seem to get eclipse to allow me to write anycode for it. I followed the how to on programing the controller with eclipse, but it still won't work. I can't modify the heavy firmware. Can some one help? Thanks,

Brian

Re: Having trouble with programing

Posted by Brian Banta at August 09. 2008

Ok, I've got every thing working, I've started with a little program that doesn't seem to be working. I'm trying to get the make controller to read values from the analog input 1 and then move a server to a set position.

#include "config.h"

#include "servo.h"

void AinServoTask( void* p );

void Run( ) // this gets called as soon as we boot up.

{

TaskCreate( AinServoTask, "AinServo", 1000, 0, 3 );

}

void AinServoTask( void* p )

{

(void)p; // unused variable

int i;

int ain;

while( true )

{

AnalogInput_GetValue(1);

if (1>1);

{

Servo_SetPosition (1, 800)

}

else

{

Servo_SetPosition (1, 250);

}

Sleep(1);

}

}



I've built it and up loaded it to the controller, but the servo just spins one way and doesn't do anything when I hit the switch hooked up to analog input 1. Either I'm messing up in the programming or the hardware, I have the switch so it will ground the input. Can some one help me out?


Re: Having trouble with programing

Posted by Liam Staskawicz at August 09. 2008
Hi - please don't paste code in the forum. It doesn't get formatted correctly and is really hard to read. Try something like http://pastie.org instead. In your program, you need to use AnalogIn_GetValue() to store the value in your ain variable: ain = AnalogIn_GetValue(1); Then test if that's greater than 1, not if 1 > 1 - which will never be true. if( ain > 1 )

Re: Having trouble with programing

Posted by Brian Banta at August 09. 2008

oh ok, sry i didn't know that would happen, I'll do that next time. I tried that but it's still not working, now the servo won't move at all. http://pastie.org/250733 <-- code with the ain = AnalogIn_GetValue(1); in it. But it's complaining about ain. It's saying "ain undeclared (first use in this function)  (Each undeclared identifier is reported only once for each function it appears in.) I can't figure out what to fix on it, should I put int before, so it's like

int ain = AnalogIn_GetValue(1);


or is there something else I'm missing

thanks

Re: Having trouble with programing

Posted by Liam Staskawicz at August 11. 2008
The error message is there to help you :) In your previous example, you had declared "int ain;" - not sure why you removed that, but you need it back. Or declaring it as you specified above as "int ain = AnalogIn_GetValue(1);" would be fine.

Re: Having trouble with programing

Posted by Brian Banta at August 11. 2008

I put int ain = AnalogIn_GetValue(1) and I'm getting a new message that on line 13 it's expecting an identifier or( before token {, yet there is an identifier there to my knowledge.

Re: Having trouble with programing

Posted by Liam Staskawicz at August 11. 2008
Make sure you end your lines with semicolons.

Re: Having trouble with programing

Posted by Brian Banta at August 11. 2008
hmm, I put semicolons on the end of my lines yet I still get errors on line 8 and 13 with the same message. http://pastie.org/251379 <--code so far with the semicolons and int = ain. Is it possible I'm missing some code that it's looking for? Thanks for the help.
Powered by Ploneboard
Document Actions