Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   HELP!!! STUCK WITH SUB ROUTINES WITH THE IR!!! (http://www.chiefdelphi.com/forums/showthread.php?t=61921)

drewjones13 17-01-2008 20:25

HELP!!! STUCK WITH SUB ROUTINES WITH THE IR!!!
 
we are having issues with our IR coding in hybrid mode, below is what we have set up, for some reason its only running the first subroutine as if rc_dig_in10 is already initialized to "on" at the start of the code.

Auton Code:

Code:

 
time1 = time1 + 1;
if (time1 <= 5)
{
        rc_dig_in10 = rc_dig_in11 = rc_dig_in12 = rc_dig_in13 = 0;
        pwm01 = pwm02 = 127;
}
else if (rc_dig_in10 = 1)
{
        cmd0();
}
else if (rc_dig_in11 = 1)
{
        cmd1();
}
else if (rc_dig_in12 = 1)
{
        cmd2();
}
else if (rc_dig_in13 = 1)
{
        cmd3();
}
else
{
        rc_dig_in10 = rc_dig_in11 = rc_dig_in12 = rc_dig_in13 = 0;
        pwm01 = pwm02 = 127;
}

Subroutines:

Code:

unsigned char cmd0()
{
        pwm01 = 190;
        pwm02 = 190;
        return 0;       
}
unsigned char cmd1()
{
        pwm01 = 64;
        pwm02 = 64;
        return 0;       
}
unsigned char cmd2()
{
        pwm01 = 190;
        pwm02 = 64;
        return 0;       
}
unsigned char cmd3()
{
        pwm01 = 64;
        pwm02 = 190;
        return 0;       
}


psy_wombats 17-01-2008 20:52

Re: HELP!!! STUCK WITH SUB ROUTINES WITH THE IR!!!
 
I believe the if statements are your problem. You're only using one equals sign. That will actually assign the bit the '1' rather than checking equivalence. You need to use the == operator instead.


All times are GMT -5. The time now is 11:07.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi