RSLogix, need to copy

opmal7

Member
Join Date
Dec 2014
Location
Moline
Posts
35
Sorry for the title, I posted before finishing, and can't figure out how to edit the Post Title. It should be "RSLogix, need to copy string to a database-style string address" or something like that

Hi all.

I'm looking for a way to copy the contents of one string data address to multiple, or successive, elements in another string table to sort of create a small database. If there is a better way to approach this, I'm open to suggestions, but this is the approach I currently have mapped out, and what I need to accomplish.

I have a sensor connected to a Micrologix that writes it's output to a string variable, ST1:0. Once that ST1:0.LEN is greater than 0, ST1:0 is copied to ST1:1, and the ST1:0.LEN is reset to 0, clearing the contents of ST1:0. Then I have a bunch of instructions that use that data to send commands back and forth to the sensor (setup instructions). At some point, I'm ready to receive the data that I care about, and use a bit, B2:0/0 to indicate that I'm in the "measuring" state. The measurement will be written to ST1:0, and the bit will indicate that this is a measurement, and not just a setup communication.

Now I need to store that measurement somewhere that it can be displayed to the user on the HMI, and I'd like to keep a record of the last 50 or so measurements. If I were to do this by hand, I'd write the first measurement to a new string variable, say ST3:0. Then, the next measurements would be written to ST3:1, ST3:2, ST3:3, etc. Is there any way to do this? I suppose I could use a whole bunch of binary indicators to keep track of which measurement I'm on, and use that to execute a separate rung to copy the string to each successive address, but I'm hoping there is a simpler method.

Currently, I'm not worried about the string variable getting full or anything like that. I'm testing this with a max of 50 results and I can store 256 string entries. Eventually, I'd like to set it up so if that database gets full, the oldest data is tossed out when the new data gets written, but I can worry about that another day down the road.
 
Last edited:
Look into the FFL/FFU instructions. Your application is exactly what the FFL exists for.
 
Look into the FFL/FFU instructions. Your application is exactly what the FFL exists for.

Awesome! This looks promising.

I'm trying this now, but getting an error on my FFL instruction. Source: #ST1:1 is showing and error "Address must be specified to the word level." Any tips on that?
 
Awesome! This looks promising.

I'm trying this now, but getting an error on my FFL instruction. Source: #ST1:1 is showing and error "Address must be specified to the word level." Any tips on that?

Also I'm getting the error "Invalid Data Type" pointing to FIFO: #ST5:0.

As I'm searching the internet, I'm not finding any FFL examples using strings. Are you sure strings can be used with this instruction?
 
Hmm. I'm not sure about whether they can be used on strings in a micrologix. AFAIK, you can use them on pretty much any data type, even a UDT, in Logix 5000, but I've not played much with them in RSLogix 500. What does the help file (click the instruction, press F1) say about valid data types?

If you can't go the FFL route, you could just use a simple COP instruction. You just have to use it in reverse.

Say you have 50 records, stored in ST9:0 through ST9:49, but instead of ST9:0 being the new sensor data and ST9:49 being the oldest, ST9:49 is the new sensor data and ST9:0 is the oldest. Each time you get a signal to say "new data coming through", you COP ST9:1 to ST9:0 with a length of 49. That'll copy 1 to 0, 2 to 1, 3 to 2, all the way through until it copies 49 to 48. Then you put your new data in ST9:49. Effectively everything is shuffled down one register, which is exactly what the FFL does, only it does it forwards instead of backwards and has some niceties about loading in and out and tracking the status of everything.

The reason you have to do it backwards is because if you shuffle everything the other way, you copy 0 to 1, and then when you go to copy 1 to 2, the value you wanted to copy from 1 to 2 has already been overwritten by the value that was in 0. So you end up copying whatever value is in zero to all 50 registers.

Hopefully that makes sense.
 
I think your best option might be a rolling queue. Set up a separate string data table just for measurements. Use pointers with indirect addressing to move the desired data into the next available spot in the queue and increment your pointer(s). If your pointer is > 255, set it back to zero.

So if N7:0 is your pointer and ST9:0 is fresh data, ST80 is your rolling queue, you would
COPy ST9:0 to ST80:[N7:0], then increment the pointer and check to ensure it is not greater than 255, if so, CLR it.

I am not 100% sure you can use indirection with ST files. There are some limitations in the Micrologix compared to SLCs. I am also not sure if simply COPying or MOVing the ST element will also handle the LENgth properly, so test it and if necessary also COPy the LEN when you need to manipulate the data.

Using a rolling queue will save a little processing power and avoid the limitations of the COP instruction which also may not play well with large lengths and/or ST files. Copying "normal" data you are usually limited to 256 bytes (128 integers) IIRC... I'm not sure about if/how that impacts strings.

The drawback to a rolling queue is that you may need another pointer to keep track of which data is the most recent entry.
 

Similar Topics

Anyone have a direct link or a copy of this old software? I have valid licenses for it on this PC but when I try and download it from rockwell it...
Replies
8
Views
2,508
Hello Forum, Having issues adding a module to the project. A 525 Powerflex drive when add the module rslogix program gives a fatal error and...
Replies
3
Views
1,988
Hi all, My client has a software running v21.03 and the last version I have installed is v20.04. I saw that the v21.03 is already available but I...
Replies
4
Views
1,918
I am aware of FTV, but I am looking for an alternative with an emulator that will work with a physical CompactLogix processor.. I was wondering...
Replies
20
Views
6,840
I've been in communication with our Rockwell distributor regarding which software package is going to be best suited for me (RSLogix pro edition...
Replies
6
Views
10,096
Back
Top Bottom