RSLogix5000 --> C-More HMI; Array --> Text String

Hello everyone,

Wondering if anybody can help me with this:
I have a CompactLogix processor running a little robot cell. Every 200 cycles, operators are forced to put a known bad part into the machine (Sensor Check Part) to make sure it fails the quality check cameras and they're working properly. That's all working well and good.
I want to add to the C-More HMI a text that reads "The Last Sensor Check Passed at: 8:12 AM on 5/9/2024" - wit the numerical values being updated by the PLC every time a sensor check is passed.
Currently I'm using a GSV to create an array[7] of SYSTEM_TIME_DATE where each element of the array is Year, Day, Month, Hour, Minute, Second, etc.
How do I take those array element values and "sandwich" them together with the appropriate text to create one text string that will read as I have shown for an example?

I'm pretty stuck on how to do this aside from a bunch of individual text boxes on the HMI showing Day, Month, Year, Hour, Minutes, etc.

Thanks!
 
Look at the CONCAT instruction, which appends strings together. I create some smaller custom STRING types to keep the memory footprint down. Then convert each value of your time array to STRING using DTOS. I have some constant values (slash, colon, etc). Then CONCAT them all together into a string.
 
OK, I got it working. A little crude, but it works.

In case anyone else is having a similar problem...

Used DTOS to copy values to a string (Like DAY, MONTH, YEAR, etc)... one for each item.
Created several other strings for things like "Slash", "Space", "At", etc.
Use like 10 lines of code to use CONCAT to stitch the strings together, each time outputting to a new string. Takes a little while to build it, but you can watch the string get longer as you go. This little date/time string ended up using 11 temporary strings to build up to the final one.

Then, after you finally get the string how you want, go to the HMI program, make sure you go into the tag database, add that string as a tag, 82 character ASCII, and the Dynamic Text box needs to be "triggered" by something that's always on, like "SYSTEM_BIT_ALWAYS_ON".

Relatively confusing, but it works.

Oh, and PS, it shows it in military time format, not AM/PM.

Wish Allen-Bradley would pre-can some code to capture a date/time value and be easily able to send it to an HMI for displaying.

Here's what's on the screen:

1715366798503.png
 
OK, I got it working. A little crude, but it works.

In case anyone else is having a similar problem...

Used DTOS to copy values to a string (Like DAY, MONTH, YEAR, etc)... one for each item.
Created several other strings for things like "Slash", "Space", "At", etc.
Use like 10 lines of code to use CONCAT to stitch the strings together, each time outputting to a new string. Takes a little while to build it, but you can watch the string get longer as you go. This little date/time string ended up using 11 temporary strings to build up to the final one.

Then, after you finally get the string how you want, go to the HMI program, make sure you go into the tag database, add that string as a tag, 82 character ASCII, and the Dynamic Text box needs to be "triggered" by something that's always on, like "SYSTEM_BIT_ALWAYS_ON".

Relatively confusing, but it works.

Oh, and PS, it shows it in military time format, not AM/PM.

Wish Allen-Bradley would pre-can some code to capture a date/time value and be easily able to send it to an HMI for displaying.

Here's what's on the screen:

View attachment 69916
For future reference - is there an easier way to CONCAT like 12 different strings together into one in less rungs of code or does it all need to be stretched out? Like it has Source A, and Source B... can I add more letters of the alphabet?
 
Not to my knowledge. You can do it in one rung if you want, but afaik each piece added requires a separate CONCAT instruction. You could build an AOI to do it, but you'd still have to do all the same work inside the AOI.

On newer processors you can use string literals instead of tags for the text that doesn't change.

Wish Allen-Bradley would pre-can some code to capture a date/time value and be easily able to send it to an HMI for displaying.

While you're at it, wish that Automation Direct would let you embed tags in static text objects like they do in multi-state text indicators.

Now that I think about it that might be another way to do it -- use an indicator that always stays on a single state and embed the timestamp tags.
 
@nutcase511, why does it take a while to build? You should be able to do it in 1 scan.
It took a little while to program it. I believe the code executes in 1 scan, yes.
I was hoping the programming of such a relatively simple instruction might have been integrated with some kind of shortcut over the last 30+ years that AllenBradley has been doing PLC's for. I'm sure I'm not the first person who wanted to capture the date and time stamp of a problem for review later.
 
If you just need it in the PLC and you're running a newer version of logix like v35, you can use a DT type and do a GSV directly into it. It displays in the tag list as human readable format: DT#1969-12-31-19:00:00.000_000(UTC-05:00)
Code:
GSV WALLCLOCKTIME ? CurrentValue _Debug_FaultTimestamp
 
If you just need it in the PLC and you're running a newer version of logix like v35, you can use a DT type and do a GSV directly into it. It displays in the tag list as human readable format: DT#1969-12-31-19:00:00.000_000(UTC-05:00)
Code:
GSV WALLCLOCKTIME ? CurrentValue _Debug_FaultTimestamp
Thanks, but I needed to get the date/time info from the PLC and send it to a C-More HMI. Every so often our operators are required to do a "sensor check" on the machines - they put a known bad part in, and it needs to fail all of the sensor and camera checks to make sure it fails properly (no bad part escapes to customer). We had a problem where some machines weren't requiring them frequently enough, etc. So I added both a time-based trigger for the Sensor Check Required (Start of shift at 7:00 AM, 3:00 PM, and 11:00 PM), and also when a sensor check was completed to capture the current date/time info from the PLC and put it into a little text box on the HMI that says "The Last Sensor Check was done at ____:_____ on MM/DD/YYYY". Really helped our Quality people out with paperwork.
 
Thanks, but I needed to get the date/time info from the PLC and send it to a C-More HMI. Every so often our operators are required to do a "sensor check" on the machines - they put a known bad part in, and it needs to fail all of the sensor and camera checks to make sure it fails properly (no bad part escapes to customer). We had a problem where some machines weren't requiring them frequently enough, etc. So I added both a time-based trigger for the Sensor Check Required (Start of shift at 7:00 AM, 3:00 PM, and 11:00 PM), and also when a sensor check was completed to capture the current date/time info from the PLC and put it into a little text box on the HMI that says "The Last Sensor Check was done at ____:_____ on MM/DD/YYYY". Really helped our Quality people out with paperwork.
Can you not cast a DT type to STRING in AB?
 
Nope, it's a new-ish datatype. But what's worse than not being able to cast as a string is the lack of support for the datatype in FTView ME or SE.
Well that would be aggravating, one of my favorite things about TIME and DT in platforms like Codesys is how easy it is to work with in the HMI for formatting. No more wasted time converting ms with modulo to get hr/min/sec, etc.
 

Similar Topics

I'm working on a project using a pair of 1756-L62 processors using RSLogix5000 ver 18.02 and FTViewSE 6.00 standalone. The odd thing that is...
24
Replies
38,572
Views
RSLogix5000 - more than one or two PLCs inside one project? Well, I see here are a lot of AB-users. My question is: I have three elec...
6
Replies
5,924
Views
Hi, We still have a couple of machines running version 13.04 which we are looking at a way of running on Windows 11. We currently have to use an...
4
Replies
239
Views
Dear Experts, I would appreciate your assistance in resolving an issue with RSLogix5000 v20,54. Our plant operates a redundant control system...
18
Replies
824
Views
Hi all, My client has an existing system running 1769-L32E/A based controls with PowerFlex 520 and 22COM Ethernet module. The task is to replace...
6
Replies
255
Views
Top