Library / Control engineering / CTL-12
Control engineering
Discrete integral term after n samples
Value of the integral term after n samples of a constant error, using the backward-rectangle update of a digital controller.
- Ref
- CTL-12
- Rev
- v1
- Field
- Control engineering
- Result
- xI,n
The backward-rectangle update xI[k] = xI[k−1] + KiTse[k] adds one slice of area Kie Ts every sample. For a constant error the n-sample sum is simply n KiTse, which is what a continuous integrator Kie t would give after the time t = nTs.
Value of the integral term after n samples of a constant error, using the backward-rectangle update of a digital controller. Each sample adds KiTse, as in xI[k] = xI[k−1] + KiTse[k].
Calculator
- Increment per sample, KiTse0.001
- Elapsed time, nTs1 s
- Samples needed to add one unit, 1/(KiTse)1,000
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- At the defaults each sample adds 0.001, so after 50 samples (1 s) the integral term has grown from 0 to 0.05. It would take 1,000 samples to add a whole unit.
- For a constant error the discrete sum equals the exact continuous integral Kie t = 0.05. When the error varies, the backward-rectangle rule adds a small timing error of order Ts, which matters only if Ts is not short compared with the loop.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing () | Local step | Change in result |
|---|---|---|---|---|---|---|
| xI,0 Initial integral state | 0 to 1 | 0.05 | 1.05 | 1 | +10% | 0 % |
| n Number of samples | 1 to 500 | 0.001 | 0.5 | 0.499 | +1 | +2 % |
| e Constant error | 0.01 to 1 | 0.005 | 0.5 | 0.495 | +10% | +10 % |
| Ki Integral gain | 0.1 to 5 1/s | 0.01 | 0.5 | 0.49 | +10% | +10 % |
| Ts Sample interval | 0.005 to 0.1 s | 0.0125 | 0.25 | 0.2375 | +10% | +10 % |
Sweep of Number of samples
| Number of samples | Integral term after n samples |
|---|---|
| 1 | 0.001 |
| 63.38 | 0.06338 |
| 125.8 | 0.1258 |
| 188.1 | 0.1881 |
| 250.5 | 0.2505 |
| 312.9 | 0.3129 |
| 375.3 | 0.3753 |
| 437.6 | 0.4376 |
| 500 | 0.5 |
Sweep one variable
Variables and how each one contributes
Integral term after n samples
What the equation gives you. Everything else feeds it.
Initial integral state
The integral state at the start (sample 0), in actuator units. Adds one-for-one to the result: the starting value is carried unchanged. Raising it by 0.1 (to 0.1) moves the result by +200 %, from 0.05 to 0.15.
Integral gain
The integral gain in 1/s. Directly proportional: the growth of the integral term scales with Ki. Raising it by 10 % (to 0.55) moves the result by +10 %, from 0.05 to 0.055.
Sample interval
The sample interval in s. For the same number of samples, a longer sample interval covers more time, so the integral grows more. Raising it by 10 % (to 0.022) moves the result by +10 %, from 0.05 to 0.055.
Constant error
The error, held constant over the samples. Directly proportional: a larger error integrates faster. Raising it by 10 % (to 0.11) moves the result by +10 %, from 0.05 to 0.055.
Number of samples
The number of samples counted since the start, a whole number. Directly proportional: the term grows by the same amount every sample. Raising it by 10 (to 60) moves the result by +20 %, from 0.05 to 0.06.
Worked example with the values above
- Increment each sample: KiTse = 0.5 × 0.02 × 0.1 = 0.001.
- Growth over 50 samples: n × 0.001 = 0.05.
- xI,n = 0 + 0.05 = 0.05.
Assumptions and limits
- A constant error and a fixed sample interval, with the backward-rectangle (rectangular) integration rule.
- No saturation: with a limit the term must be clamped or protected against windup.
Common mistakes
- Leaving Ts out of the update, so the effective integral gain depends on the loop rate.
- Not initialising or tracking xI when the controller is switched on or changes mode, which causes a bump in the output.
Statistics and uncertainty
Accumulating many small increments in floating-point arithmetic loses precision when the increment is tiny compared with the state, which can happen with a very small Ts in single precision. A sensor offset in e is integrated like a signal: an offset of 1 % in e adds 1 % to the growth rate, and it never averages out.
Where it is used
- Implementing the integral term of a digital PID controller.
- Predicting how quickly the integral action will remove an error at a given sample rate.
Maths you need
- Numerical integration: adding area slices of width Ts
- Sampled signals: values at k = 0, 1, 2, ...