This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use PID control library

Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

I wanted to understand how to implement the available PID library. I have attached the file:pi.h

Is there a document to understand its use ?

What will be the output of PID ? will it be in counts ? and in how many bits format ? or will it be within max and min. range ?

I'm using F28069 device

Please provide the necessary help on implementing PID. I wanted to work with adjustable ramp up and down rates using PID control. 

  • Ravi,

    The code is part of the DMC library and is documented in the attachment.  If you have controlSUITE installed in the default location, the full document will be at:
    C:\ti\controlSUITE\libs\app_libs\motor_control\math_blocks\v4.3\~Docs

    The code uses the IQ format data (see IQmath library), so the numeric range and precision is adjustable by the user in the IQmathLib.h header file.  The default format is Q24: that is, 24 bits of precision and 8 bits of range. 

    The output is saturated to the user defined Umax and Umin limits, defined in the PI C structure. In the context of FOC motor control, the PI controller is typically used to close both inner current control loops.  In this case the output of each controller would be a rotational reference frame voltage. 

    The outer speed or position loop would likely be a PID controller, an example of which you can find in the same library. As you mention adjustable ramp up & down rates I think this is what you mean.  The PID implementation can be found on pages 95 - 93 of the same document.  It's structure and implementation is similar to the PI controller.  In FOC, it's output would typically be a q-frame reference current.

    Since you are using a floating point device, you may like to know there is a newer library of control functions (DCL) in C2000Ware, which you can download at:
    http://www.ti.com/tool/c2000ware

    I'm not sure the extent to which this answers your questions so please post back if anything's unclear.

    Regards,

    Richard

    PI section from DMC MATH_v13.1.pdf

  • Sir,

    I wanted to start by implementing PI control, then I will try ramp control using PI.

    With the PI library that I had attached, for initialization I had used:

    PI_CONTROLLER closed_loop = PI_CONTROLLER_DEFAULTS;

    closed_loop.Ref = setpoint;
    closed_loop.Fbk = parameter_to_be_controlled;
    PI_MACRO(closed_loop); 

    & for tuning I'm using: closed_loop.Kp and closed_loop.Ki values having limits: closed_loop.Umax = _IQ(1) and closed_loop.Umin = _IQ(-1)

    but, the closed_loop.Out value in debug window doesn't appear in floating point, its always integer value and it also exceeds the range Umax and Umin.

    Please help in understanding. 

  • Ravi,

    All the IQ variables will appear as integers unless you have the MATH_TYPE definition set to FLOAT_MATH in your IQmathLib.h file. You are using a floating-point part so you could compile like that if you want to, but since closed_loop.Out is showing as integer in the watch window I think you have it set to IQ_MATH.

    Also in IQmathLib.h, check what your GLOBAL_Q setting is. That has to match the Q value of the watch window or the numbers won't be aligned. In the Expressions window in CCS, right-click on the Type column for the closed_loop.Out variable and set the Q value to match your GLOBAL_Q selection. You should then see the right number.

    Regards,

    Richard