Skip to content

Contact evaluated repeatedly when followed by multiple coils #836

@tkuusk

Description

@tkuusk

Expected Behavior

In the following examples, assuming that FirstScan is initially True, I would expect both Output1 and Output2 to be set to True:

Image Image Image

Current Behavior

Output2 is not set because FirstScan is re-evaluated before each coil assignment. The generated ST code is almost identical for all cases:

  IF FirstScan THEN
    Output1 := TRUE; (*set*)
  END_IF;
  IF FirstScan OR FirstScan THEN
    FirstScan := FALSE; (*reset*)
  END_IF;
  IF FirstScan THEN
    Output2 := TRUE; (*set*)
  END_IF;

Steps to Reproduce

  1. Create ladder diagrams like in the examples above.

  2. Compile and run or examine generated ST code

Possible Solution (Not obligatory)

One option would be to limit what can be drawn, e.g., no branch joins after a coil or function, or no sequential coils.

Context

The behaviour is unintuitive and not consistent with other PLC softwares, including OpenPLC Editor v1.x.

Your Environment

  • Version : 4.1.4
  • Operating System and version : Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions