CONCAT a string - length limits

ASF

Lifetime Supporting Member
Join Date
Jun 2012
Location
Australia
Posts
3,921
Hi all,

Quick question if anyone knows offhand -

In a ControlLogix (or Compact Logix), the default STRING datatype has a maximum length of 82. If I have a string stored in a STRING tag with an actual length of 80, and I CONCAT three or more characters onto the end, will the PLC just truncate the string, or fault? I'm onsite this week and don't have a non-critical PLC to test this with, and I'm wondering if I should check the string lengths before I CONCAT them.

Thanks!
 
Some of the string will end up dropping off the end of the earth. You can also just increase the length from 82 to some number much larger than anything you're dealing with.
 
Thanks Jeev. Not concerned with chopping a bit off the end, at that point it would run off the edge of the screen anyway. Just don't want to leave it open to faulting the PLC if someone decides to play silly buggers with the descriptions :)
 
Thanks Jeev. Not concerned with chopping a bit off the end, at that point it would run off the edge of the screen anyway. Just don't want to leave it open to faulting the PLC if someone decides to play silly buggers with the descriptions :)

You can also put a length limit on any HMI input fields. There are values where I'll do this as well as limit checks in the PLC... The best example is array indexes where you don't want a subscript out of range. I will program with a certain level of paranoia anything that an operator can do.
 
Last edited:
Just tried it on an L71 version 21.0 no fault. Just truncates what wont fit in 82 characters.

You know you can also create your own string type? I use STRING20 and STRING100 for storing ISA tagname and then the device description.
 
Yeah I know I can change the string length, or limit the input fields - in this application I really can't see any possible way that it could ever exceed 82 characters, because it's dragging the string from an SQL database with a length limit of 60 characters, and I'm only CONCAT'ing another 10. But I'm just super paranoid about "if there's even the remotest chance of it happening, someone will find a way to make it happen", so I just wanted to make sure if they DID somehow manage it, they at least wouldn't fault the PLC.

Thanks guys!
 

Similar Topics

Hi all I am trying to set up a lhttp instruction to connect to an api https (with our IT) this will send data back to the plc? I have an api https...
Replies
9
Views
1,786
Hello, I am using Machine expert - basic with an M221 PLC. I have two 16 bit modbus registers coming in and I want to convert to a 32bit real...
Replies
8
Views
3,910
I'm writing a new program for a CompactLogix 5069-L310ER. I used a GSV to grab the date and time from the processor. Then several DTOS and...
Replies
5
Views
2,022
Can I take 2 strings, concatenate them and use that result as a TagName of a Bool or any other element? I'm creating an AOI for MSG stats and it...
Replies
3
Views
1,482
Good Morning , I'm working on trying to get timestamping done on some doses. I am very close, thanks to many of you with your advice. I...
Replies
7
Views
2,672
Back
Top Bottom