Big Array, myUDT[300]

widelto

Member
Join Date
Jul 2005
Location
Barranquilla, Colombia
Posts
3,392
Hi Guys:

See attached figure. This is my UDT.
Is there any way to populate my array using excel and then copying it to my program, instead of doing it manually.
I'm using Rslogix 5K V20.

UDT.jpg
 
You can...
Define up a couple, then export your tags as .CSV to see the format, modify it, and re-import.

Tag import/export is best used from the "Tools" menu for this.
 
Hi Guys:

See attached figure. This is my UDT.
Is there any way to populate my array using excel and then copying it to my program, instead of doing it manually.
I'm using Rslogix 5K V20.

Sure.

Method #1:

First populate a few items of your array with dummy numbers, or the real thing, your choice.

Then export your program to a .L5K file, find your array, note how it stored your dummy data, replace it with your real data from a .CSV file, save it & reload it. This works okay for a "one-timer" approach.

Method #2:

Get a copy of AdvancedHMI (it's free) and VBStudio (also free-ish), create a link to your PLC and a routine in AdvancedHMI to write your Excel data (also saved as a CSV file) directly into your PLC.

This is a bit more work up front (but not by very much), but you don't have to take the processor down to do the upload, and you can do it as often as you like.


Do us a favor and post your exported UDT. And it wouldn't hurt to know the name of the tag that you will create from this UDT.
 
Last edited:
exported file see attached L5K zipped

Rootboy:

This program is still working.
My UDT is used for inventory purposes, I use a bar code scanner from cognex. Now they want to change descriptions, bar codes and some values.

That's the reason i do not want to do it manually. My array is called Producto[300]. My udt is called "Bodega".
Everything is in spanish.

Attached you will find my .L5K file.

Thanks in advanced.
 
Last edited:
see CSV tags file.

Rdrast:

your approach seems to work only for single tags, for arrays it seems to be incomplete.

See attached file. My array is Producto[300]. My udt is called "Bodega"

Tks
 
In the .L5K file, the complete record of all of the datatypes and values are saved. Spaces don't matter, so you can have it all one one line, or multiples. One entry for your data looks like this:

Code:
        Linea1 : Bodega[60]  := [
        [0.00000000e+000,
        0.00000000e+000,
        0.00000000e+000,0,
        [0,'$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00'],
        [0,'$00$00$00$00$00$00$00$00$00$00$00$00$00$00'],
        0,
        0,
        0],
when I break it down to lines. That represents record 0 in Linea1. Record [1] would start with another [0.00000000e+000, and end with 0], and so on.
I'd probably fire up UltraEdit, or some good programmable text editor, and cobble together a javascript program to bring in the CSV, format it to the L5K format, and then import that. Still work, but...


Hrm... one fairly simple way of doing it might be to write a report in Crystal or SQL to create the lines as you need them extracting from the Excel sheet... that should work too.
 
Okay, it was a bear, but I got it to load your data using AdvancedHMI.

The screenshot shows that it's working, and I had to modify your Bodega UDT to remove the string structures and just use regular strings in their place. AdvancedHMI wouldn't write to strings that were defined as "Codigo_Barras" and "Descripcion" strings. I tried...

The program will load up to 300 instances of your Producto tag (0 - 299), or until it runs out of data, whichever comes first.

You will need to download AdvancedHMI version 3.98d and install VB.NET 2013 for Desktop if you want to go this route.

Unzip the AdvancedHMI into your directory of choice, open up the project, do a "Build" command before anything else, and then copy the "MainForm.vb" and the MainForm.Designer.vb from the "VB Files.zip" over the existing ones (after closing the solution). And then you can run it. You may run into VB.Net errors if you copy the VB Files over the originals first, but even this is recoverable

Then open up your excel .CSV file, this is how I created it. Be sure to leave a blank line between your header and the start of your data block. The program is looking for ",,,,,,,," as a flag that the data starts after it.

Code:
UDT = Bodega,Tag = Producto,Length = 300,,,,,,
Peso_Real,Peso_Teorico_Caja,Peso_Teorico_Estiba ,Codigo_Aceite,Descripcion,Codigo_Caja,Cajas_X_Estiba,Lote,Clima
Float,Float,Float,DINT,ASCII x 45,ASCII x 14,INT,INT,SINT
,,,,,,,,
1.22,2.33,3.45,44,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.23,2.34,3.46,45,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.24,2.35,3.47,46,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.25,2.36,3.48,47,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.26,2.37,3.49,48,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.27,2.38,3.4,49,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.28,2.39,3.41,40,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.29,2.3,3.42,41,This is a string that is <= 45 Chars long,Shorter one,77,88,99
1.2,2.31,3.43,42,This is a string that is <= 45 Chars long,Shorter one,77,88,99

Producto.jpg Excel Data Format.jpg
 

Attachments

  • VB Files.zip
    3.4 KB · Views: 4
  • New_Bodega.zip
    610 bytes · Views: 4
Rootboy and Rdrast:

Thanks for your great efforts.
AdvanceHMI is new to me and this is going to be my first experience, I wanted to use it anyway.
Hope to do it this weekend or next monday, i'll let you know and share my results.
 
Rootboy and Rdrast:

Thanks for your great efforts.
AdvanceHMI is new to me and this is going to be my first experience, I wanted to use it anyway.
Hope to do it this weekend or next monday, i'll let you know and share my results.

No problem, it was a challenge (more so than it should have been, but that's my fault) and I was stuck in the Body shop for 12 hours yesterday, so I had a bit of free time. :)

And after I posted my solution, I got to thinking about how to get AdvancedHMI to write to your strings the way that you have them set up. The answer is to create a "Loader" UDT that is identical to your Bodega UDT with the strings removed and a DINT (for the string .LEN) and an array of SINTs (for the characters) in their places.

Load your "Loader" tag from AdvancedHMI, and then use the PLC to copy it to your Producto tag. Along with the "Loader" tag, you could also send an index pointing to which Producto tag that you want written to. I tried it out on my multi-million dollar test bench (idled equipment at the plant) and it works fine.

But that's only necessary if you really need your Bodega structure the way that you have it.
 
Last edited:

Similar Topics

Hello all My manager was nice enough to provide us with these nice big screens. Yet bootp is as small as it is on my lap to. Is there any...
Replies
3
Views
1,976
So, I ran into a motor and transformer someone was trying to get started today. Motor = 1HP, Transformer = 750VA With the transformer tapped...
Replies
15
Views
3,859
Haven't run into this before. imported routine, but this one tag is not cooperating. Hoping I could get some quick help before i come completely...
Replies
4
Views
1,534
Does anyone know of a 17" touchscreen that works properly with a RevPi Core 3 and Codesys? I tried a Viewsonic TD1711 which said it worked with...
Replies
0
Views
1,359
Kindly, do you know another brand which makes "power shielded big cables" similar to the below ones? Power cable sold by the meter type...
Replies
2
Views
1,372
Back
Top Bottom