TMS320F28P650DK: PID controller Tuning

Part Number: TMS320F28P650DK
Other Parts Discussed in Thread: POWERSUITE

Hi,

 

I've been updating the control variables directly from the Expressions window when tuning my converter. Am I allowed to do that? Could there be any issues with that?



I'm seeing that there is an “on-the-fly” operation option in section 2.4 of the DCL User's Guide but I'm having a hard time understanding how to make the updates. Could I just add the SPS variable (ex. pid1.sps.Kp) to the Expressions window and update it there? Then how would I enable the update flag and update the PID?

If I don't use the “on-the-fly” option, what would be the correct wat to update the PID variables? would I have to recompile the code every time?

  • Hi,

    The  "on the fly" here is not referring to be able to change the parameters through CCS window at any instance, it really about doing it w/o stopping the control loop. 

    Yes,  recompile the code w/ the parameters needed. 

    Regards.

  • Hi,

    What issues could i come across with doing it they way I've been doing with updating the Kp, Ki, and Kd, variables in the Expressions window?

    When you say "w/o stopping the control loop." does that mean I don't have to terminate the debug session and I can update the PID variables while the code is running? If so, what is the process of updating the PID variables? Where do I update the values of the PID variables while the code is running?




  • Hi ,

    When using the expressions window we are really changing the values w/o disabling the interrupts. The on the fly here is basically managing the timing so the loop's core calculations are not interrupted or corrupted to disrupt the stability of the control loop.

    The mechanism of pend through DCL_REQUEST_UPDATE and then updating the parameters through DCL_updatePID()  handles this to ensure controllers do not run with partially set variables. Updating controller parameters is a time critical task since interrupts must be disabled while copying from shadow to loading tuning parameters takes place.

     Which is why recompile is the recommendation & not using expressions window to get this done. 

    Regards.

  • How do I run the DCL_REQUEST_UPDATE and DCL_updatePID() functions while the code is running?

    When I'm ready to test a new value for a PID variable, where do I update the variable and how do I then engage the DCL_REQUEST_UPDATE and DCL_updatePID(). How is this done practically? What would be your process of achieving this?

    For example, if I am applying a load step to the output of the converter and I wanted to adjust Kp, observe response, then adjust Ki, observe response, how would you practically do that using the SPS and CSS?

  • Hi ,

    We cannot run DCL_REQUEST_UPDATE and DCL_updatePID() outside the code at compile time .  The variable have to be updated in the code.  Everything in the code. So we choose the parameters change the value in code for eg. KP then recompile , load and then check. Redo for Ki next.

    Code will be something on these lines.

        // In main, link the controller to the SPS and CSS structures
        pid1.sps = &spid;
        pid1.css = &cpid;
        
        // Initial parameter setup (or use defaults)
        pid1.sps->Kp = 0.5f;
        pid1.sps->Ki = 0.1f;
        pid1.sps->Umax = 1.0f;
        pid1.sps->Umin = -1.0f;
    
        // Acknowledge the initial request to update
        DCL_REQUEST_UPDATE(&pid1);
        DCL_updatePID(&pid1);

    On a side note , powersuite is a tools package that can be used to get the PID tuning and check the control system etc 

    https://www.ti.com/tool/POWERSUITE

    Regards.

  • Hi,

    So the idea would be to periodically update the DCL_REQUEST_UPDATE and DCL_updatePID() in the code and in order to see a change to a PID variables?

    For example, if I wanted to change Kp from 0.5 to 1, I would update Kp in the code and then save the code then when DCL_REQUEST_UPDATE and DCL_updatePID() runs again, it will update without having to recompile the project?

  • Hi,

    Overall yes the idea is to periodically update the DCL_REQUEST_UPDATE and DCL_updatePID() in the code after we load the variables we want into the shadow variables ie the pid1.sps. 

    I am not clear on the save code but not compile. Simply saving the Kp in the code will not give the data to the variables / pid1.sps unless its recompiled and rerun the code.

    One thing you could try is:

    • Reset and restart the code in CCS
    • Put a break point at the DCL_REQUEST_UPDATE
    • Run the code from start it will halt before running DCL_REQUEST_UPDATE
    • Update the pid1.sps in CCS watch expression and then run the code to completion

    It might be able to serve for what your trying to do. This way you can avoid multiple recompiles but its not ideal since everytime you halt you will stop any possible interrupts from being processed realtime/ missed but if the goal is more to check the PID and not other interrupts or control func in the example for now this could work.