RAC-230 · Lesson 1 of 12 · 21 min

Control fundamentals: loops, differentials and PID

The first call of Theo's second-year controls block came from the brewery. Priya, the head brewer, had a complaint that sounded like a refrigeration problem: the walk-in cooler's condensing unit was starting and stopping every three or four minutes, all day long, and the compressor sounded tired. Dana listened for a minute outside the box, counted the starts on her watch and went straight to the thermostat on the cooler wall instead of the condensing unit. Someone had replaced the old mechanical control with a cheap digital one and left the differential at its factory setting of 0.5 K (1 °F). "The refrigeration is fine," she told Theo. "The control is asking it to do something stupid. Before you can fix controls, you have to understand what a control is trying to do."

RAC-130 covered the electrical side of controls: switches, relays, contactors, transformers, thermostats and the basic sequences of an air conditioner and a heat pump. This course covers what those parts are for. It starts here with the ideas every control uses, whether it is a bimetal strip in a 1970s thermostat or a building automation controller running a chiller plant: the controlled variable, the setpoint, the loop, the differential and the three actions of a PID controller. Later lessons apply these ideas to sensors, operating and safety controls, defrost, case controllers, communicating equipment, economizers and building automation.

The parts of a control loop

Every automatic control has the same parts, even when they are hidden inside one small device. The controlled variable is the thing you care about: box air temperature in a walk-in, leaving glycol temperature from a chiller, supply air temperature from a rooftop unit or space humidity in a clinic. The sensor measures it. The controller compares the measurement with the setpoint, the value you want, and decides what to do. The controlled device carries out the decision: a contactor starts a compressor, a valve opens, a damper moves or a fan speeds up. The process is the equipment and the space between the controlled device and the sensor, with all its delays.

  • Setpoint: the desired value of the controlled variable, such as 2 °C (36 °F) box air.
  • Error: the difference between the setpoint and the measured value at any moment.
  • Controlled device or final control element: the contactor, valve, damper actuator or drive that changes the energy going into the process.
  • Disturbance: anything that pushes the controlled variable away from setpoint, such as a door left open, warm product loaded into the box, sun on a roof or a crowd in a room.
  • Lag: the delay between a change at the controlled device and the sensor seeing the result.
A block diagram of a closed control loop: setpoint and sensor signal enter a comparator, the error goes to the controller, the controller output drives a controlled device such as a compressor contactor, which acts on the process, the walk-in cooler; disturbances such as door openings and warm product enter the process; the sensor measures box air and feeds back to the comparator
A closed loop. The sensor feeds the result back to the controller, which keeps correcting until the controlled variable is at setpoint.

Open loop and closed loop

An open-loop control acts without measuring the result. A time clock that runs an exhaust fan from 7 a.m. to 6 p.m. is open loop: it does not know whether the kitchen is hot. Time-initiated defrost, outdoor reset on a boiler without a supply sensor and a fixed-speed pump on a schedule are all open loop. Open loop is simple and predictable but cannot correct for disturbances. A closed-loop control measures the controlled variable and keeps correcting. Nearly every temperature and pressure control in this trade is closed loop, and most real systems combine both: a schedule decides when a rooftop unit is allowed to run, and a closed loop decides how hard it runs.

Closed loops can be wrong in ways open loops cannot. If the sensor is in the wrong place, out of calibration or damaged, a closed loop will faithfully control the wrong number. A supply air sensor that has fallen out of the duct and is hanging in a warm ceiling space will make a rooftop unit run its compressors flat out. That is why lesson 2 is about sensors and why the first rule of control troubleshooting is to check what the controller thinks it is seeing against what a calibrated instrument actually reads.

Two-position control and the differential

The simplest closed-loop control is two-position, also called on-off control. The controlled device has only two states: the compressor runs or it does not, the heater is on or off, the solenoid valve is open or closed. If the control switched exactly at setpoint, the slightest noise in the reading would make it chatter on and off many times a second. Every two-position control therefore has a differential, the gap between the value at which it turns on (the cut-in) and the value at which it turns off (the cut-out). Some manufacturers call it hysteresis or the dead band.

