PI Controller Example

Overview

This example demonstrates the use of the Digital Control Library (DCL) Proportional-Integral (PI) controller. The PI controller is one of the most widely used feedback controllers in industrial control systems for:

  • Motor speed control

  • Temperature regulation

  • Voltage/current regulation

  • Position control systems

  • Process control applications

What the Example Does

The example:

  1. Initializes a Series PI controller with predefined gain parameters

  2. Processes control loop iterations with reference and feedback inputs

  3. Computes control output (uk) based on error between reference (rk) and feedback (yk)

  4. Compares computed outputs against expected reference values

  5. Measures and reports execution performance in CPU cycles

  6. Validates correctness by comparing results with an error tolerance

Expected Output

The example prints:

  • Total execution cycles for all iterations

  • Average execution cycles per iteration

  • Number of errors detected (should be 0 for PASS)

  • Individual failure messages if any output differs from expected value

Usage Notes

Customization

You can modify the example by:

  • Adjusting controller gains (Kp, Ki) in dcl_pi_example.h

  • Changing output limits (Umax, Umin) or integrator limits (Imax, Imin)

  • Modifying NUM_ELEMENTS to process more or fewer samples

  • Replacing test data files in the data/ directory

  • Switching to different PI controller variants

External Connections

None required. This is a software-only computational example.