Your Equation

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

Solve for
01
1/s
0.15
s
0.0050.1
0.011
1500
  • 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.

Integral term after n samples () current value 0.05
xI,0Initial integral stateKey driver
1.05
nNumber of samples
0.0010.5
eConstant error
0.0050.5
KiIntegral gain
0.010.5
TsSample interval
0.01250.25
  • 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

VariableTypical rangeLowest resultHighest resultSwing ()Local stepChange in result
xI,0 Initial integral state0 to 1 0.051.051+10%0 %
n Number of samples1 to 500 0.0010.50.499+1 +2 %
e Constant error0.01 to 1 0.0050.50.495+10%+10 %
Ki Integral gain0.1 to 5 1/s0.010.50.49+10%+10 %
Ts Sample interval0.005 to 0.1 s0.01250.250.2375+10%+10 %

Sweep of Number of samples

Number of samplesIntegral term after n samples
10.001
63.380.06338
125.80.1258
188.10.1881
250.50.2505
312.90.3129
375.30.3753
437.60.4376
5000.5

Sweep one variable

Integral term after n samples ()Hover, touch, or use the arrow keys on the chart
00.10.20.30.40.5 100200300400500 Number of samples now 0.05

Variables and how each one contributes

xI,n

Integral term after n samples

Result ·

What the equation gives you. Everything else feeds it.

xI,0

Initial integral state

· typical 0 to 1

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.

Ki

Integral gain

1/s · typical 0.1 to 5

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.

Ts

Sample interval

s · typical 0.005 to 0.1

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.

e

Constant error

· typical 0.01 to 1

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.

n

Number of samples

· typical 1 to 500

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

  1. Increment each sample: KiTse = 0.5 × 0.02 × 0.1 = 0.001.
  2. Growth over 50 samples: n × 0.001 = 0.05.
  3. 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, ...

Related formulas

Practise this formula