3 Replies Latest reply on Sep 18, 2020 2:35 AM by BoTa_264741

    Scaling PID loop floating point output to PWM block

    RiTa_288331

      Greetings All!

       

      The answer to this question may be painfully obvious, but I'm just not "seeing" it yet.

       

      I'm using a PSOC6 (M4 core with floating point) to close a PID loop on a simple DC-DC boost converter (inner current loop only for now).  I'm setting a desired current value (let's say 1 amp), and I'm measuring the actual current, and I pass the error through the PI loop (for now, my loop is just a PI loop - no derivative gain).

       

      The PWM element I'm using to drive the switching transistor is:

      50kHz

      PWM counter is 16 bits

      period = 1000 counts (so valid compare values are from 0 [0% duty] to 1000 [100% duty])

      Center aligned

       

      --> Once I have the output of the PI loop controller (in floating point), how do I scale this to a value of 0 to 1000 for the PWM generation?