QSPICE Schematic Capture “Discrete-Time PI Controller Written in C++"

Well… I am not entirely sure it is a discrete-time controller, as the math samples at every simulation step.
Here is a discrete-time PID controller project for reference:
https://forum.qorvo.com/t/c-pid-controller-for-qspice-community-project/15690

Regardless of what it is, here are two modifications to the code for a more standard approach when working with Qspice C++:

  1. Change the static variables to member variables (to handle things better if, in the future, you need to include Trunc() for timestep modification).
  2. Make Kp and Ki input attributes instead of hardcoding them into the code.

Closed loop control with the gate driver.qsch (31.9 KB)
buck_conv_pwm.cpp (4.3 KB)

3 Likes