Codesys Ladder Diagram: Understanding Differences in Rungs 2 and 3

Question:

Take a look at the Codesys LD program displayed below. One would anticipate that Rungs 2 and 3 would yield the same outcomes, but they don't seem to. Can anyone offer any insights on this discrepancy? Alternatively, this topic may have already been discussed in a previous post.

Top Replies

In most cases, the execution order within POUs is specifically established in text-based and network-based editors. Unlike in the CFC editor, where elements can be freely arranged, leading to a non-unique execution order initially. Learn more about this topic at https://help.codesys.com/api-content/2/codesys/3.5.15.0/en/_cds_cfc_automatic_order_by_dataflow/.

How can I access a statement list version of the program to compare interpretation discrepancies? Explore a statement list view to identify differences in program execution.

User bernie_carlton inquired about the availability of a statement list version of the program, which could reveal interpretation discrepancies. This option is indeed available, as observed earlier in the behavior of the reset command with r_trig in ladder logic versus CFC, and whether it is used within a function block or not.

It appears that the execution order in POUs is uniquely determined in text-based and network-based editors, as mentioned in the CFC editor where elements can be freely positioned resulting in a non-unique execution order. This raises concerns about the accuracy of the execution order set by Codesys, especially in LD (Ladder) which is a network-based editor following specific execution rules. The discrepancy in execution order is evident in the logic where the top branch of two parallel branches should execute first, contrary to the current scenario. Could viewing a statement list version of the program reveal any interpretation differences? It is crucial to consider that the lower branch of Rung 3 must have been executed before the upper branch of Rung 3 based on the logic presented, otherwise the equality between savehound2 and fox would not be achievable. For further insights, refer to the link provided.

In reviewing drbitboy's statement, it appears that there may be a discrepancy in the execution order determined by Codesys, especially in LD (Ladder) programming, where the top branch of parallel branches should execute first. This indicates a potential issue with the program's logic, as the lower branch of Rung 3 should have been executed before the upper branch to ensure savehound2 equals fox. The question arises whether Codesys follows a top-to-bottom, then right or left-to-right, then bottom execution order. This observation may reflect a similar pattern seen in old modicons from the 70s and 80s.

This discrepancy could occur due to the different operational precedences of logic gates involved. In the Ladder Diagram (LD) programming, the logic is easier to troubleshoot when you keep the flow from left to right. Programmatically, there might not be a difference for some PLCs, but it can in others due to scan time considerations. Please be sure to check previous discussions related to scan times and how they could affect the processing of your logic.

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: FAQs:

Answer: 1. Why do Rungs 2 and 3 in the Codesys LD program yield different outcomes despite appearing similar? - The differences in the outcomes of Rungs 2 and 3 could be due to specific logic or conditions programmed within each rung. It is essential to carefully review the ladder diagram logic and check for any discrepancies.

FAQ: 2. How can one troubleshoot the discrepancy between Rungs 2 and 3 in the Codesys LD program?

Answer: - To troubleshoot the discrepancy, one can analyze the logic statements and conditions in Rungs 2 and 3 step by step. Check for any differences in input conditions, output assignments, or function blocks that might be causing the varied outcomes.

FAQ: 3. Has the topic of differences in Rungs 2 and 3 of Codesys LD programs been discussed previously?

Answer: - If the topic has been discussed before, you may find relevant insights and solutions by searching for previous posts or discussions related to the discrepancies in Codesys ladder diagram rungs. It could be beneficial to refer to existing resources for additional guidance.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’