Fundamentals / Mechanical engineering / Control engineering

From a balance law to a measured plant

Predict a transient from conservation of energy, then use measurements to decide whether a first-order model is credible.

From first principles

Turn a thermal energy balance into a step response

A well-stirred body of heat capacity \(C\) stores the energy increment \(C\,dT\) for a small temperature increase \(dT\). Assume the ambient temperature \(T_a\) is constant, the heater supplies power \(u\), and heat loss is proportional to temperature excess with coefficient \(H>0\). Conservation of energy then gives a differential equation, with every term measured in watts.

\[C\dot T=u-H(T-T_a).\]

Hold the power at a constant value after a step. The new equilibrium requires zero stored-energy change, hence \(T_\infty=T_a+u/H\). Subtracting that constant solution leaves an equation proportional to the deviation itself, which integrates exponentially.

\[\frac{d(T-T_\infty)}{dt}=-\frac HC(T-T_\infty),\]
\[T(t)=T_\infty+[T(0)-T_\infty]e^{-t/\tau},\]
\[\tau=C/H .\]

The steady temperature rise per watt identifies \(1/H\). The time required for the residual deviation to fall to \(1/e\) identifies \(\tau\). Together these observations determine the stored heat capacity as \(C=H\tau\) under the assumed single-temperature model.

Derivation and applications

Identify a first-order time constant without knowing the final level

A thermometer in a stirred bath often stops recording before the new equilibrium is reached. Three equally spaced readings can still determine that equilibrium if a single relaxation dominates. Assume a fixed step in heat input, constant heat capacity and a linear heat-loss coefficient over the observed temperature range. Take the first observation after the input has finished changing. If the sampling interval is \(h\), the unknown remaining difference from equilibrium is multiplied by the same factor \(a\) over every interval.

\[T_j=T_\infty+(T_0-T_\infty)a^j,\]
\[a=e^{-h/\tau}.\]

Subtract successive readings. The unknown equilibrium cancels and the ratio of consecutive increments measures \(a\). The inversion uses differences of readings, so temperature offsets cancel as well. Once \(a\) is known, rearrange the one-step update to recover equilibrium in the original temperature scale.

\[a=\frac{T_2-T_1}{T_1-T_0},\]
\[\tau=-\frac{h}{\ln a},\]
\[T_\infty=\frac{T_1-aT_0}{1-a}.\]

A fourth reading tests the model against data excluded from the estimate. It can be predicted directly from the last increment. The condition for a stable monotonic first-order response is that \(a\) lie strictly between zero and one. Ratios near unity make the extrapolated final level very sensitive to measurement error.

\[T_{3,\rm pred}=T_2+a(T_2-T_1).\]

Worked example

Recover thermal capacity from a short record

A heater adds 6.00 W to a bath initially at equilibrium. At 20.0 s intervals the thermometer reads 20.0, 24.0 and 26.0 °C. The increments give \(a=2/4=0.500\), so \(\tau=28.9\) s and \(T_\infty=28.0\) °C. The heat-loss coefficient is \(6.00/8.00=0.750\) W/K. Multiplying by the time constant gives a lumped heat capacity of 21.6 J/K. The next predicted reading is 27.0 °C.

Change the inputs and inspect this calculation below

Second application

Test whether one relaxation fits a cooling record

An independent 5.00 s interval record reads 90.0, 80.0, 74.0 and 68.0 °C. The first three values give \(a=0.600\) and \(\tau=9.79\) s. They predict a fourth value of \(74.0-0.600(6.00)=70.4\) °C. The residual is \(-2.4\) K. With sensor repeatability of 0.1 K this discrepancy calls for checking the assumption of constant ambient temperature or a single thermal state.

Interactive calculation · Change the inputs of this example

Use the adjustable quantities to test the two worked calculations above. The plot recomputes this derivation’s balance or constitutive relation; its numerical readout reports the quantities needed for the forward calculation and the inverse or design question. Keep the fixed assumptions stated in the readout when comparing with the example values.

OneSimulation laboratory

Predict the settling time and offset of a feedback loop

Start from this chapter. Read the time constant and gain of the first-order plant, then predict how the fitted closed-loop time scale changes when proportional gain increases.

Compare recorded OneSimulation runs on this page. To test your own inputs, download the notebook and model files and run the model in an activated OneSimulation environment.

The OneSimulation signal graph connects a setpoint, error junction, controller and first-order plant. Start with plant_gain = 2.0 and setpoint = 1.0. Change proportional_gain or time_constant, keeping the other parameters fixed. Before comparing, decide which change affects the asymptotic error.

Numerically fitted time constant and tracking error sampled after six closed-loop time constants. The unit step starts from rest.
Controller gain and plant time constantFitted time (s)Sampled error
Gain 4 · plant 20 s2.222220.11331
Gain 2 · plant 20 s4.000000.20198
Gain 4 · plant 40 s4.444440.11331
Reducing proportional gain slows the loop. Doubling the plant time constant with gain fixed doubles the fitted closed-loop time while leaving the error at six closed-loop time constants almost unchanged.
Reducing proportional gain slows the loop. Doubling the plant time constant with gain fixed doubles the fitted closed-loop time while leaving the error at six closed-loop time constants almost unchanged.

Try \(K_p=9.5\) in the download. Compare the recorded final error against \(e_\infty=0.05\). To explain the difference, evaluate the exponential at the actual last sample time. Inspect the signal graph and its time histories.

Download experiment files (ZIP) Extract the files together and open first_order_plant_p_control.ipynb in a local OneSimulation environment.

Interactive reference for the OneSimulation laboratory

Change gain and plant lag independently. The browser evaluates the unsaturated analytical reference for the linked OneSimulation signal graph.

Problem sheet 2 · Identify a controller from a finite-time observation

Read the model setup and preparatory problems

Choose variables that describe stored energy

A heater warms a well-stirred tank. A sensor measures only the liquid temperature, and a controller will eventually change the heating power. Before designing the controller, ask what information fixes the future of the plant when the power is given. If the tank, its contents and the thermometer can be represented by one uniform temperature, a single initial temperature suffices. A slow thermometer or a heavy tank wall may require its own initial condition. This is a physical way of deciding how many states to put in a model.

Let \(C\) in J/K be the combined heat capacity, \(H\) in W/K the thermal conductance to the room, \(T_a\) the ambient temperature and \(u\) the delivered heater power. Over an interval \(dt\) the heater adds \(u\,dt\), the room receives \(H(T-T_a)\,dt\), and storage increases by \(C\,dT\). Taking the limit of a short interval gives

\[C\dot T=u-H(T-T_a).\]

The signs can be checked without solving anything. Set \(u=0\) while \(T>T_a\). Stored energy must decrease. At equilibrium \(\dot T=0\), so a constant 20 W input and \(H=5\) W/K sustain a 4 K excess over the surroundings. This check will later reveal a faulty actuator calibration even if the transient looks smooth.

Separate gain, time scale and initial condition

Choose an operating point \((u_0,T_0)\) in equilibrium, keep the ambient temperature fixed and write \(v=u-u_0\), \(y=T-T_0\). Subtracting the equilibrium balance cancels the constant terms. Dividing by \(H\) gives

\[\tau\dot y+y=Kv,\]

where \(K=1/H\) is the steady gain and \(\tau=C/H\) is a time. An input step of amplitude \(v_s\) moves the equilibrium to \(Kv_s\). Subtract this new equilibrium to leave a homogeneous decay equation. Integrating from zero time yields

\[y(t)=Kv_s+\big[y(0)-Kv_s\big]e^{-t/\tau}.\]

After one time constant, 36.8% of the initial distance to the new value remains. Reaching a specified fraction of the final temperature and reaching a tolerance relative to the final change are equivalent only if the output is initially zero in the chosen coordinates. Working in temperature deviations makes the convention explicit.

