When you set Compressor_Enable to false but the air temperature is still above the lower threshold, the runtime never leaves the inner loop. Both conditions need to be false for the code to end. You could try using “and” between both conditions in just one while loop so that it stops running when either condition becomes false?
And just a little tip, when you share code you can highlight everything and hit the </> button to add triple ticks ``` at the start and end to format it like this:
while (IsVariableTrue (Compressor_Enabled))
while (ReturnAir_Temp > AirTemp_Lower)
If this logic is going to be used in production some day, then consider that ReturnAir_Temp will be a noisy analog signal that may cause your condition statement to alternate between true and false rapidly. Since compressors tend to make a fuss about starting against high head pressure, appropriate cycling delays should be provided.
Philip, I plan to add an anti-recycle timer in there for that reason, as well as time to let the motor windings cool if not on a VFD. I also have air temp setpoint differentials in place to allow some more off cycle. That is where the ‘lower’ comes into play for off cycling the compressor.
AirTemp_Setpoint minus AirTemp_Differential equals AirTemp_Lower
As always, your help and suggestions are much appreciated.