Wrong ST code generation

Issue #31 new
Thiago Alves created an issue

Beremiz generates wrong ST code for ladder diagram with parallel outputs that rely on the inputs. Example:

   out       mem                     out
-----[ / ]-----[ / ]------------+------( S )------
mem
------( S )------

For this case, the generated ST code is:

PROGRAM My_Program VAR Mem AT %QX99.0 : BOOL; Out AT %QX0.0 : BOOL; END_VAR

IF NOT(Mem) AND NOT(Out) THEN Out := TRUE; (set) END_IF; IF NOT(Mem) AND NOT(Out) THEN Mem := TRUE; (set) END_IF; END_PROGRAM

This generates a wrong behavior, since the second IF statement will not be triggered. The correct ST code would be to have both coils set on the same IF statement

Comments (1)

  1. Thiago Alves reporter

    More information here: https://openplc.discussion.community/post/coils-are-not-being-activated-9290623?trail=15#9

    I don't know much about PLCOpen Editor internal compiler, and I think that if I try to mess with it I have bigger chances of braking it more than fixing the problem. So, my idea is to fix this with an extra parser. After the code is generated, the parser will be called and will then scan the entire code looking for duplicate IF statements. Then it will concatenate all the statements inside each duplicate IF inside a single one, fixing the problem. I know it is not the most elegant solution, but it is what I can do now.

  2. Log in to comment