Background · How can three samples reveal a time constant without knowing the final level?

For a stable, noise-free first-order response after a single input step, take three measurements \(y_0,y_1,y_2\) equally spaced by \(h\). Each difference contains the same unknown amplitude. Their ratio isolates the exponential decay.

\[\rho=\frac{y_2-y_1}{y_1-y_0}=e^{-h/\tau},\]
\[\tau=-\frac{h}{\ln\rho}.\]

With one second spacing and readings 2.00, 3.20 and 3.92 V, the ratio is 0.60 and the inferred time constant is 1.96 s. A constant sensor offset cancels. Near the final level both differences become small, so quantisation may dominate the ratio. In real data, evaluate multiple triples or fit all samples with a noise model.

Recover a model from a step experiment

Start from equilibrium and increase the power by 30 W. The final rise is 6 K. At 20 s the rise is 2.36 K. The final measurement identifies the gain and heat-loss conductance.

\[\begin{aligned} K &= \frac{6~\mathrm K}{30~\mathrm W}=0.20~\mathrm{K/W},\\ H &= \frac1K=5.0~\mathrm{W/K}. \end{aligned}\]

Next divide the distance still to go at 20 s by the initial distance to the new equilibrium. The logarithm of this dimensionless fraction gives the time constant, which in turn gives the effective heat capacity.

\[\begin{aligned} r&=\frac{6-2.36}{6}=0.607,\\ \tau&=-\frac{20~\mathrm s}{\ln r}\simeq40~\mathrm s,\\ C&=H\tau\simeq200~\mathrm{J/K}. \end{aligned}\]

At 60 s the predicted rise is

\[6(1-e^{-1.5})=4.66\,\mathrm{K}.\]

This third measurement tests a prediction made using the earlier data.

The same experiment can expose a missing state. Plot the logarithm of the remaining fraction against time. A single time constant gives a straight line with slope \(-1/\tau\). If the early trace has a shoulder but the late trace is straight, the sensor or a second thermal mass might be responsible. In the last few samples, the temperature difference in the logarithm may be comparable to measurement noise. Use those samples to estimate the final temperature rather than relying on their individual log slopes.

Transfer the argument to a rotating shaft

With shaft inertia \(J\), viscous drag \(b\) and driving torque \(u\), conservation of angular momentum gives

\[J\dot\omega=u-b\omega.\]

A suspended flywheel with \(J=0.12\) kg·m² and \(b=0.030\) N·m·s/rad has a 4.0 s time constant. A 0.30 N·m step from rest eventually gives 10 rad/s. The equilibrium gain and transient have the same mathematical form as the thermal problem. Their units and the physical meaning of a disturbance differ. A load torque enters the shaft equation directly. A change in ambient temperature enters the tank balance through \(H\). This distinction matters once the loop must reject disturbances.

Linearise a gravity-drained tank around an operating level

A model identified with one small power step can be accurate locally and fail after the operating point shifts. A tank with a gravity outlet illustrates this without invoking an unknown internal mechanism. Let its horizontal cross-sectional area \(A\) be constant and inlet flow \(q\) be directly controlled. Approximate outlet flow by \(c\sqrt h\), where \(h\) is liquid level above the outlet datum and \(c\) includes effective opening area and gravity. With incompressible liquid, mass conservation reduces to

\[A\dot h=q-c\sqrt h.\]

Both sides of this equation have units of volume per time.

At an equilibrium \(h_0>0\) the inlet is \(q_0=c\sqrt{h_0}\). Set \(h=h_0+\eta\) and \(q=q_0+u\), retaining only terms linear in the deviations. Since the tangent of \(c\sqrt h\) at \(h_0\) is \(c/(2\sqrt{h_0})\), the constant terms cancel and the incremental model is

\[A\dot\eta+k_h\eta=u,\]
\[k_h=\frac{c}{2\sqrt{h_0}},\]
\[K=1/k_h,\]
\[\tau=A/k_h .\]

