Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

STEP PID

smarmiroli
2020-05-07
2020-05-11
  • smarmiroli - 2020-05-07

    I'm sorry but there is a problem with the link that i have sent

    the function that i have to replicate is this:

    FB_CTRL_STEP_PID
    fb_ctrl_step_pid
    The function block controls a digitally manipulated variable for integrating actuators. It is based on a standard PID controller with an additional binary output signal along with the analog output and operates without a precise position feedback signal.

    The position feedback signal required to calculate the controller output, is estimated with the help of the limiting values and the time required to reach those limits. The function block then creates pulses based necessary to drive the actuator such as a servo motor.

    the step pid are typically used to control a temperature with one output that heats and one that cools, and this is what I have to do

     
    πŸ‘
    2

    Last edit: smarmiroli 2020-05-07
  • smarmiroli - 2020-05-07

    'm sorry but there is a problem with the link that i have sent

    the function that i have to replicate is this:

    FB_CTRL_STEP_PID
    fb_ctrl_step_pid
    The function block controls a digitally manipulated variable for integrating actuators. It is based on a standard PID controller with an additional binary output signal along with the analog output and operates without a precise position feedback signal.

    The position feedback signal required to calculate the controller output, is estimated with the help of the limiting values and the time required to reach those limits. The function block then creates pulses based necessary to drive the actuator such as a servo motor.

    the step pid are typically used to control a temperature with one output that heats and one that cools, and this is what I have to do

     
  • gatto

    gatto - 2020-05-08

    Hi, for control a temperature with one output that heats and one that cools, you can use Three-point controls.
    ThreePointController: Function block for implementing a three-point control
    ThreePointControllerWithValueHysteresis: Function block for implementing a three-point control with
    value-based modulation
    (Part of Control Loop Library)

     
  • smarmiroli - 2020-05-08

    thanks, I try with the ThreePointController, although I preferred to be able to interact with a control system with PI parameters, thanks a lot anyway

     
  • smarmiroli - 2020-05-11

    This is my personal solution.. it works!!:

    FUNCTION_BLOCK fb_ctrl_step
    VAR_INPUT
    // parametri PID
    actualValue : REAL;// valore reale della variabile di controllo
    setPoint : REAL;// valore di impostazione desiderato
    kP : REAL;// costante proporzionale
    kI : REAL;// costante integrale
    // gestione uscite UP DOWN
    limitSwitchUp : BOOL;// fine corsa massima salita
    limitSwitchDn : BOOL;// fine corsa meccanico di massima discesa
    minPulseUpDuration : TIME;// durata minima dell'impulso di salita
    maxPulseUpDuration : TIME;// durata massima dell'impulso di salita
    minPulseDnDuration : TIME;// durata minima dell'impulso di discesa
    maxPulseDnDuration : TIME;// durata massima dell'impulso di discesa
    pausePulseUpDuration : TIME;// duarata pausa impulso di salita
    pausePulseDnDuration : TIME;// durata pausa impulso di discesa
    // gestione manuali
    manualMode : BOOL; // modalitΓ 
    manualUp: BOOL;
    manualDn:BOOL;
    END_VAR

    VAR_OUTPUT
    qUp:BOOL; // uscita per aumentare
    qDn :BOOL; // uscita per diminuire
    END_VAR
    VAR
    oscatPI: OSCAT_BASIC.CTRL_PI;
    oscatHyst3: OSCAT_BASIC.HYST_3;

    upCommandRising : R_TRIG;
    dnCommandRising : R_TRIG;
    
    oscatGenPulseUp:OSCAT_BASIC.GEN_PULSE;
    oscatGenPulseDn:OSCAT_BASIC.GEN_PULSE;
    

    END_VAR

    oscatPI(
    ACT:= actualValue,// valore di processo
    SET:= setPoint, // setpoint
    SUP:= 0 , // soppressione (0)
    OFS:= 0, // offset da sommare (0)
    M_I:= 0, // output se in manuale
    MAN:= manualMode, // manuale
    RST:= manualMode, // reset - il pid si resetta in manuale
    KP:= kP, // costante proporzionale
    KI:= kI, // costante integrale
    LL:= -1*TIME_TO_REAL(maxPulseDnDuration), // limite inferiore Γ¨ la durata massima dell'impulso di salita
    LH:= TIME_TO_REAL(maxPulseUpDuration), // Γ¨ la durata massima dell'impulso di discesa
    //Y=>y ,// uscita del filtro
    );

    oscatHyst3(
    in:= oscatPi.Y,
    hyst:=0.1 ,
    val1:= -1* TIME_TO_REAL(minPulseDnDuration) ,
    val2:= TIME_TO_REAL(minPulseUpDuration) ,
    //Q1=> comando di discesa ,
    //Q2=> comando di salita
    );

    // discesa
    oscatGenPulseDn.ENQ S= oscatHyst3.Q1 AND NOT oscatGenPulseUp.ENQ ;
    oscatGenPulseDn.ENQ R= NOT oscatHyst3.Q1 AND oscatGenPulseDn.Q ;
    oscatGenPulseDn( PTH:= REAL_TO_TIME (-1* MIN(oscatPI.y,oscatHyst3.val1)) ,
    PTL := pausePulseDnDuration ,
    //Q=>
    );

    // salita
    oscatGenPulseUp.ENQ S= oscatHyst3.Q2 AND NOT oscatGenPulseDn.ENQ ;
    oscatGenPulseUp.ENQ R= NOT oscatHyst3.Q2 AND oscatGenPulseUp.Q ;
    oscatGenPulseUp( PTH:= REAL_TO_TIME (MAX (oscatPI.y,oscatHyst3.val2) ),
    PTL := pausePulseUpDuration ,
    //Q=>
    );

    qUp := ((manualMode AND manualUp) OR (NOT ManualMode AND oscatGenPulseUp.Q ))AND NOT limitSwitchUp;
    qDn := ((manualMode AND manualDn) OR (NOT ManualMode AND oscatGenPulseDn.Q ))AND NOT limitSwitchDn;

    END FUNCTION

     
    πŸ‘
    1

    Last edit: smarmiroli 2020-05-11

Log in to post a comment.