Logix5000 String Data Storage

bbishop108

Member
Join Date
Mar 2017
Location
Indiana
Posts
86
[FONT=&quot]Good day everyone!
I am using a PanelView 800 and programming a compactlogix 5370 controller. I have created a string of tags in an array, Array[100]. What I am trying to do is enter a string file via the PV800 ( XX-1234-YY) and store it into my Array[100]. I need for the entered data to be stored in the array sequentially...i.e. XX-1234-YY goes to Array[0], XX-1235-YY into Array[1]...etc.[/FONT]
 
You can use a FAL instruction is INC mode to enter random data into your array. You could use the FSC instruction to find the first blank position in your array. Using either method you would use indirect addressing to point the data entry from the HMI to point to that position. But when all comes down to ascending order the sort instruction is the only way to do that.
 
Thanks for the info! I am looking at the SRT instruction, but I don't see that it supports string data type. I am using the FSC to search for the HMI entered data, if found it loads that file. If it is not found, then a message displays and I need to create that new data. All this data is string type, and I'm sure how I can use the FSC to find the next blank position and then store the new data in that location.
 
Create a tag called NULL_STRING. This tag should be blank. Then Expression String_Array[control.pos]=NULL_STRING This should find the first blank in the array.
 
Last edited:
Ok, I created another tag (Hold) string type. For the expression I set it up as you described Hold[Control.POS], but I keep getting the error message Invalid array subscript specifier.o_O
 
Interesting problem. Since it is implied that the data is coming in one-record-at-a-time, I would approach this as keeping the data sorted as records are added. (This would be in contrast to a bulk input from a file or external source.)

I would look at a user-defined type with a DINT and a String, where the DINT contains the sort criteria (e.g., value 1234). When a new record is received, use a FAL to step through an array of these (already sorted) UDTs to find the point where the new record should be inserted. Then a second FAL to shift all the elements after the insertion point. (There was a recent thread on how to do this.) Then insert the new element.

The FALs could be implemented by FOR loops, depending on preference.
 
I had to edit the expression comment in previous post. We want to look for Null String = to the [control.pos]

In this example I named my control FSC2 This is what I was trying to convey. A picture is worth a 1000 words.

Capture.JPG
 
Wow that is very helpful cwal61, and I feel I'm very close to getting this to work. The next thing that is just not clicking for me is this: The FSC sees the next available spot in the array, but how do I get the entered data from the HMI into that location? I presume I would use the COP instruction with the source being my entered data, but the location is where I am not sure how to store data.I tried to store it (per your example) as String_Array[FSC2.POS], that mostly worked the data was stored in the correct location but it also stores garbage data into the next 6-7 array locations. šŸ™ƒ
 
I think I got it....I had to set my COP length to 1, and that is now storing the data into the next available position and not storing garbage data!!! Thanks for all your help, I tried getting tech support with AB online chat...no help with this one! Thanks for all the help, greatly appreciated cwal61 and Mispeld!!!(y)
 
Glad to help.

Regarding the sorting aspect, a couple more options to consider. The CMP instruction will do string compare, and is pretty well documented in the RSL5K help. Using this in a FOR loop would avoid the need for a UDT with an extracted value for the sort criteria, and would be necessary if that criteria was not strictly numeric.

If the sort process involves shifting contiguous array elements to make space for an insertion, you could also use a COP instruction instead of a second loop. However, since the length is an immediate value, the storage array should be twice a large as the number of data items (e.g., if you are working with 100 items, the array would have to be 200 to be safe when making space for the 99th element). I guess you could also rely on the firmware not copying beyond the end of a shorter array and avoid the unused space.

This is the tread with discussion about shifting array elements from the end.

http://www.plctalk.net/qanda/showthread.php?t=109630

I would also imagine someone has implemented an in-place sorting technique. Maybe that logix code is readily available.
 

Similar Topics

So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
Hello, I have a question on an OCR application I am doing. I am reading in 16 characters that come from a camera into the plc in its input words...
Replies
4
Views
1,273
I'm currently working on an MES interface PLC which passes around a whole bunch of strings. A lot of these strings are really just to allow for an...
Replies
0
Views
1,117
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,952
Sorry I'm a rookie when it comes to working with strings in RSLogix5000 I have a barcode application where I'm trying to increment a barcode...
Replies
5
Views
2,622
Back
Top Bottom