Picture the brewery's walk-in with a setpoint of 2 °C (36 °F) and a differential of 2 K (4 °F). On a cooling control, the compressor cuts in when the box warms to 3 °C (38 °F) and cuts out when it reaches 1 °C (34 °F). Between those values the control does nothing, and the box temperature drifts up slowly while the compressor is off and down while it runs. The wider the differential, the longer each on and off period and the fewer starts per hour; the narrower the differential, the tighter the temperature and the more starts. Note that some digital controllers place the differential entirely above the setpoint, so the setpoint is the cut-out, while others centre it on the setpoint. Always read which way a particular controller works before setting it.

Even with a wide differential, the actual swing of the box air temperature is larger than the differential. When the compressor stops, the evaporator coil is still cold and keeps cooling the air for a short time, so the temperature undershoots the cut-out. When it starts, it takes time for the coil to get cold again, so the temperature overshoots the cut-in. This overshoot and undershoot is caused by lag in the system and is called the operating differential, compared with the control's mechanical or set differential.

A graph of box air temperature against time for a two-position cooling control: the temperature saws up and down between cut-in and cut-out lines, slightly overshooting each; a compressor on-off bar beneath shows longer cycles with a wide differential and many short cycles with a narrow differential
Two-position control. The differential sets the cycle length; lag adds overshoot beyond the cut-in and cut-out.

Why short cycling matters

Compressors are designed for a limited number of starts. Each start draws locked-rotor current, heats the motor windings, washes oil off the bearings for the first few seconds and, on some systems, slugs liquid refrigerant or oil into the cylinders. Most manufacturers state a minimum off time and often a maximum number of starts per hour, commonly in the range of six to twelve for small hermetic compressors, and many control boards and timers enforce an anti-short-cycle delay of a few minutes. A compressor that starts fifteen or twenty times an hour runs hot, returns little oil and fails early.

Short cycling is a symptom, and controls are only one of its causes. A low charge can trip a low-pressure control repeatedly, a dirty condenser can trip a high-pressure control, an oversized unit satisfies the thermostat in minutes, and a thermostat in a supply air stream or next to an evaporator fan sees fast temperature swings. At the brewery, the cause was the differential alone. Dana reset the digital thermostat to a 2 K (4 °F) differential and set its minimum off time to three minutes. Within an hour the compressor was running about twelve minutes on and eight off, and the box stayed within a degree of setpoint.

# Two-position control of a walk-in cooler: how the differential sets the number of starts
# Simple model: box warms at a fixed rate when off, cools at a fixed rate when on (illustrative values)
WARM = 0.25      # K per minute rise with the compressor off
COOL = 0.35      # K per minute fall with the compressor on
LAG = 0.5          # minutes of lag before the coil responds
SET = 1.0         # cut-out at setpoint, differential added above it

def simulate(diff, minutes=240, dt=0.05):
    t, temp, on, starts = 0.0, SET + diff / 2, False, 0
    delay = 0.0
    lo, hi = temp, temp
    while t < minutes:
        if not on and temp >= SET + diff:
            on, starts, delay = True, starts + 1, LAG
        elif on and temp <= SET:
            on, delay = False, LAG
        effective_on = on if delay <= 0 else not on   # coil keeps its old state for the lag time
        delay -= dt
        temp += (-COOL if effective_on else WARM) * dt
        t += dt
        lo, hi = min(lo, temp), max(hi, temp)
    return starts / (minutes / 60), lo, hi

for diff in (0.5, 1.0, 2.0):
    per_hour, lo, hi = simulate(diff)
    print(f"differential {diff:>4} K: {per_hour:5.1f} starts per hour, box swings {lo:.1f} to {hi:.1f} C")
Output
differential  0.5 K:  10.5 starts per hour, box swings 0.8 to 1.6 C
differential  1.0 K:   6.5 starts per hour, box swings 0.8 to 2.2 C
differential  2.0 K:   3.8 starts per hour, box swings 0.8 to 3.1 C

The model is simple, but it shows the trade-off clearly. Halving the differential roughly doubles the starts, while the swing in box temperature shrinks by less than you might expect, because the lag adds a fixed overshoot at both ends. A narrow differential buys little extra temperature accuracy and costs a great deal of compressor life.

Modulating control

Many controlled devices can do more than switch on and off. A chilled-water valve can be 35 % open, a variable-frequency drive can run a fan at 41 Hz, an inverter compressor can run at any speed in its range and an economizer damper can sit at 20 % outdoor air. Controls that drive these devices are modulating or proportional controls. Instead of a cut-in and cut-out, they produce a continuous output, often a 0–10 V or 4–20 mA signal, or a digital command over a network, that positions the device anywhere between minimum and maximum.

