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.

PID code in C2000 (F28027)

Hello Experts,

I'm planing to implement 6 PID  controllers in a single loop ,in that case my  T will be assumed same for all 6 by assuming the code execution time is negligible at  60MHz and i sample all 6 ADCs(feedbacks) before entering to the control equation .  my PID implementations are based on discreet equation 

    U[k] = U[k-1] + b0e[k]+b1e[k-1]+b2e[k-2]   // where i can directly scale and fix the Umax n Umin to PWM limits,

my problems are  ,1. e should be a signed value for this implementation to  work properly  or else U end-up  being Umax short after loop execution, and i don't think resetting U is not a good engineering practice as this would give very unpredictable behavior right in middle of the execution of control. Has anyone tried a PID in this form with signed integer or double ?... please share your experience .

   

2. Has anyone tried to implement at least 3 PID controls in a single shot ? if so, up to what extend my assumption can be practical  ?

thanks

  • Hi Darshana,

    First of all, your execution time may override sampling time as you intend to execute 6 PID controllers that too with inbuilt math operators. I would suggest you to use iQmath libraries for optimal usage of cpu and cut off your execution time. By doing so your PID controllers would be far more efficient than by using  signed integers! 

    We've executed 3 PID controllers in a single loop but using floating point controller F28335; also we intend to use more than 6 in near future. Yours being a fixed point controller you'll find some limitations executing  these PI loops. To keeps your hopes alive, I've implemented the same using iQmath lib. 

    Regards,

    Gautam

  • Thanks Gautham,

    Great to know you have already done this but my  objective is to implement this on a non floating point processor (a low cost platform if i said more correctly )  a rough outline would be like this(not the actual code) ,

    PID loop {
    Y1=ADC1();    //sampling  feedback 1   to   6  ,yes I know this  part would be time consuming  but  at
    Y2=ADC2();   //12.5 MSPS sample rate (assume I used half of the above sample rate, actually I don’t need
    Y3=ADC3();  // that much  for a position control system operate in a much more slower speed
    Y4=ADC4();  //lets say linear actuators with 100mm/s to be more subjective.
    Y5=ADC5();
    Y6=ADC6();  
    e13=e12;
    e12=e11;
    e11=Y1-setpoint1;    // initializing error for each pid  this can be implemented in a simple for loop
     
    U11delta= b110e[k] + b111e[k-1]+b112e[k-2] ;
    U11=  U11+U11delta             ;                                               //again  this can be done in a simple for loop for all 6
      If ( U11> Umax)    U11=Umax;
      If ( U11< Umin)    U11=Umin; 

    //no more codes

    1.so my point is above simple operations are  less than 1ms for a 60Mhz clocked MCU or if we do consider the execution time it becomes much more predictable execution time.  do you think this type of implementation will have a greatly reduced control impact on a DC motor position control system ?

    2. in my application all six actuators are operated at the same time hence no need to handle different interrupts for all six pids  only the ADC sampling will play a part in applying offset for sampling time again i think within ps range.

    your opinion on this matter is highly appreciated

      thanks again,

                 
  • Exactly Darshana, thats what I'm telling you; use iQmath library to be on the safer side as the performance of your fixed point controller would be boosted tremendously. Consuming 1ms for the above steps is too much. The only issue is that, implementing PI loop using iQmath lib. would be quite complicated. 

    I'm 100% sure that using the iQmath library itself will solve you problem and put you in a safer zone; coz overriding of execution time over sampling time is the biggest issue in your example.

    Just do the following:

    1. Using a DSO check for the duration of your PI loop (ie the whole execution part) and ADCsampling rate

    2. Set the sampling rate accordingly by altering the sampling clock; such that every time you enter the loop you get a fresh ADC value.

    This would help you stabilize your system.

    Regards,

    Gautam

  • Thanks Gautam,

    I think i should compare the 2 implementation and see the results for one pid loop  

  • Yup Darshana, do share your results later.

    Regards,

    Gautam