How to Display Time as 3:00 PM Using CCW with PV800 and Micro850

Question:

When using CCW with a PV800 and Micro850, I have created a scheduler allowing users to select a specific month, day (1-31), hour (0-23), and minute (0-59) for system startup. I want to display this time in a standard AM/PM format, such as 3:00 PM. However, my current method of displaying the time results in inconsistencies, such as showing single-digit minutes. Is there a way for CCW to convert the time into a string for proper display? Utilizing $SysTimeString allows for the correct display of current time, but converting the scheduled time to a TIME variable results in an unattractive format like 15h00m. I also attempted to use a UDFB from AB's website to determine the day of the week based on input date, but encountered issues with importing it into CCW.

Top Replies

While I don't have the specific hardware on hand, I recently set up a new PV800 project in CCW. When utilizing a Numeric Display for displaying minutes, there is an important setting labeled "Fill With" under the "Format" section. By adjusting the Number of Digits to 2 and choosing to Fill With Zeroes, you can customize the display to show the minutes exactly as desired.

One useful method is to utilize the RTC_READ function to retrieve the current time and date from the PLC system, including hours and minutes. This data can then be processed using DTOS and INSERT commands to create a formatted string for presentation on the HMI screen.

I offer my sincere condolences for resorting to carrying concealed weapons (CCW).

Thank you, Joseph, for your two excellent suggestions. I will start with the first one and if it doesn't yield results, I will move on to the second one. Your input is greatly appreciated!

Geoff White expressed his sympathy for using CCW, but I have to say that I have come to appreciate it. While many may not favor CCW, my background with text languages like C++, C#, and Python gives me a unique perspective. CCW is my first introduction to PLC programming and ladder logic, and surprisingly, I find myself preferring it over text-based programming. Is CCW considered less effective than other programming systems for PLCs?

It seems like you're on the right track, but translating the TIME variable into a more readable format is indeed tricky in CCW. Unfortunately, there isn't a straightforward method in CCW to convert TIME to string directly. However, you can consider creating a custom function for formatting that will convert hours and minutes independently into strings and then concatenate them. As for the issue with the UDFB you're having, it might be a compatibility issue. Check the version of the UDFB and if it's not designed for the Micro850, you could have problems. Another approach could be to use a RTC (real-time clock) and program it to return the day of the week based on a given date. This might involve a bit of coding but ultimately it could provide a more integrated solution.

I think the best approach here would be to convert the 24 hour time to 12 hour format using mathematical manipulations and then concatenate all elements (day, month, hour, minute) into a single string. Here's a brief idea how you can do it: Assuming your hour variable is called 'Hour', you can get the equivalent 12-hour format by using the modulo operator: Hour12 = Hour %12. This will return a value between 0 and 11. Since we don't usually use '0' in 12-hour format, add '1' to the result if the original Hour was 12 or less. Next, you can create the AM/PM identifier. If the original Hour is less than 12, it's 'AM', otherwise it's 'PM'. You can use a case structure for this. Finally, you should create the time string. Concatenate all elements(day, month, the calculated Hour12, minute, and the AM/PM identifier) together making sure to add leading zeros to the minute if the minute is a single digit. You can do this by checking if minute is less than 10 and if true, add the zero before it, using another case structure. This is a workaround but should give you decent results! Let me know if you need a step by step guide for this.

Have you tried using the STRING FORMAT function in CCW to customize the time into a proper AM/PM format? This function should allow you to set up your strings in a top-down manner, giving you more control over how things are displayed. To address the issue with single-digit minutes, you could try padding zeros to the left of the minute segment. Regarding the UDFB import issue, try double-checking for compatibility issues or missing dependencies in your code. It's sometimes overlooked but these are often the culprit in such scenarios.

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 display time as 3:00 PM using CCW with PV800 and Micro850?

Answer: - To display time in a standard AM/PM format like 3:00 PM, you can convert the time into a string for proper display. Utilizing $SysTimeString can help with correct display of the current time.

FAQ: 2. Why am I experiencing inconsistencies in displaying time with CCW?

Answer: - If you are facing issues such as showing single-digit minutes or unattractive time formats like 15h00m, it may be due to the method used to convert the time. Consider converting the scheduled time to a TIME variable for better display.

FAQ: 3. How can I determine the day of the week based on an input date in CCW?

Answer: - You can explore using User-Defined Function Blocks (UDFBs) provided by AB's website to determine the day of the week based on the input date. However, ensure that the UDFB can be imported and utilized correctly within CCW to avoid any issues.

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