Proportional, integral and derivative action

Most modulating controls use some combination of three actions, named proportional, integral and derivative, or PID. You do not need the mathematics to set them up in the field, but you do need to know what each one does, because the symptoms of a badly tuned loop are easy to recognize once you know what to look for.

  • Proportional action makes the output proportional to the error. With a throttling range or proportional band of 4 K (8 °F), the valve might be fully closed at setpoint and fully open when the temperature is 4 K (8 °F) away. A larger gain (a narrower band) reacts harder.
  • Integral action, also called reset, adds to the output for as long as an error remains, at a rate proportional to the size of the error. It removes the steady offset that proportional control alone leaves behind. Too much integral action, set with an integral time that is too short, makes the loop overshoot and hunt.
  • Derivative action responds to the rate of change of the error and can damp fast-changing loops. It amplifies noise, so in HVAC-R it is usually set to zero or left at a small factory value.
\[u(t) = K_p\,e(t) + \frac{K_p}{T_i}\int_0^t e(\tau)\,d\tau + K_p\,T_d\,\frac{de}{dt}\]

In the equation, u is the controller output, e is the error, K_p is the proportional gain, T_i is the integral time and T_d is the derivative time. Proportional-only control always settles with some offset, called droop, because an error is needed to produce any output at all. Suppose a chiller's leaving glycol setpoint is −4 °C (25 °F) and proportional-only control needs the glycol 0.8 K (1.4 °F) warm to hold the compressor at the speed the current load needs. The glycol settles there, not at setpoint. Integral action keeps adding output until the error is zero, which is why nearly every modulating HVAC-R loop is a PI loop.

# A PI loop holding a glycol chiller's leaving temperature (first-order process with dead time, illustrative)
def run(kp, ti, minutes=40, dt=0.05):
    sp, temp, out, integral = -4.0, 2.0, 0.0, 0.0
    tau, dead, gain = 4.0, 1.0, 0.16   # process time constant (min), dead time (min), K per % output
    history = [0.0] * int(dead / dt)
    peak, settled_at = temp, None
    for k in range(int(minutes / dt)):
        err = temp - sp                     # cooling loop: warm water means more output
        integral += err * dt
        out = kp * err + (kp / ti) * integral if ti else kp * err
        out = max(0.0, min(100.0, out))
        if ti and (out == 0.0 or out == 100.0):
            integral -= err * dt             # stop winding up when the output is pinned
        history.append(out)
        applied = history.pop(0)
        load_temp = 6.0                    # temperature the glycol would reach with no cooling
        target = load_temp - gain * applied
        temp += (target - temp) / tau * dt
        peak = min(peak, temp)
        if settled_at is None and abs(temp - sp) < 0.2 and k * dt > 5:
            settled_at = k * dt
    return temp, peak, settled_at

for kp, ti, name in ((30.0, 0, "P only, moderate gain"), (30.0, 3.0, "PI, integral time 3 min"),
                     (30.0, 1.0, "PI, integral time 1 min (too fast)"), (60.0, 3.0, "PI, gain doubled")):
    final, peak, settled = run(kp, ti)
    s = f"{settled:.1f} min" if settled else "not within band"
    print(f"{name:34s} final {final:6.2f} C, lowest {peak:6.2f} C, first within band at {s}")
Output
P only, moderate gain              final  -2.28 C, lowest  -3.34 C, first within band at not within band
PI, integral time 3 min            final  -4.01 C, lowest  -4.24 C, first within band at 7.7 min
PI, integral time 1 min (too fast) final  -4.00 C, lowest  -5.09 C, first within band at 6.0 min
PI, gain doubled                   final  -4.78 C, lowest  -4.91 C, first within band at 7.6 min

Run the code and compare the four cases. The proportional-only loop settles about 2 K (about 3 °F) warm, offset from setpoint. The PI loop with a sensible integral time reaches setpoint with a modest dip. The PI loop with a one-minute integral time overshoots and oscillates, because integral keeps pushing after the temperature has started to move. Doubling the gain gets close to setpoint sooner but leaves the loop less stable, still swinging at the end of the run. These are the four behaviours you will see on real trend logs.

Tuning in the field

