Program Code Help

CurtisPratt

Member
Join Date
Dec 2011
Location
Saskatoon
Posts
23
I’m having some trouble when testing this code out

if (Sixnet_Data.Generator_Running ==1)

{ if (Sixnet_Data.IntakeTemperature_testing > -9.0)
{ Sixnet_Data.Damper_Inlet = 75;
Sixnet_Data.Damper_Outlet = 75;
return;
}
if (Sixnet_Data.IntakeTemperature_testing < -10.0
&& Sixnet_Data.IntakeTemperature_testing > -20.0)
{ Sixnet_Data.Damper_Inlet = 50;
Sixnet_Data.Damper_Outlet = 50;
return;
}
if (Sixnet_Data.IntakeTemperature_testing < -21.0)
{ Sixnet_Data.Damper_Inlet = 10;
Sixnet_Data.Damper_Outlet = 10;
return;
}}

Basically I just want to set the 2 outputs to 75, 50 & 10 based on the 3 temperature scenarios and the generator running.

Above -10deg C @ 75%
Between -10deg C & -20deg C @ 50%
Below -20def C @ 10%

Could someone tell me where I've gone wrong on the code, thanks.
 
The Sixnet_Data.IntakeTemperature_testing is a floating point real number, so you have to include also the range from -10.0 to -9.0 and -20.0 to -21.0 in your test:


if (Sixnet_Data.Generator_Running ==1)

{ if (Sixnet_Data.IntakeTemperature_testing >= -10.0)
{ Sixnet_Data.Damper_Inlet = 75;
Sixnet_Data.Damper_Outlet = 75;
return;
}
if (Sixnet_Data.IntakeTemperature_testing < -10.0
&& Sixnet_Data.IntakeTemperature_testing >= -20.0)
{ Sixnet_Data.Damper_Inlet = 50;
Sixnet_Data.Damper_Outlet = 50;
return;
}
if (Sixnet_Data.IntakeTemperature_testing < -20.0)
{ Sixnet_Data.Damper_Inlet = 10;
Sixnet_Data.Damper_Outlet = 10;
return;
}}
 
Any particular reason you are putting "return;" in your IF statements? If this isn't packed in a function, you don't need/shouldn't use "return;". If it is in a function, it would be safer to put the "return;" after the "}}" at the end in case the temperature is, for instance, between -9 and -10, which would lock up the function and crash the PLC with your code.

xzen's corrections would prevent crashes if this is a function, but having three separate empty returns is still silly.
 

Similar Topics

| | | In1 Ls2 Out1 | |-| |---| |---O---| | | | Ls1 Ls3 Out2 | |-| |---|/|---O---| | | | Ls2 Out1 | |-|/|---------O---| | |...
Replies
21
Views
9,187
Is there anyway to be certain that the memory module in a ML1400 has been written to with the current program? I have controllers in the field...
Replies
0
Views
869
(Allen Bradley PLC)Issue resolved by download the project, But What is the main root cause of this Major Fault Error code 62 “Non-Recoverable...
Replies
3
Views
3,231
Hi : All 1'st time i upload plc FP-XH C60T with FPWIN PRO7 after that i want return to download to plc but the program show " No code to be...
Replies
1
Views
1,504
Hi all, i have a 1756-L62 processor, it keeps going into fault mode when i put it into run. I went to check major faults and i see the program...
Replies
23
Views
4,603
Back
Top Bottom