The demonstration in this video will show you the effect of proportional, derivative, and integral control on a real system. It’s a DC motor connected to an optical rotary encoder (quadrature) and is controlled by a digital control loop implemented on a TI Launch Pad MSP432. It uses a series of timers and interrupts to generate the PWM signals to the H-Bridge motor driver, read the pulses from the encoder, and calculate the control effort using a PID control algorithm. It also implements an anti-windup algorithm to improve the system stability since this is a real system and the motor saturates easily.
Code can be downloaded at his github page.
Via : TI E2E Community Blog