ASCII String Advice

PLC Pie Guy

Member
Join Date
Jun 2013
Location
Halifax
Posts
1,144
Hey all.
Looking for some assistance with something.

I have an array of string tags that I need to "Put together". Example::

I[16] = '1' ASCII
I[17] = '.' ASCII
I[18] = '1' ASCII
I[19] = '9' ASCII
I[20] = '5' ASCII

I would like this to give me a real value that looks like 1.195

I need to NOT fault the PLC on this 🤞🏻
Am I correct in saying that I would use 5 CONCAT instructions to put it together???? That gives me a "true numerical value". As I want to see it but now how do I make it a real tag still as 1.195? I haven't done much of anything with ASCII instructions.

Thanks for any assistance.
 
Hey all.
Looking for some assistance with something.

I have an array of string tags that I need to "Put together". Example::

I[16] = '1' ASCII
I[17] = '.' ASCII
I[18] = '1' ASCII
I[19] = '9' ASCII
I[20] = '5' ASCII

I would like this to give me a real value that looks like 1.195

I need to NOT fault the PLC on this 🤞🏻
Am I correct in saying that I would use 5 CONCAT instructions to put it together???? That gives me a "true numerical value". As I want to see it but now how do I make it a real tag still as 1.195? I haven't done much of anything with ASCII instructions.

Thanks for any assistance.

Firstly, what PLC are you using ?

Secondly, is the string data always consistent, i.e. numbers of digits before and after the decimal point ?

Faced with this task I would use a "find" to find and record the position of the decimal point in the ASCII array, then extract each digit, multiplying it by the correct power of 10, accumulating each into a DINT tag, then I would divide (into a REAL tag) the DINT total by the correct power of 10 deduced from the position of the d.p.
 
Based on other threads I'm gonna assume C'Logix Processor.

If these are String tags, then yes, you'd need to CONCAT them together. You only need four in this instance. After that, Use a STOR function to convert it to real.

Since I can't seem to get two pics showing at the same time, stay tuned for one more post...

2017-11-25_9-34-43.jpg
 
If, however, they are numeric tags, as a lot of vendors' EDS files use SINT, then you can copy the values (49, 46, 49, 57, and 53) into it's own string.

2017-11-25_9-41-29.png
 
Until PLC Pie Guy comes back to tell us his processor, we don't know if these excellent suggestions are even relevant.
 
I should have been more clear in my caveat. Based on threads he's started over the past six months, it is extremely likely we can assume a C'Logix processor.

Good call, and glad you took the time to do the research, but not totally conclusive, well above WAG, but below FACT
 
@JordanCClark -
Regarding your solutions above, I would go one step beyond, and CLR the target string before using the CONCAT method, otherwise, it is possible to overrun the destination string bounds.
 
Hey all.

Firstly, I thank you for assistance in this matter. And the answer to your question is yes, this is an L35E version 20.13 controller.

I need to read these posts a little more carefully right now.. I appreciate any advice one can give me with this.

These are values coming from a vendor device. SINT is the type.

There was one other question regarding the string position.. The decimal will always be in the same place with the same number of digits on both sides.

Thankyou
 
@JordanCClark -
Regarding your solutions above, I would go one step beyond, and CLR the target string before using the CONCAT method, otherwise, it is possible to overrun the destination string bounds.

The first CONCAT effectively does this for you. Since it doesn't add to itself like the remaining ones, it acts as an initializer.
 
If, however, they are numeric tags, as a lot of vendors' EDS files use SINT, then you can copy the values (49, 46, 49, 57, and 53) into it's own string.

I'm curious about this statement.... What do you mean by copy the values 49,46,49,57 and 53.... Where did you get those values? This is a SINT from EDS file set up. At first the device was sending me hex data, IFM couldn't help me with logic to make it work so they had me change the data coming from the device to look like this ASCII values. Now I simply need to put them together.

I use other vendor devices in which they provide me the code to make these SINT values work and that gives me the process values that I want to see. Once I have to do that myself I'm a little out of my element. Especially when the vendor couldn't help me. So, I guess its easier to get this data as a STRING. I just have to put it together now.

Thanks
 
SO on the Tag Controller tag screen, I have the tag set to display as ASCII. However, when I start to lay out my CONCAT instructions, and I select the tag it shows as SINT not matching what the ASCII value should be. In my controller tags. I[16] is 0, in my CONCAT instruction it shows as 48. My value at I[17] is 46, not the . that it should be. If I use CONCAT to move that value to an DEST string.... I'm not sure.


Thanks
 
I cant even accept the edits as shown in the solution by JCClark .

"Invalid data type. Argument must match parameter data type."

So I know that the data type is SINT coming in to the elements [16] through [20] but they are only correct if displayed as ASCII, but I want to use it as a REAL... Oh my.. I will never purchase another vendor device unless they can PROOVE working code before hand.

Any suggestions on what I should do with this? Besides meet an IFM guy in a dark ally and beat him with it!

Thanks
 

Similar Topics

I have a Horner PLC that is reading Ascii string from a device. When the device responds, it responds with the hex value in Ascii. I need to...
Replies
8
Views
2,368
HI Guys So i am trying to write a real SINt or DINT value into a string tag. If in string browser I write it manually, no problem. But how can I...
Replies
8
Views
5,881
Have an unusual one here, guys... I have a remote machine that is sending my 1769-L33ER five 16-bit integers that represent 10 ASCII characters...
Replies
4
Views
2,204
Hello gentlemen, A few days ago I was tasked with converting an old panelview 1400e to a panelview plus 7 application. Everything went well except...
Replies
1
Views
1,302
hi, i try to capture barcode data using UDT with SINT ascii array. i have all the data i need but it in array format, how can i convert to 1...
Replies
5
Views
3,042
Back
Top Bottom