T3's Programming tips: Staging three stages of heat with a PID

We experienced an issue in T3 programs as some of the variables are not updating correctly during its operation after a power failure. (Controllers are not powered up through UPSs)

Ex:
#Before the power failure:
Relative Humidity is less than the Setpoint then the BV for Humidifier command stays On (Correct)

#After recovering from the power failure:
Even if the Relative Humidity goes above the Setpoint, Humidifier command remains On (Wrong, program do not do the needful to switch the Humidifier command variable off)

Program is uploaded.

Program.txt (616 Bytes) .

Hi Max,
I fixed the errors in your program, I don’t know your algorithm, but you can understand how to make the program. Pay attention, I changed the name of the A/M variable to A_M, since the name of the variable with a slash is suspicious for me :slight_smile:

10 V_C = PID1
20 IF A_M AND SCH_ENAB AND A_ONOF THEN START AHU_ONOF ELSE STOP AHU_ONOF
30 IF AHU_STS THEN 40 ELSE 110
40 REM *** TEMPERATURE CONTROLLE ***
50 IF A_TEMP < TEMP_SET - 0.500 THEN START H01_ONOF ELSE STOP H01_ONOF
60 IF A_TEMP < TEMP_SET - 1 THEN START H02_ONOF ELSE STOP H02_ONOF
70 IF A_TEMP < TEMP_SET - 1.500 THEN START H03_ONOF ELSE STOP H03_ONOF
80 REM *** HUMIDITY CONTROLL ***
90 IF A_RH < RH_SET - 1 THEN START HUM_ONOF
100 IF A_RH > RH_SET + 0.500 THEN STOP HUM_ONOF
110 END

1 Like

Thanks Aleksei, indeed the ‘/’ is a special character that shouldn’t be used in variable names.

Max: Subtle point but I notice there’s no hysteris in the programs.
Here’s the program as it is now for stage one heat:
50 IF A_TEMP < TEMP_SET - 0.500 THEN START H01_ONOF ELSE STOP H01_ONOF
The output could potentially short cycle if the temperature is near the trigger point. I can suggest you add a little hysteresis to avoid short cycling:
50 IF A_TEMP < TEMP_SET - 0.500 THEN START H01_ONOF
51 IF A_TEMP > TEMP_SET THEN STOP H01_ONOF

And you could consider going to PID control rather than hard coded setpoints like you have now. This will allow the controller to kick the system along if there’s a prolonged deviation from setpoint. Set up PID2 with the setpoint and feedback and the program will go like so:

50 IF PID1 > 30 THEN START H01_ONOF
60 IF PID1 > 50 THEN START H02_ONOF
70 IF PID1 > 70 THEN START H03_ONOF
80 IF PID1 < 25 THEN STOP H01_ONOF
90 IF PID1 < 45 THEN STOP H02_ONOF
100 IF PID1 < 65 THEN STOP H03_ONOF

And one other suggestion is I see that the GOTO statement has a small logic hole. When the fan goes off while any of the heating outputs is on the heat is going to still be on. You will know from my other examples on this forum that GOTOs are to be avoided. Here’s how I would program it, your line 110 with the goto statement can now be deleted.

50 IF PID1 > 30 THEN START H01_ONOF
60 IF PID1 > 50 THEN START H02_ONOF
70 IF PID1 > 70 THEN START H03_ONOF
80 IF PID1 < 25 OR NOT AHU_STS THEN STOP H01_ONOF
90 IF PID1 < 45 OR NOT AHU_STS THEN STOP H02_ONOF
100 IF PID1 < 65 OR NOT AHU_STS THEN STOP H03_ONOF

1 Like

Thanks @Aleksei We will revise the program accordingly.

Thanks Aleksei, indeed the ‘/’ is a special character that shouldn’t be used in variable names.

Max: Subtle point but I notice there’s no hysteris in the programs.
Here’s the program as it is now for stage one heat:
50 IF A_TEMP < TEMP_SET - 0.500 THEN START H01_ONOF ELSE STOP H01_ONOF
The output could potentially short cycle if the temperature is near the trigger point. I can suggest you add a little hysteresis to avoid short cycling:
50 IF A_TEMP < TEMP_SET - 0.500 THEN START H01_ONOF
51 IF A_TEMP > TEMP_SET THEN STOP H01_ONOF

And you could consider going to PID control rather than hard coded setpoints like you have now. This will allow the controller to kick the system along if there’s a prolonged deviation from setpoint. Set up PID2 with the setpoint and feedback and the program will go like so:

50 IF PID1 > 30 THEN START H01_ONOF
60 IF PID1 > 50 THEN START H02_ONOF
70 IF PID1 > 70 THEN START H03_ONOF
80 IF PID1 < 25 THEN STOP H01_ONOF
90 IF PID1 < 45 THEN STOP H02_ONOF
100 IF PID1 < 65 THEN STOP H03_ONOF

Thanks @maurice Appreciate your support as always!

And one other suggestion is I see that the GOTO statement has a small logic hole. When the fan goes off while any of the heating outputs is on the heat is going to still be on. You will know from my other examples on this forum that GOTOs are to be avoided. Here’s how I would program it, your line 110 with the goto statement can now be deleted.

50 IF PID1 > 30 THEN START H01_ONOF
60 IF PID1 > 50 THEN START H02_ONOF
70 IF PID1 > 70 THEN START H03_ONOF
80 IF PID1 < 25 OR NOT AHU_STS THEN STOP H01_ONOF
90 IF PID1 < 45 OR NOT AHU_STS THEN STOP H02_ONOF
100 IF PID1 < 65 OR NOT AHU_STS THEN STOP H03_ONOF

**Noted and understood your approach here! **
By the way our program is to switch on the next Heater in the line up (if required) without switching off the previous heater.

@Max: You mention you’re staging three stages without switching the previous heater off and indeed that’s how this program works. When PID1 is greater than 70 all three stages will be on.