Define Text to Tag using Structure Text

AutoJig

Member
Join Date
May 2013
Location
NYC
Posts
14
Hi,

I have to update thousands of text value in String tag. And that why I want to generate code to do it quickly.

I am looking for something like

Str_tag := "Hello";

And It is normal in normal programming but not possible in RSLogix but I was going through some document and found

To add or insert a string of characters to a string tag, use either of these ASCII string instructions.

To Use ___________________________________this instruction
______________________________________________________________
Add characters to the end of a string _____________ CONCAT
insert characters into a string_____________________ INSERT

I tried but it don't work any way...

Anyone have Idea or ever tried anything like this ?

Thanks
 
Last edited:
If my memory serves me right assigning string literals into a tag i think is invalid in logix 5000 Structured text.

Example as you stated Str_tag := "Hello"; would not work. What you might want to try is to create a place holder tag that is a string data type that holds your literal characters you would have to put the text that you want manually into the tag, then use a COP instructions to copy the data to your string tag

So the tag that you create can be StrTag_Placeholder, then go to the controller tag database, monitor and manually write a string of you liking.

Your strucutred text code can look like this
COP(StrTag_Placeholder,Str_tag,1);
That should copy whatever string data exists in the SrtTag_Placeholder tag to the Str_tag.
 
If I want to write a text to Str_tag I can manually write directly in to Str_tag. My intention is I have tag and values in excel table. Where I can use some excel functionality and I can create Thousands line of code in sec. I will run that code ones and it fill out value in tags, so I don't have to enter those information manually in that tag.

If my memory serves me right assigning string literals into a tag i think is invalid in logix 5000 Structured text.

Example as you stated Str_tag := "Hello"; would not work. What you might want to try is to create a place holder tag that is a string data type that holds your literal characters you would have to put the text that you want manually into the tag, then use a COP instructions to copy the data to your string tag

So the tag that you create can be StrTag_Placeholder, then go to the controller tag database, monitor and manually write a string of you liking.

Your strucutred text code can look like this
COP(StrTag_Placeholder,Str_tag,1);
That should copy whatever string data exists in the SrtTag_Placeholder tag to the Str_tag.
 
Are the tags an array and also the string literal that you want to update to the thousands of tags is it the the same for all of them, then if that's the case you can use a for loop to update the tags assuming the literal is the same for all and the tags are in an array. If they are not an array i don't see how your going to do all that in a sec.


EDIT** i also don't know what you mean by some excel functionality
 
Define your string tags in your program.
Export the program to an L5K file.
Edit the L5K file with the new string values in any text editor or word-processing program.
Import the L5K file back in.

You do not need to export/import the entire project, you can do just the program.
 
I have Str_tag as an Array, but all values are diffrent
Str_tag [0]= OFF
Str_tag [1]= Auto
Str_tag [2]= Manual
Str_tag [3]= V1_ON... and so on..

I wrote macro in excel which generate code from table where i define String literals

Str_tag [0] := OFF ;
Str_tag [1] := Auto;
Str_tag [2] := Manual;
Str_tag [3] := V1_ON;
......
....
Str_tag [1530] := XM36_Off;
 
Str_tag[0] := "OFF"; will not work. Hard coded string constants are not supported, so continuing on this path is not going to produce results.

Your options are to export/edit/import an L5X file (this is a design time solution as opposed to a runtime solution), or if you have a licensed copy of RSLinx Pro you can probably create some DDE links to the spreadsheet.

Just curious, why are all these strings being stored in the PLC as opposed to an HMI? The example you posted looks like something that can be solved with a handfull of multi-state objects in the HMI and a few integer tags in the PLC.
 
L5K is good option is in my list as a next solution.

PS. Those tag and Text literal are just as an example.

I used those tags in PLC just because I am going to use same PLC code and same HMI for some different type of machine.. So That's why I am not do it permanently in HMI.

One of my next step... I am planning for code generator which can generate more code ... and I got some success with that... only stopping point is text literals. There is another thing is ... I am going to load engineering units and Tag description as text literals too as same way.

As I know I can't load it directly but from the Rockwell Manual ... I find out..

To add or insert a string of characters to a string tag, use either of these ASCII string instructions.

To Use ___________________________________this instruction
__________________________________________________ ____________
Add characters to the end of a string _____________ CONCAT
insert characters into a string_____________________ INSERT

and as they are saying some way I can use it ... trying to reach rockwell support but there are some issue with chat and emails
 
If there is a repeating pattern to your strings, say

M? Off
M? Hand
M? Auto
M? Fault
M? Running

Then there are some things we can do programatically. In the example above where you have the same five strings for any number of devices then create a UDT for the strings and define an array of that UDT type.

Then define seven strings, str_devicenumber, str_M, str_Off, str_Hand str_Auto, str_Fault, and str_Running. In the tag editor set the value of str_M to "M" Set str_Off to "OFF", and so forth with each of the other tags.

Then using a for loop, convert the integer to a string str_devicenumber, then concatenate str_M and str_devicenumber, and finally concatenate each of the str_Off, str_Auto, etc, into the matching element of the UDT.

This is only going to work if you have a repeating pattern and sequential device numbering.
 

Similar Topics

hello dear forum, About DELTA DIAView SCADA I defined a variable in Timescript VBscript I want access this variable from within a window For...
Replies
0
Views
603
Hello PLCS.Net! I have the EDS Hardware Installation Tool installed on my PC. When I try to install a file, It says it's successful, the...
Replies
2
Views
2,064
Hi all, I want access a Mitsubishi PLC Q series to SMC. I am using Archestra DASMTEthernet as my server in SMC to connect with PLC. After I...
Replies
0
Views
1,440
Hi, I was wondering if anybody can help me with this issue. I have *.cab backup created from a lower version (Dev Studio 2012R2) and I loaded it...
Replies
8
Views
5,399
Hi Guys, I searched throughout the forums but didnt find any information on this topic. I currently have an application that relies on macros...
Replies
0
Views
1,623
Back
Top Bottom