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.

Looking at your Codesys LD program, the potential discrepancy between Rungs 2 and 3 could be attributed to a variety of factors. In ladder logic, the order of your operations is absolutely essential. Even if the rungs look similar, if the instructions are processed in a different sequence, it could lead to different outcomes. Additionally, the conditions on each rung could impact how the PLC executes each instruction. To give you a more accurate answer, it would be helpful if you could share some specific details about the program parameters and the outcomes you've noticed. Occasionally, there might even be an issue with the PLC itself, so that's another area to investigate.

From my understanding, the discrepancy in outcomes between Rungs 2 and 3 might be due to the difference in the sequence of actions. Ladder Diagram (LD) language operates on a left-to-right and top-to-bottom paradigm. In Rung 2, the operation might be executed before a certain condition is met. Meanwhile, in Rung 3, the sequence might be differently ordered leading to a different outcome. Without seeing the specific code it's hard to say. Also, if this has been discussed earlier, tagging or linking the post here can provide more context and verify if it's the same issue.

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.

You must be a registered user to add a comment. If you've already registered,
sign in. Otherwise, register and sign in.

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  â†’