Log in

View Full Version : Programming question


CircularLogic
17-04-2006, 20:31
A couple of weeks ago, I wrote some code just to test out motor direction and then from there decided to write "real" code in the same file. Because easyC does not allow me to edit the text, I couldnt find a way to comment the test section of the code so I just made it an invalid while loop. (while(1==0)).

So when I ran the code, I noticed there was a rhythmic beep and silence pattern which corresponded to the same type of rhythmic motor control and lack of control. I figured out that it was the invalid while loop that was doing it.


Now I am experiencing a similar problem, but the rhythm of no control is much shorter. The only part of the code that would ever not be operation is a fairly large if statement. Is it possible for that if statement to cause a break in the code? Or could it have something to do with an undefinied variable?

#include "UserAPI.h"

int a = 0;
int b = 0;
int c = 0;

void main ( void )
{
while ( 1 )
{
MotorRcControl ( 0 , 2 , 3 , 0 ) ;
MotorRcControl ( 0 , 3 , 4 , 1 ) ;
MotorRcControl ( 0 , 6 , 1 , 1 ) ;
a = GetRxInput ( 1 , 5 ) ;
if ( a>127 )
{
SetPWM ( 2 , 160 ) ;
PrintToScreen ( "154\n" ) ;
}
else
{
if ( a<127 )
{
SetPWM ( 2 , 90 ) ;
PrintToScreen ( "100\n" ) ;
}
else
{
SetPWM ( 2 , 127 ) ;
PrintToScreen ( "127\n" ) ;
}
}
b = GetRxInput ( 1 , 6 ) ;
if ( b>127 )
{
SetPWM ( 1 , 144 ) ;
}
else
{
if ( b<127 )
{
SetPWM ( 1 , 110 ) ;
}
else
{
SetPWM ( 1 , 127 ) ;
}
}
}
}

Donut
17-04-2006, 21:52
There is a way to comment out code in EasyC, right click on an item in the flowchart and select "comment out". Try seeing if the actual comment out takes care of things.