How to make the output of a function blok persistent?

benbammens
2020-11-07
2020-11-09
  • benbammens - 2020-11-07

    Hello,

    I use a PFC200 with codesys for my home automation. I would like the light outputs to be persistent since it is a pain in the b... that every time when I re-upload the program or restart the PLC the lights go out...

    I use push buttons an a toggle function block to control the lights. I have made the final output variable persistent, but when the program starts, the output "Q" of the toggle FB gets reset ofcourse and the light is switched off.

    I have tried to define the entire block as retain variable but this does not seem to work. I cannot define the "Q" as retained in my POU since it is part of the FB...

    Is there an easy way to set this up?

     
  • dFx

    dFx - 2020-11-09

    Using an inout variable will suit your requirements.
    More generally, if you need to know the previous state of an output variable, then it should be an inout. Inout refers to variables you want to read and write.
    Just define the inout variable as persistent.

     

Log in to post a comment.