• AVR Freaks

Hot!Anti-Windup of smps_control_library PID

Author
HiMountain
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/05/30 20:08:28
  • Location: 0
  • Status: offline
2021/01/22 05:09:47 (permalink)
0

Anti-Windup of smps_control_library PID

I'm calling _SMPS_ControllerPIDUpdate_HW_Accel in <smps_control_library_v2018_02_28>.
During this PID function ,there's no Anti-Windup function for Integrator which cause a slow response for dynamic control .
I use two loops in one battery charger application , one is voltage loop and the other one is current loop.These two loops are running independently ,and the output get the smaller one of them.
In some specific condition ,voltage loop output is slowly rising ,but the current loop has already Saturated。Due to the PID has no anti-windup function ,the current loop perform a very slow response to the big charging current .
Here's question :
       How to clamp the ACCA to a limited range before save to alternative register W3,4,5 ?
      This loop has two control loop ,so code efficiency is important.
      The Chips is dsPIC33EP64GS506
      Thanks !
 
Benson
      
 ; Save accumulator for next iteration
;How to clamp the ACCA value befor save to w3,4,5?
      mov ACCAL, w3
      mov ACCAH, w14
      mov ACCAU, w5

      ; Initialize Scale-factor and multiply
      sac.r a, w4 ; w4 = Rnd(ACCAH)
      mpy w4*w6, a ; Multiply control output with 'postScalar' value
   
   
   ; Backwards normalization & write back
      sftac a, w7 ; 'postShift' backward normalization to compensate coefficient scaling
      sac.r a, w4 ; w4 = Rnd(ACCAH)

      ; Clamp to minimum if needed
      cpsgt w4, w11 ; Check if u[n] > minClamp. If true, the next instruction is discarded and a Nop() is executed
                          ; If not true, execute next instruction
      mov w11, w4 ; Update u[n] with minClamp value

      ; Clamp to maximum if needed
      cpslt w4, w12 ; Check if u[n] < maxClamp. If true, the next instruction is discarded and a Nop() is executed
                          ; If not true, execute next instruction
      mov w12, w4 ; Update u[n] with maxClamp value

      mov w4, [w2] ; Update the target register (Output): [w2] = PDCx/CMPxDAC

#1

2 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 4114
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anti-Windup of smps_control_library PID 2021/01/22 08:46:04 (permalink)
    4 (1)
    I do not really understand your question: the code you posted shows some clamping action !
    It's just that this clamping is done post saving ACCA to w5:w4:w3. (I suppose "w14" is a typo - not your real code.)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    HiMountain
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/05/30 20:08:28
    • Location: 0
    • Status: offline
    Re: Anti-Windup of smps_control_library PID 2021/01/23 19:18:17 (permalink)
    0
    Currently solve this issue by adding flag to check if output is reaching the limited range.
       when the output reach the maximum , the Integrator won't accumulate the positive error 
       when the output reach the minimum ,the Integrator won't accumulate the negative error .
    By doing this ,more than 10 instructions is added. Any one has a better ideal for the SMPS control lib ? 
    #3
    Jump to:
    © 2021 APG vNext Commercial Version 4.5