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.

TMS320F28075: ControlSUIT library to use for implmenting PI controller

Part Number: TMS320F28075
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Hello,

I am implementing PFC on my C2000 28075 controller and right now I have obtained a working Simulink model. Next step is to move to the code implementation.

I need to implement 2-3 PI controllers as part of my logic.

Do i need to discreetise and convert the PI Kp Ki to a "Difference equation" form (in terms of a0 a1 b0 b1 etc) to implement this in the controller ?

I went through the ControlSUITE resources and in these the implementations seem to suggest a direct implementation without the difference equation conversion.

Which is correct and which library do i use for this?

  • Hi Mat,

    Mathew J Manavalan said:
    Which is correct and which library do i use for this?

    You can refer: PID_GRANDO_F.h

    C:\ti\controlSUITE\libs\app_libs\solar\v1.2\float\include

    Regards,

    Gautam

  • Thanks for the response.

    Do i need to discreetize my whole system and then re-calculate the Kp Ki values in order to use this?

    Also, I also found another PI controller implementation here : C:\ti\controlSUITE\libs\control\DCL\v1_00_00_00

    What is the difference between this and the one that you have indicated?

    Thanks again. Waiting for your response.
  • Matthew,

    The controller Gautam recommended was developed as part of a motor control library several years ago. It has a C macro format which is compatible with that library.

    The DCL is a more recent library of control functions written for floating-point devices such as the F28075. The DCL functions are not tied to a particular device or library. I recommend you use version 2.0 of the DCL, which you can find in C2000Ware, here: http://www.ti.com/tool/c2000ware

    If you are starting with an analog PI controller model in Simulink and you know the gains you need, then yes, you will need to adjust those gains to account for the discrete time controller. There is a document " PI Controller Equations.pdf" on this page which may help you:
    https://sites.google.com/site/controltheoryseminars/home/downloads

    You will also need to account for the A/D and D/A gains.

    It is possible to emulate the PI controller using a 2P2Z structure, in which case you would need to find the difference equation and the {ai bi} coefficients you mentioned. However, the actual PI controller will be easier to use and give you better performance because it handles integrator wind-up.

    Regards,

    Richard

  • Thank you Richard for the response.

    I was looking at the "PI Controller Equations.pdf" that you have referred to and ive picked out the relevant ones that I need to convert my Kp Ki values in Continuous domain to Discreet domain so that I can use them in the DCL PI Controller implementation.

        

    Where A is given by the below formula and T is the sampling time at which I run the controller loop in my C2000 microcontroller.

     

    But the problem here is that after applying the conversion for Kp and Ki, I am getting a very high value for the Proportional gain which doesn't seem right.

    Have I missed anything in this? Can you please validate whatever I have said above?

    Thanks again. 

    Mathew

  • Mathew,

    Thank you for pointing this out.  The gain matching method I put in the document won't work, at least not with an integrator.  I need to re-write that part of it.

    If your sample rate is over 100Hz or so the correct gain matching number will come out to very close to 1, in which case you can safely set A = 1 and use equations (12) and (13) to find the discrete PI coefficients.

    I'm sorry about this mistake.  I will post back once I have modified the document.

    Regards,

    Richard

  • Richard,

    Thanks for the input. Our sample rate is 20KHz. We will try to proceed with the gain corrected values as indicated above (by using A = 1).

    Please do post back once the modified equations have been updated in the document. It'll be very helpful for us.

    I also wanted to know more about "You will also need to account for the A/D and D/A gains.". Any resources you can point us to regarding this?

    Thanks in advance,
    Mathew
  • Mathew,

    Sorry, I updated the document over the week-end but have been travelling for a couple of days and unable to respond on the Forum.  You can download the modified version on the website I sent earlier.

    Apart from calculating the discrete PI gains, there are a couple of other factors you'll need to take into account when you implement any digital controller.  Among these are the numerical "gains" which take place as the signals pass across the A/D and D/A boundaries.  These depend on the resolution of the data converters.   You would typically normalize e(k) to +/-1.  If you're simulating your system, or carrying over PI settings from an analog design, you will need to remember to include this.

    Regards,

    Richard

    Data Converter Gain.pdf

  • Thank you again Richard for your inputs.

    We have proceeded with the implementation on the controller as suggested but we are facing some stability issues.

    Regarding the "gains" that you have mentioned, what we have attempted to do within our control loop is to scale up the input signals in such a way that, within the control loop I am using the actual physical values for all the signals (voltages and currents).

    eg : 100Vrms AC is scaled down in my power isolation board and given to my ADC in a scaled of around 1V. This i read in via my 12-bit ADC and knowing my scaling factor (which I measure via some calibration steps) I scale up the read value to 100V. Is this done usually? We choose this since this way we are staying as close to the Simulink simulation as possible. Now i am wondering if this is the right method since you have mentioned the e(k) being normalized to +/-1. Can you comment on this?

    Also, apart from the gains for the ADC and PWMs, how do we compensate for the delays of the ADCs and PWMs? Wont that affect our system?

    Looking forward to your response.

    Mathew
  • Mathew,

    Sorry for my late reply - I have been on vacation since just before your last post.

    Generally most people normalize (scale) the inputs to the controller to +/-1.  This is very important on fixed-point machines to manage numeric range and resolution.  You have a floating-point core so numerical over-flow will be less of an issue, but the resolution now depends on the magnitude of the number. You can have issues if you are combining very large and small variables.  It's impossible to give general guidelines. 

    What we do here is to simulate the controller using single-precision data type (there is a Simulink conversion block for that), then capture a set of input and output data, and run them through the hand coded controller on a real target device.  This way we can have confidence the controller code is behaving predictably and there aren't any numerical issues.

    You are correct that delays through the data converters will affect the system.  Any time delay translates into a phase lag which is proportional to frequency (see attached).  You have to account for it in the compensator design. 

    Regards,

    Richard

    Time Delay.pdf

  • Hello Richard,

    Sorry for the lack of updates. We have decided to go with a more analytical approach for our control system design. We hope to get the system to a certain level of stability. After which we plan to run an analysis to quantify the system stability etc.

    Thanks for the support!

    Thanks,
    Mathew JM