Guidance Needed for Structured Text Programming in PLCs: Using TOD# for Time-Based Data Storage

Question:

Hello everyone, I’m new to structured text programming and could use some guidance. My background in PLCs includes working with PLC5 (ladder logic), Omron (ladder logic), and Micro850 (function block), but I’m now exploring structured text to trigger data storage at a specific time of day (08:00) using TOD#. I've searched through the forum but haven't been able to find helpful resources or clear examples demonstrating how to effectively utilize TOD#. It seems like it's meant to manage time settings, but I'm not entirely sure. For context, I'm working with a Schweitzer RTAC. Additionally, I'm on the lookout for comprehensive tutorials that provide detailed examples rather than just brief snippets. Any recommendations would be greatly appreciated! Thank you, rp123

Top Replies

What level of access do you have to the clock utilizing SEL structured text? Below is an example of how the RSLogix 5000 code would be structured: ```structured-text /* Checking Wall Clock Data to assess the current time: If it is 8 AM and the seconds are less than 5, then record the current values to my logging system one time. */ If (WallClockData[3] = 8) and (WallClockData[4] = 0) and (WallClockData[5] < 5) and not OneShotTag Then If Not OneShotTag Then OneShotTag := 1; cop(MyData[0], DataFile[0], 8); End_if; End_If; /* Checking Wall Clock Data to evaluate the current time: If it is 8 AM and the seconds are greater than 10, and the one shot tag is true, then reset the one shot tag for reuse when the specified time reoccurs. */ If (WallClockData[3] = 8) and (WallClockData[4] = 0) and (WallClockData[5] >= 10) and OneShotTag Then If OneShotTag Then OneShotTag := 0; End_if; End_If; ``` This code snippet illustrates how to effectively use SEL structured text in RSLogix 5000 for time-based evaluations, specifically checking for conditions at 8 AM and managing a one-shot tag for efficient data logging.

Hello Programmer1, Thank you for your prompt response! I couldn't find any mention of the "wallclockdata" function in their manual. Is this function part of the IEC 61131-3 Structured Text standard? According to the SEL manual, there are additional IEC 61131-3 resources that I am currently searching for. The available data types include TIME, LTIME, DATE, DATE_AND_TIME, and TIME_OF_DAY, which appear to be utilized for TON (Timer ON) functions or event logging. I will conduct some testing based on the example you provided. Your help is greatly appreciated! Best regards, rp123

The WallClockData tag captures the information provided by the Get System Value (GSV) function within Logix. To utilize this tag effectively, ensure that there is an available clock configured in the processor. You can then implement it similarly to the provided example. I have reached out for access to the software to create a more illustrative example, and I expect to receive approval in a few days. If there are any delays, you may need to connect a digital input from an external time clock to trigger events. As the system maintainer, you also have the option to develop a time function utilizing timers to count seconds, minutes, and hours. However, keep in mind that if the system encounters issues and the timer stops, you would need to account for any downtime—an approach that may not be acceptable in many scenarios. In the given example, the WallClockData array is structured as follows: WallClockData[3] represents the hours, WallClockData[4] denotes the minutes, and WallClockData[5] indicates seconds (with a condition that WallClockData[5] must be greater than 10). By understanding this configuration, you can effectively manage time tracking within your Logix-based applications.

Hi rp123! Welcome to the world of structured text programming! Using TOD# (Time of Day) to trigger data storage at a specific time is a great application. You can define a variable to hold the current time and then check if it equals your target time (08:00). For instance, you could use a simple `IF` statement to compare the current TOD# with your specified time and execute your data storage function accordingly. As for resources, I would suggest checking out the Schneider Electric or CodeSys websites, as they often have detailed tutorials and examples that walk through practical applications. Also, don't hesitate to post specific code snippets here if you run into challenges; the community can offer targeted advice. Happy coding!

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)

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  →