How to Ensure Proper Functionality of Logix 5000 ONS in Multiple Sub-Programs

Question:

Within a single continuous task, I have various programs defined. The initial program includes an "ONS" that is utilized in multiple subsequent programs. Despite the ONS executing initially, it reverts back to false by the time it reaches later programs, resulting in the logic not activating as intended. How can I ensure that this ONS functions properly for all sub-programs, or should I consider revising a significant portion of the code?

Top Replies

Have you arranged the programs in the Task properties to prioritize the ONS controlling program? Make sure the controller-scoped tag is not overshadowed by a program-scoped tag in all programs. It is important to confirm that ONS(thesametag) is not being executed in multiple programs simultaneously. This is not allowed.

Cheeseface suggested checking the program order in Task properties to ensure the ONS controlling program is prioritized. It's important to verify that the controller-scoped tag is not overshadowed by a program-scoped tag in all programs. In my setup, the clock control program is the top priority, and I do not have any local tags in use.

In order to avoid ambiguity, it is important to consider the possibility of multiple ONS instructions with the same logic feeding each one but with different storage bit operands. It is recommended to write the state of the first ONS in a scan cycle to a single global bit and utilize that global bit's state throughout the program. Each rung containing an ONS is self-contained and evaluates the logic feeding its input at the time of program scan evaluation. Using multiple ONS instructions with identical logic may risk the logic changing during the same scan cycle, especially if physical input memory is involved due to Logix 5k's asynchronous I/O processing. This means that signals like Local:1:I.Data.0 could change while the program is still running. Consider if Logix 5k includes OSR functionality.

AMarks95 mentioned the presence of an ONS (Object Naming Service) in the initial program, which is then utilized across various other programs. Could it be that all the other programs are dependent on that initial program for functionality?

In a recent update, drbitboy discussed the implementation of ONS instructions in PLC programming. The approach involves utilizing multiple ONS instructions, each with a unique storage bit operand. However, the initial post lacked clarity on this aspect, leading to some ambiguity. Despite this, it's important to note that all ONS bits are indeed unique in this setup. Drbitboy suggested a strategy where the state of the first ONS in a scan cycle is recorded in a global bit, which is then utilized throughout the program. This method aims to streamline the process and ensure consistency in logic evaluation. The use of a timed trigger, such as a 250ms timer, can further enhance the efficiency of the system. It is crucial to maintain self-contained rungs with ONS instructions to prevent discrepancies in logic evaluation. By incorporating timed triggers at both the global and local levels, the system can facilitate seamless operation. These adjustments will be monitored closely for optimal performance.

It seems like your ONS is getting reset before the entire sequence of sub-programs finishes executing. One possible solution could be to include the status of the ONS either as a global variable or pass it as a parameter among the sub-programs, so its state remains consistent throughout. Another approach could be to reassess your code structure. If the logic heavily depends on the output of an ONS from the beginning of the task, it might be worth revisiting the code architecture for potential optimization or redesign.

I'd suggest using global variables to manage your boolean switches. Currently, your ONS is local to the first program and resets before the later ones run. If you declare your ONS at a higher level, it stays set and becomes accessible to all your sub-programs. However, be careful to reset it manually when you're done, since it won't reset automatically. If the complexity still persists, you might want to consider refactoring the logic to simplify and generally improve the code's efficiency. It could be a bit of a task, but it's worth it in the long run.

It sounds like you're dealing with a scope or state persistence issue with the ONS variable across your programs. One approach to ensure its value carries through is to implement a global or external variable that retains its state throughout the execution of the task. This way, each sub-program can reference the same ONS instance, preserving its value. If that doesn't fit with your current architecture, consider refactoring your code to handle this logic in a more modular way, maybe by creating a specific management function for the ONS state that can be called before the relevant sub-programs. It might take some upfront effort, but it could lead to a more robust solution in the long run!

It sounds like you're dealing with a scope or lifecycle issue with the ONS variable. To ensure it retains its state across all your sub-programs, you might want to consider making it a global variable if that's suitable for your architecture, or pass it as an argument to each sub-program that needs it. Another option could be to store its state in a centralized configuration object or use a flag to track its status as you move through the task. If these solutions compromise other parts of your code's integrity, then revisiting the structure might be necessary, but hopefully, a simpler adjustment will do the trick!

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 ensure the proper functionality of an ONS instruction in multiple sub-programs within Logix 5000?

Answer: - To ensure the ONS instruction functions properly across multiple sub-programs in Logix 5000, consider placing the ONS in a common routine that all programs can access. This way, the ONS will maintain its state throughout the execution of different sub-programs. 2. Why does the ONS instruction revert back to false when used in multiple subsequent programs in Logix 5000? - The ONS instruction may revert back to false when used in multiple subsequent programs due to the scope of the instruction within each program. To address this issue, consider reorganizing your code structure to ensure consistent ONS functionality across all sub-programs. 3. Do I need to revise a significant portion of the code to ensure proper ONS functionality in Logix 5000? - Depending on the complexity of your existing code structure, you may need to revise the organization of your code to ensure proper ONS functionality in Logix 5000. Consider consolidating common logic into shared routines or modules to improve the consistency of the ONS instruction across multiple sub-programs.

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