Hello,
I have a basic question about setting a value to a certain variable, and then having the program change or update that value as it is executed. The program is pretty simple, it is a switch that monitors another variable that decides when to turn on and off. It is shown below.
The program first checks to see if vssAD_RLYD2 = 1 (on). If it does equal 1, then it checks if the value of vssAD_VAC is < 550. If it is true, then it keeps vssAD_RLYD2 equal to 1. If it is false, it changes vssAD_RLYD2 to 0 (off).Code:main( VOID ) { if ( vssAD_RLYD2 == 1 ) { if ( vssAD_VAC < 550 ) { vssAD_RLYD2 = 1; } else { vssAD_RLYD2 = 0; } } else { if ( vssAD_VAC <= 450 ) { vssAD_RLYD2 = 1; } else { vssAD_RLYD2 = 0; } } }
If in the beginning vssAD_RLYD2 does NOT equal 1 (=0), then it checks if vssAD_VAC is <= 450. If this is true, then it changes vssAD_RLYD2 to 1. If it is false, it keeps vssAD_RLYD2 at 0.
After vssAD_RLYD2 is changed to whichever gets executed, it will start over by checking to see if vssAD_RLYD2 = 1.
---------------------------------------------------------------------------------------------
So, the variable vssAD_RLYD2 is the one that it needs to check for in the beginning (if its 0 or 1) then throughout the rest of the program, if certain statements are true, it needs to change that value of vssAD_RLYD2, and it will stay that value until it is changed again (like an on off switch)
I am not a computer science engineer, so that is why I am here asking for help. Hopefully this makes sense, if not let me know and I will explain what I can.