How to Identify and Fix Division by Zero Issues in PLC Programming: A Case Study on Registers Displaying 1.#INF

Question:

Greetings to all readers! I delved into the world of PLC programming about a year ago, mainly working with GE/Emerson products such as RX3i and 90/30. To kickstart my journey, I attended an entry-level programming class offered by Emerson and received invaluable guidance from experienced programmers at my workplace. Our primary task involves using PLC controllers to test automotive seat frames. Each controller houses multiple versions of the same logic, which we refer to as stations (e.g., station 1, station 2). Recently, I encountered an issue where I had to duplicate an existing functional logic, adjust it for a new sheet, and assign specific variables to correspond with the station number. However, during this process, I observed that certain registers in the new logic were displaying "1.#INF." According to a colleague, this anomaly might be caused by division by zero. Despite looking through the Analog Logic, Output Logic, and Test Logic sections, I couldn't pinpoint where the division by zero occurred. Is there a more efficient way to identify this zero division without manually checking every rung? I attempted to share a screenshot for better clarity, but encountered some technical difficulties. Below is a snippet of the code I'm working on: COMMENT /* ANALOG INPUT/OUTPUT FOR POWER STATION 6 */; COMMENT /* POWER STATION 6 CURRENT DRAW */; H_WIRE; INT_TO_REAL AI0022,G,%AI0022 R06000,G,%R06000; END_RUNG; H_WIRE; SUB_REAL R06000,G,%R06000 -60.0 R06002,G,%R06002; H_WIRE; H_WIRE; MUL_REAL R06002,G,%R06002 -1.0 R06004,G,%R06004; H_WIRE; H_WIRE; DIV_REAL R06004,G,%R06004 1050.0 R06006,G,%R06006; END_RUNG; ... This snippet showcases the complexity of the programming tasks I'm dealing with in relation to power station operations. If you have any insights or solutions to my zero division issue, I would greatly appreciate your input. Thank you for your time and assistance!

Top Replies

Numeric variables are initialized to zero by default, but any variables intended for use as divisors in a DIV function should have a nonzero initial value. To quickly identify instances of division by zero in your ladder logic program, conduct a search for all DIV functions. For better results, use the "Find in Target" search option over the standard "Find" search. Ensure that your PLC target is active within the project before performing the search. This will help optimize your troubleshooting process and prevent errors in your program.

I express my gratitude to Steve for prompting me to review my logic, leading me to discover a mistake in a variable. I had mistakenly used the wrong register in a MOVE REAL instruction, causing errors in all my calculations. After identifying and correcting this issue by using the correct register, all the mathematical operations functioned correctly.

Hi there! It can indeed become really tedious checking for a division by zero error across each rung, especially within complex logic. One quick trick that you may find useful is to incorporate a catch-all error control right before the function that might cause the division by zero. You can add a condition that checks if the denominator is zero before carrying out the division. If it is zero, you can make it output a specific value (like a warning or alarm) that is easy to spot. This way, you can quickly isolate the area where the problem originates. I hope this aids you in sorting out your issue! Good luck with your PLC programming journey, it seems like you're handling some fascinating tasks!

Hey there! I understand your frustration - debugging can be quite a challenge sometimes. Here's a method you might find useful: rather than checking each rung manually, try using breakpoints to understand when your code is running into the "1.#INF" issue. This way, you can gradually narrow down where the division by zero is occurring. Looking at your code, given there is a division operation, check if '1050.0' or any other divisor in your code could potentially be turning zero in any given scenario. If you're unable to identify the specific scenario, you might want to add some protection logic in your program. For instance, before you divide, check if your divisor is zero and, if so, reassign it to, let's say, '1' or any non-zero number to prevent the software from crashing. Best of luck!

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: 1. How can I identify and fix division by zero issues in PLC programming?

Answer: - To identify division by zero issues in PLC programming, you can use tools like runtime error monitoring, debug mode, or specific PLC programming software features that highlight such errors. Fixing the issue involves reviewing the logic where the division operation occurs and adding checks to prevent division by zero.

FAQ: 2. Is there a more efficient way to pinpoint division by zero errors in PLC logic?

Answer: - Yes, instead of manually checking every rung, you can use debugging tools provided by the PLC programming software to step through the code and identify the specific location where the division by zero occurs. Additionally, you can utilize error logs or monitoring features to track such errors.

FAQ: 3. What could be causing registers to display "1.INF" in PLC programming?

Answer: - The display of "1.INF" in registers typically indicates a result of infinity, which can result from division by zero operations in the PLC logic. It is essential to review the code related to the affected registers and implement safeguards to prevent such zero division scenarios.

FAQ: 4. How can I troubleshoot and resolve anomalies like "1.INF" in PLC registers?

Answer: - Troubleshooting anomalies like "1.INF" in PLC registers involves analyzing the logic related to the affected registers, checking for division operations, and ensuring that appropriate checks are in place to handle division by zero scenarios. Utilizing debugging tools and seeking input from experienced programmers can also aid in

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