Mspeck Posted November 16, 2018 Report Posted November 16, 2018 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. Quote
panic mode Posted November 16, 2018 Report Posted November 16, 2018 you cn convert each element individually into a string then concatenate them into one longer string Quote
Mspeck Posted November 16, 2018 Author Report Posted November 16, 2018 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 Quote
Ken Roach Posted November 18, 2018 Report Posted November 18, 2018 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. Quote
Mspeck Posted November 19, 2018 Author Report Posted November 19, 2018 Thank You Ken, this worked perfectly. I appreciate you and 'panic mode's' response to my post. Quote
bobuhh98 Posted May 5 Report Posted May 5 Hello, in this example, would we be able to use BCData.LEN as the length in the COP instruction? or would it need to be the StringTag.LEN? I am experiencing a similar issue where I am trying to move the barcode scanner data from a Zebra EA3600 scanner to a string but am occasionally copying a value of "$00$00..." over instead. Quote
Ken Roach Posted May 5 Report Posted May 5 Welcome to the MrPLC forum community ! In that case in 2018, there was no "BCData.LEN" element because BCDData was a SINT[8]. So that's not really a question i can answer. Ideally, create a new thread and provide some details about your application. Because some modern ControlLogix firmware has changed the way that COP instructions handle dissimilar-typed sources and destinations, please post your firmware revisions too. When using barcode readers, the function that indicates that new data is present is important. Sometimes it's a handshake, sometimes an incrementing identfier, etc. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.