Implement Retard Transfer Function

fjcano
2020-10-22
2020-10-23
  • fjcano - 2020-10-22

    Hello, IΒ΄m trying to simulate the control of a heating system. Then end of the control is a PID of the error between a power reference I generated internally for the heating system and the actual power consumption of the heating system. To test this control I want to implement a retard transfer function that simulates the power consumption. The idea is that the power consumption of the heating system will be the output of the PID with a retard of, for example, 5 second. The thing is that I donΒ΄t know how to implement this in CODESYS or if it is possible. Any ideas?
    Any help will be appreciated.

     
  • dFx

    dFx - 2020-10-23

    What about this :
    This will introduce some filtering on your value.

    rActualPower := rActualPower * 0.99 + rPidOutputPower * 0.01;
    

    You may also do this, but it will surely oscillate and tends not to reflect any real system:

    aRrBuffer : ARRAY 1..100 OF REAL; 
    ---
    'Cycle index value
    index := index + 1;
    If index > 100 Then
        index := 1;
    End_If
    'Recover stored value
    rPidInputPower := aRrBuffer[index];
    'Place new command in buffer
    aRrBuffer[index] := rPidOutputPower;
    

    Both examples need to be called in a cyclical task, where if we want 5s filtering/delay and 100 records, then the cyclical call time should be 5s/100samples so every 50ms.

     
    πŸ‘
    1

Log in to post a comment.