Import constant array values

Papplebeast

Member
Join Date
Oct 2014
Location
Missouri
Posts
11
I've got an RSLogix 5000 program where constant arrays are used as a lookup table. There are several hundred values in these constant arrays and I could type them in by hand, but I was wondering if there was a way to do something like import values from a csv.

Thanks
 
No, There is A Tag upload / download tool but it requires OPC Topics and creates a .COT file. It also requires a licensed version of RSLINX. The Lite Version will not work.

If you have access to be online with a PLC then a temporary line of logic using indirect addressing could fill your values. I have used this method when faced with that type of situation. Made 3 tags called x, y, z. Move the value of X into Array[y] For Length of Z
Of course my X was the same Value defining the Life of Tool Sets. If your numbers are Consecutive then an Add Instruction could change the Value of X before Move.
 
When I have to populate a constant table, I execute a Structured Text routine either once on startup, or on demand.

Those are just a lot easier to edit, so you have a big table of

Code:
MyValue[0] := 123.00 ;
MyValue[1] := 124.00 ;
MyValue[2] := 125.00 ;
MyValue[3] := 126.00 ;
MyValue[4] := 127.00 ;

I use Notepad++ to do most of my editing; the "Column Editor" is a hidden gem for sequential numbering in that program.
 
There is a clever and simple way to do this with AdvancedHMI if you have the values in a text file:

1) Open and build the AdvancedHMI solution
2) From the Toolbox add an EthernetIPforCLXCom driver
3) In the properties window set the IP address of your PLC
4) Add a Button from the Toolbox to the form and Double click to get back to the code
5) Enter code like this:
Code:
        Dim index As Integer
        Dim value As String
        Using sr As New System.IO.StreamReader("MyTextfile.txt")
            While Not sr.EndOfStream
                '* Read the line of data from the text file
                value = sr.ReadLine
                '* Write it to the tag in the PLC
                EthernetIPforCLXCom1.Write("MyTag[" & index & "]", value)
                '* Increment to next array index
                index += 1
            End While
        End Using

        '* Indicate that it is finished
        MsgBox("Written " & index & " lines of data")
        Close()
6) Run the application and click the button
 
Welcome to the forum.

This is really easy to do and you can do it offline at design time.

Create your array tag in your PLC program, but don't enter any data into it.

In the sample below I defined a DINT array named MyArray with 100 elements.

Save your program as an L5K import/export file.

attachment.php


Now open the L5K file in a text editor such as Notepad or Notepad++ and find where the array tag is defined. It will look something like what is shown below. Take a second and look at the tag definition, its format will be obvious.

If you haven't entered anything yet you should see just zeroes in the array. Paste the new values in, between the brackets and over the zero values that are there.

attachment.php



Save the L5K file in your text editor program.

Open the L5K file using Logix5000. Your array will now have all the pasted in values.

Save it as a Logix5000 ACD file.

TJC12101401.jpg TJC12101402.jpg
 
Last edited:
This is a nice set of solutions !

The *.L5K method is excellent as well for a first-time load of bulk values.

I started using the ST routine to configure 'constant' arrays when a bumped keyboard and mouse inadvertently zeroed out one of the values in my CRC lookup table and all my checksums started failing.

I was so pleased with finding the Column Edit feature in Notepad++ that I sent an e-mail out describing it to my co-workers. The feedback I got showed that we all did bulk code generation differently.

One used Excel spreadsheets and concatenation expressions, another wrote scripts in VB, another in Python and yet another in AutoHotKey.
 
One used Excel spreadsheets and concatenation expressions,

Excel is how I've done it. In fact somewhere on here I have a post showing how to do bulk PLC programming for large numbers of nearly identical rungs by using Excel. Excel can auto increment Allen Bradley IO addresses when you do a range fill, so its handy for that. Now that I know notepad++ has that feature I'll probably use it.

Recently for a 32 point lookup table I created an AOI and defined an array that was local to the AOI. AOI local tag values are not editable at run time and not programmatically accessible outside the AOI. It could be edited offline, but someone would have to actually drill down to it. It seemed to be a good solution for maintaining a constant table.
 
Last edited:

Similar Topics

I'm trying to import a .prj file and I keep getting the error message: Project import error. i Any ideas how to get around this? Thanks.
Replies
0
Views
88
Good day colleagues, I have a problem with a plc slc 5 since I export the tags to my factory program to load them into a panel view 1000 plus 6...
Replies
0
Views
126
hey good afternoon ! I have a simple question, I need to import an Add on instruction to a controller that is in operation and cannot stop. Is it...
Replies
6
Views
315
I am very familiar with Studio 5000 PLC programming. And I'm very familiar with C-More HMI programming. But this is my first time using a C-More...
Replies
2
Views
332
I am trying to import addresses and symbols from a PanelBuilder32 application into the RSLogix 5 Address/Symbol database - however each time I...
Replies
5
Views
561
Back
Top Bottom