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.
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: