Sign in to follow this  
Followers 0
gromit

Concatenating strings in SLC5/05 controllers

5 posts in this topic

How can I concatenate strings into string files as follows.
Any time an event occurs, I want an entry in the string file that includes date/timestamp from real time clock, and also an integer number that correlates with the first out or cause of the event.
The integer can be anywhere from 1 to 25, and possibly 100 to indicate the trip has cleared.
I would like it to be able to maintain the last 20 events.
Please advise.
An enhancement to this would be to type out the cause next to the date/timestamp, based on the value of the integer word.
Such as... 
if N7:0 = 1
"21/11/2020 15:32:24 Tank-1  Level High-High"
if N7:0 = 4
"20/11/2020 11:12:04 Tank-2  Temperature High-High"
if N7:0 = 2
"17/11/2020 05:31:02 Tank-1  Level Low-Low"
if N7:0 = 1
"17/11/2020 03:22:12 Tank-1  Level High-High"

Edited by gromit

Share this post


Link to post
Share on other sites

You will need to use the ACN function to concatenate two strings. You can stack this by just placing that string into a buffer then doing it again.

I believe you will need to use the status bits to get the Date and time though. 

Send me a message if you get stuck and I can help you through it.

Edited by Criticore

Share this post


Link to post
Share on other sites

Criticore,
Thanks for your response.
I was able to create the basic logic to convert the dd+mm+yyyy , hh+mm+ss and trip number to strings and then concatenate into a string, as follows (21112020 : 153550 > 12)...

 BST AIC S:39 ST78:0 NXB AIC S:38 ST78:1 NXB AIC S:37 ST78:2 NXB AIC S:40 ST78:3 NXB AIC S:41 ST78:4 NXB AIC S:42 ST78:5 NXB AIC N77:10 ST78:9 BND 
  BST LES N77:10 999 XIC N77:0/0 NXB XIC N77:0/15 BND OSR N77:0/3 BST CTU C5:77 20 18 NXB GRT C5:77.ACC 20 RES C5:77 NXB ACN ST78:0 ST78:1 ST78:10 NXB ACN ST78:10 ST78:2 ST78:11 NXB ACN ST78:11 ST78:7 ST78:12 NXB ACN ST78:3 ST78:4 ST78:13 NXB ACN ST78:13 ST78:5 ST78:14 NXB ACN ST78:12 ST78:14 ST78:15 NXB ACN ST78:15 ST78:8 ST78:16 NXB ACN ST78:16 ST78:9 ST78:17 BND 
The output is basic and ugly as follows, (dd+mm+yyyy+:+hh+mm+ss+>+trip number)(21112020  : 153550 > 12) and I would like to enhance it, but the current issue is that I am not able to figure out how to maintain the last 20 events.
I tried using a counter to save the last 20 events into 20 contiguous string registers, but am not able to use indirect addressing to save the results to ST78:20 through ST78:40.
Any assistance would be appreciated.
Thanks.

Edited by gromit

Share this post


Link to post
Share on other sites
On 11/23/2020 at 0:28 PM, gromit said:

Criticore,
Thanks for your response.
I was able to create the basic logic to convert the dd+mm+yyyy , hh+mm+ss and trip number to strings and then concatenate into a string, as follows (21112020 : 153550 > 12)...

 BST AIC S:39 ST78:0 NXB AIC S:38 ST78:1 NXB AIC S:37 ST78:2 NXB AIC S:40 ST78:3 NXB AIC S:41 ST78:4 NXB AIC S:42 ST78:5 NXB AIC N77:10 ST78:9 BND 
  BST LES N77:10 999 XIC N77:0/0 NXB XIC N77:0/15 BND OSR N77:0/3 BST CTU C5:77 20 18 NXB GRT C5:77.ACC 20 RES C5:77 NXB ACN ST78:0 ST78:1 ST78:10 NXB ACN ST78:10 ST78:2 ST78:11 NXB ACN ST78:11 ST78:7 ST78:12 NXB ACN ST78:3 ST78:4 ST78:13 NXB ACN ST78:13 ST78:5 ST78:14 NXB ACN ST78:12 ST78:14 ST78:15 NXB ACN ST78:15 ST78:8 ST78:16 NXB ACN ST78:16 ST78:9 ST78:17 BND 
The output is basic and ugly as follows, (dd+mm+yyyy+:+hh+mm+ss+>+trip number)(21112020  : 153550 > 12) and I would like to enhance it, but the current issue is that I am not able to figure out how to maintain the last 20 events.
I tried using a counter to save the last 20 events into 20 contiguous string registers, but am not able to use indirect addressing to save the results to ST78:20 through ST78:40.
Any assistance would be appreciated.
Thanks.

I was able to enhance the output to display one of 24 different causes, rather than just the trip number.
such as Tank-1 Level Hii-Hi, Tank-2 Level Low-Low, FSL-101 Flow Low, etc.
Now I just need help with maintaining the last 20 or so events.
I tried using indirect addressing to save the string to 20 contiguous string registers, but it says that the ACN instruction doesn't allow indirect addressing.
ANY IDEAS?

Share this post


Link to post
Share on other sites

I was able to get it to work by using a counter and indirect addressing on a COP instruction, rather than an ACN instruction.

Everything is working now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0