---
title: "Discrete PID realization and roles of P, I, D"
subject: "Digital Control System"
chapter: 4
key: "semester_6/digital_control_system:pid-discrete-realization-roles"
source: https://www.bctengineer.com/q/semester_6/digital_control_system/pid-discrete-realization-roles
site: BCT Engineering
---

# Discrete PID realization and roles of P, I, D

Digital Control System · Chapter 4: Design and Compensation of Discrete Time Control System

- Asked in: 2071 Bhadra, 5 marks
- Video: [The Realization of a PID Controller](https://www.youtube.com/watch?v=EHeH2OZ5f_o) — Abubakar Irfan
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/digital_control_system/pid-discrete-realization-roles
- Whole chapter: https://www.bctengineer.com/md/semester_6/digital_control_system/chapter-4

## Question

Explain how PID controller is realized in discrete time domain. Discuss the role of P, I and D parts.

## Short answer

A digital PID replaces the integral with a trapezoidal sum and the derivative with a backward difference. The velocity (recursive) form uses only the last two errors and last output. P responds to present error, I removes steady-state error by accumulating past error, and D anticipates future error by reacting to rate of change.

## Answer

A digital PID controller is obtained by replacing the integral and derivative of the analog PID law with sums and differences of the sampled error $e(kT)$.

#### Analog PID law
$$
m(t) = K\left[e(t) + \frac{1}{T_i}\int_0^t e(t)\,dt + T_d\frac{de(t)}{dt}\right]
$$

#### Discretization
- Integral by the trapezoidal rule, derivative by the backward difference:
$$
m(kT) = K\left\{e(kT) + \frac{T}{T_i}\sum_{h=1}^{k}\frac{e((h-1)T)+e(hT)}{2} + \frac{T_d}{T}\big[e(kT)-e((k-1)T)\big]\right\}
$$
- Taking the z-transform:
$$
\begin{aligned}
\frac{M(z)}{E(z)} = G_D(z) &= K_P + \frac{K_I}{1-z^{-1}} + K_D(1-z^{-1})\\
K_P = K - \frac{KT}{2T_i},\quad K_I &= \frac{KT}{T_i},\quad K_D = \frac{KT_d}{T}
\end{aligned}
$$

#### Realization (velocity / recursive form)
Multiplying by $(1-z^{-1})$ gives an algorithm that needs only the last two errors and the last output:
$$
m(k) = m(k-1) + (K_P+K_I+K_D)e(k) - (K_P+2K_D)e(k-1) + K_De(k-2)
$$
```text
          +--> [ KP ] -----------------+
          |                            v
 e(k) ----+--> [ KI/(1-z^-1) ] ---->( + )---> m(k)
          |                            ^
          +--> [ KD(1-z^-1) ] ---------+
```
The computer runs this equation once every sampling period, and the D/A converter with a zero-order hold applies $m(k)$ to the plant.

#### Role of each part
- **P (proportional):** gives an output proportional to the present error. A larger $K_P$ makes the response faster and reduces steady-state error, but too much gain causes overshoot and instability.
- **I (integral):** adds a pole at $z=1$ and accumulates past error. It removes steady-state error to a step (raises the system type by one) but adds phase lag, so it can make the response more oscillatory. Anti-windup is needed when the actuator saturates.
- **D (derivative):** responds to the rate of change of error, so it anticipates future error. It adds damping, reduces overshoot and improves stability, but it amplifies high-frequency measurement noise. It is often applied to the measured output instead of the error, with a filter.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is the analog PID law discretised in this answer?
   A. Integral by the trapezoidal rule, derivative by the backward difference
   B. Integral by backward difference, derivative by the trapezoidal rule
   C. Both by the forward difference
   D. Both by exact z-transform of the plant
   Answer: A. The integral is a trapezoidal sum, and the derivative is the backward difference [e(kT) - e((k-1)T)]/T. (Key point: Discretisation method)

2. In G_D(z) = KP + KI/(1 - z^-1) + KD(1 - z^-1), the integral and derivative gains are:
   A. KI = K Ti/T, KD = K T/Td
   B. KI = K T/Ti, KD = K Td/T
   C. KI = K Ti, KD = K Td
   D. KI = K/T, KD = K T
   Answer: B. KI = KT/Ti and KD = K Td/T, with KP = K - KT/(2Ti). (Key point: Digital PID gains)

3. What does the velocity (recursive) form of the algorithm need to compute m(k)?
   A. The whole error history
   B. Only the current error
   C. Only the last output and the last two errors plus the current one
   D. The plant model
   Answer: C. m(k) = m(k-1) + (KP+KI+KD)e(k) - (KP+2KD)e(k-1) + KD e(k-2), so only a few past values are stored. (Key point: Recursive form)

4. What is the main role of the I part?
   A. It adds damping and reduces overshoot
   B. It anticipates future error
   C. It increases speed without side-effects
   D. It removes steady-state error to a step by adding a pole at z = 1, at the cost of phase lag
   Answer: D. The integrator raises system type by one, but adds lag and may need anti-windup. (Key point: Role of integral part)

5. What is the drawback of the D part?
   A. It amplifies high-frequency measurement noise
   B. It increases steady-state error
   C. It removes the integral action
   D. It reduces stability
   Answer: A. D adds damping and anticipates error, but it amplifies noise, so it is often filtered or applied to the output. (Key point: Role of derivative part)

## Related in Digital Control System

- [Pulse TF with PID controller, plant 1/(s+1)](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Apid-pulse-tf-first-order) — Digital Control System, chapter 3, asked 2×
- [Pulse transfer function of digital PID controller](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Aderive-pid-pulse-tf) — Digital Control System, chapter 3, asked 2×
- [Controller design for peak time ≤ 1.2 s (ζ = 0.5)](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Adesign-peak-time-zeta-0-5) — Digital Control System, chapter 4, asked 2×
- [Controller design for peak time 1.2 s (ζ = 0.55), Kv](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Adesign-peak-time-zeta-0-55) — Digital Control System, chapter 4, asked 2×
- [Closed-loop TF with digital PID, plant 1/(s(s+1))](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Apid-closed-loop-plant-s1) — Digital Control System, chapter 3, asked 2×
- [Pulse TF with digital PID, plant 1/(s(s+2))](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Apid-pulse-tf-plant-s2) — Digital Control System, chapter 3

## Related in other subjects

- [PID controller block diagram, transfer function, characteristics](https://www.bctengineer.com/question.md?key=semester_3%2Fcontrol_systems%3Apid-bd-tf-characteristics) — Control Systems, chapter 7
- [PID controller types and applications](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Apid-types-realtime-application) — Embedded System, chapter 7
- [LTI system output in time domain](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Alti-output-time-domain) — Communication Systems, chapter 1
- [Single tone DSB-FC AM in time and frequency domain](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Asingle-tone-dsbfc-time-freq) — Communication Systems, chapter 2