The gain \(K\) converts inlet-flow change into equilibrium level change, while the time constant contains the additional storage area. Increasing level makes the outlet characteristic flatter, increasing both gain and time constant. At an empty tank the square-root derivative is singular; the small-signal model around a positive level cannot be continued through that point.

Compare a small step with a finite change

Let \(A=0.20\,\mathrm{m^2}\), \(h_0=0.25\,\mathrm m\), and \(q_0=0.0010\,\mathrm{m^3/s}\). Then \(c=0.0020\,\mathrm{m^{5/2}/s}\), \(k_h=0.0020\,\mathrm{m^2/s}\), \(K=500\,\mathrm{s/m^2}\) and \(\tau=100\,\mathrm s\). Increasing inlet flow by \(0.00010\,\mathrm{m^3/s}\) predicts a 0.050 m final rise in the linear model. The exact steady level is \((0.00110/0.0020)^2=0.3025\,\mathrm m\), a rise of 0.0525 m. Initially both models predict \(\dot h=0.00010/0.20=0.00050\,\mathrm{m/s}\), since the level has not yet changed. Immediate slope agreement therefore does not validate the predicted final gain.

Repeat the thought experiment for a 50% inlet increase. The linear result is 0.50 m absolute level, whereas the nonlinear equilibrium is 0.5625 m. The difference now matters for a level limit. An informative commissioning test uses small upward and downward steps of equal amplitude at more than one operating point. The tangent model predicts symmetric final increments; the measured curvature contributes a positive quadratic term to both absolute levels. Comparing that asymmetry with sensor uncertainty can distinguish a genuine level-dependent gain from a drifting measurement zero.

One can reconstruct the physical parameters independently from two parts of a measured step record. If a flow step of \(0.00010\,\mathrm{m^3/s}\) produces an initial level slope of \(0.00050\,\mathrm{m/s}\), the immediate mass balance gives \(A=\Delta q/\dot h(0)=0.20\,\mathrm{m^2}\), without knowing the outlet law. A sufficiently small steady rise of 0.050 m would separately give

\[k_h=\Delta q/\Delta h=0.0020\,\mathrm{m^2/s}.\]

Their quotient predicts the 100 s time scale. A sensor mounted behind a narrow side passage could delay the observed initial rise, making this area estimate too large without changing the final level. Comparing a direct sight-glass record with the remote sensor helps locate that additional lag before adding another state to the tank model.

Distinguish delay from a slow first-order response

Three devices have the same DC gain and the same area under their step-error curve, two seconds, but represent different mechanisms. A transport delay contributes a dead interval; two identical first-order states give the factor \((1+t)e^{-t}\) in the step error.

Distinguish delay from a slow first-order response. Horizontal axis: Time after command (s). Vertical axis: Output / final increment. Data follow the figure.
The delayed model initially remains at zero. The cascade rises smoothly with zero initial slope; the single lag begins with nonzero slope. A single recorded settling time is insufficient to distinguish these plant models.
Read values from the plot
Output / final increment at selected values of Time after command (s).
Time after command (s)Two-second lagOne-second delay, one-second lagTwo cascaded one-second lags
0000
20.632120.632120.59399
40.864660.950210.90842
60.950210.993260.98265
80.981680.999090.99698

Download all 401 plotted samples (CSV)

Interactive calculation · change the inputs of this example

Allocate more of the total error-area time to pure delay. Compare the dead interval with the initial slopes of the lag models.

The curves below are recalculated from this section’s equations in your browser. The fixed reference plot above remains available for comparison.

Study the full derivation

Estimating velocity from position with a model-based observer · System dynamics, feedback and estimation

An optical encoder returns position and the actuator drive supplies a commanded acceleration. Reconstruct an unmeasured velocity without differentiating successive noisy samples. Derive the observer, explain what a pair of chosen poles guarantees, and predict the tradeoff visible when the encoder carries periodic interference.