Factory PID values in packaged equipment are normally sensible, and the first rule of field tuning is to leave them alone unless a trend shows a problem. When a loop does hunt, the usual causes are, in order: a sensor in the wrong place or with a slow response; a valve or damper that is oversized, sticking or has play in its linkage; integral action that is too fast; and only then gain that is too high. Change one value at a time, by about a factor of two, and watch at least several cycles of the trend before changing anything else. Write down the original values first.

Reading a PID trend. Always check the sensor and the controlled device before changing tuning values.
What the trend showsLikely causeFirst thing to try
Settles but never reaches setpointProportional-only control, or integral turned offAdd or restore integral action
Slow, smooth swings above and below setpointIntegral time too shortLengthen the integral time
Fast, small oscillationGain too high, or noisy sensorReduce gain; check sensor wiring and location
Output slams fully open then fully closedOversized valve, sticky actuator or integral windupCheck the valve and actuator; enable anti-windup
Very slow recovery after a disturbanceGain too low, or integral time too longIncrease gain or shorten integral time in small steps

Control actions and fail-safe positions

Two more ideas complete the vocabulary. A control's action is direct when its output increases as the measured value increases, as for a cooling valve that opens as the water warms, and reverse when its output decreases as the measured value increases, as for a heating valve. Choosing the wrong action makes a loop run away to one extreme, and it is a common mistake when a controller is replaced or reprogrammed. The fail-safe or normal position is what the controlled device does when power or signal is lost: a spring-return outdoor air damper closes so coils cannot freeze, a heating valve may fail open in a cold climate, and a liquid line solenoid closes when it loses power. Knowing the fail-safe position of every device in a system tells you what the equipment will do in a power failure or when a wire breaks.

Back at the brewery

Before leaving, Dana had Theo write the new settings on a label inside the thermostat cover: setpoint, differential, minimum off time and the date. "The next person who opens this will know what it is supposed to be," she said. She also asked Priya to keep the brewery staff from adjusting it. Theo noticed the old mechanical thermostat in the van's scrap bin, with its differential adjusting wheel set to the widest mark. "That one probably worked better than the fancy one," Dana said. "A control is only as good as how it's set."

Common mistakes

  • MistakeTreating short cycling as a compressor or refrigerant fault every time.

    InsteadCheck the control's differential, minimum off time and sensor location first.

  • MistakeSetting the narrowest possible differential to hold temperature tightly.

    InsteadUse a differential wide enough to keep starts within the manufacturer's limit.

  • MistakeChanging several PID values at once.

    InsteadChange one value at a time, by about a factor of two, and watch several cycles.

  • MistakeUsing derivative action on noisy HVAC loops.

    InsteadLeave derivative at zero unless the manufacturer specifies otherwise.

  • MistakeReplacing a controller without checking its action.

    InsteadConfirm direct or reverse action and the fail-safe position of the device it drives.

Summary and key terms

  • A control loop has a sensor, a controller, a controlled device and a process, with disturbances and lag.
  • Open-loop controls act without measuring the result; closed-loop controls keep correcting.
  • Two-position controls need a differential between cut-in and cut-out; lag adds overshoot.
  • A narrow differential multiplies compressor starts and shortens compressor life.
  • Proportional control leaves an offset; integral removes it; derivative is rarely used in HVAC-R.
  • Check the sensor and controlled device before retuning, and change one value at a time.
Controlled variable
The quantity a control loop holds, such as box air or leaving water temperature.
Setpoint
The desired value of the controlled variable.
Differential
The difference between the cut-in and cut-out values of a two-position control.
Short cycling
Starting and stopping too often, usually more often than the compressor manufacturer allows.
Proportional band
The range of error over which a proportional control moves its output from minimum to maximum.
Integral time
The setting that determines how fast integral action adds output while an error remains.
Offset
The steady difference between setpoint and the controlled variable left by proportional-only control.
Fail-safe position
The position a controlled device takes when it loses power or signal.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. A cooler control cuts out at 1 °C with a 2 K differential above setpoint. Where does it cut in?

    Show answer

    At 3 °C.

  2. Halving a differential from 2 K to 1 K roughly does what to the starts per hour?

    Show answer

    Roughly doubles them.

  3. A PI loop on a chilled-water valve swings slowly 1 K above and below setpoint. What is the first tuning change?

    Show answer

    Lengthen the integral time, after checking the sensor and valve.

  4. A proportional-only loop holds supply air 1.5 K above setpoint. Why?

    Show answer

    Proportional control needs an error to produce output; integral action would remove the offset.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz