Sign in to follow this  
Followers 0
Mspeck

Concat Ascii to readable text

5 posts in this topic

Good morning,

I have an ASCII tag BCData.Data[0] thru [8] Data Type SINT.

How can I combine all values into a readable text ?

This is a Compactlogix processor.

Share this post


Link to post
Share on other sites

you cn convert each element individually into a string then concatenate them into one longer string

Share this post


Link to post
Share on other sites

I have been trying this for two days and am getting nowhere,

My string array looks like this . . . 

BCData.Data[0]  currently equals 5

When Copied to a string that string value equals '6828$r$00$00$00$00$00$00$00$00

Why is it not simply copying the 5 that is located in that element

Share this post


Link to post
Share on other sites

The default STRING datatype in ControlLogix consists of a 32-bit DINT that represents the Length, and a SINT[82] array that represents the data, one character at a time.

In your case it sounds like you have BCData.Data[0] that holds the Length (but it's only 8 bits), then BCData.Data[1],[2],[3],[4] that holds the letters "6 8 2 8".    The last character is shown as "$r" which is shorthand for 0x0D = 13 = Carriage Return.

The easiest way to handle this would be to use a MOV instruction to move the BCData.Data[0] value to the StringTag.LEN tag.     Use the MOV because it automatically converts from SINT to DINT and it's easy to understand.

Then perform a COP instruction, with the Source = BCData.Data[1] and the destination StringTag.Data[0].   Make the Length of the COPY the number of target elements (SINTs), so use StringTag.LEN as the Length.    If you don't want the carriage return on the end, subtract 1.

 

 

Share this post


Link to post
Share on other sites

Thank You Ken, this worked perfectly.

I appreciate you and 'panic mode's' response to my post.

 

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