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

Use one variable serveral times in one program

McMarco
2018-09-16
2018-09-19
  • McMarco - 2018-09-16

    Hi Everyone!
    I have a problem with variables in Codesys.
    Firstly, I would like to use 1 variable as Coil, serveral times in the same program, but if i have use other firstly variable, which runs Coil, then coil is not working. When I use other secondly variable, which runs Coil, then coil is working. Why? How to fix it?
    I would like to attach a coil from several places in the program.

    Thanks.

    IMG: Bild

    IMG: Bild

    IMG: Bild

     
  • aliazzz

    aliazzz - 2018-09-16

    You can do these tasks in a single rung;
    Set the input coils in parallel (in an OR operation) and then write output-coil once.
    Also, by-design the latest operation in writing to the same output always get executed (in a single cycle).
    So, in your case the lowest rung always has highest precedence.

     
  • Triodes - 2018-09-19

    Try to use bits with an output only once in your program to avoid things like this.

    For your example you need to make an OR statement by paralleling the two inputs in the same rung as the output.

    ---- ----- ----------------------( )----
     

Log in to post a comment.