Export UDT to excel and modify values

ASF

Lifetime Supporting Member
Join Date
Jun 2012
Location
Australia
Posts
3,921
Hi all,

I have a UDT with two STRINGs and four REALs. I have to put a value in each of the 6 members...in a 300-element array.

I have the values in an excel spreadsheet. Is there any way to get these values loaded into a UDT without spending the next 8 hours copying and pasting? :cry:
 
Whoops, sorry. RSLogix 5000.

Idea: I have a SoftLogix handy. Convert the excel file to a CSV in the right structure, write SoftLogix program to interrogate each row and store values in respective array element. Is it possible to get a Logix PLC to read/write an excel spreadsheet?
 
Got a licensed version of RSLinx Classic? You can write VBA code using simple DDE to read and write values to the PLC.
 
If that does not work

Save from PLC to L5K then modify the text file
or L5X for XML
Open the L5K or L5X file then download
 
Last edited:
If you use Micheal G's method. You could take your excel sheet data and save it into a .csv file then open .csv file in notepad and paste into .L5K.

The Data would have to be in a row format instead of column but that can easily be done in excel with the paste special option and checking the transpose check box.

The data in the .L5K file will have your tagname followed by 0,0,0,... for all elements associated with that tag or Values if any are present. It may be helpful to put a unique number in the first UDT element to help find it in the .L5K file. Which by the way can be opened and modified using notepad. Once modification are done save file, close and open .L5K file using RS5K. Make a backup copy first with different name because when opening a .L5K file it will ask which one to replace. Just in case any uh oh's pop up.

Chris
 
Thanks for the tips guys!

As it turns out, the DDE option is ridiculously easy. With the help of this article I got it working in no time!

For anyone following along in the future, here's my code structure. My DDE topic was called EXCEL, and the data was in columns A through F, starting at Row 2.
Code:
Private Function OpenRSLinx()
    On Error Resume Next
    
    'Open the connection to RSLinx
    OpenRSLinx = DDEInitiate("RSLINX", "EXCEL")
    
    'Check if the connection was made
    If Err.Number <> 0 Then
        MsgBox "Error Connecting to topic", vbExclamation, "Error"
        OpenRSLinx = 0 'Return false if there was an error
    End If
    
End Function

Private Sub CommandButton1_Click()

On Error GoTo ErrorHandling

    rslinx = OpenRSLinx() 'Open connection to RSlinx

'Loop through the cells and write values to the array tags
    For i = 0 To 299
            DDEPoke rslinx, "Recipe_DB[" & i & "].ID", Cells(2 + i, 1)
            DDEPoke rslinx, "Recipe_DB[" & i & "].Name", Cells(2 + i, 2)
            DDEPoke rslinx, "Recipe_DB[" & i & "].Qty1", Cells(2 + i, 3)
            DDEPoke rslinx, "Recipe_DB[" & i & "].Tol1", Cells(2 + i, 4)
            DDEPoke rslinx, "Recipe_DB[" & i & "].Qty2", Cells(2 + i, 5)
            DDEPoke rslinx, "Recipe_DB[" & i & "].Tol2", Cells(2 + i, 6)
    Next i
    
'Terminate the DDE connection
    DDETerminate rslinx
Exit Sub

ErrorHandling:
    MsgBox "Error Writing Data", vbExclamation, "Error"
    DDETerminate rslinx
End Sub

Thanks!
 
Good job, and thanks for closing your question out with your solution, since the number of unresolved threads is like entropy, ever increasing.
 
FYI - The RSLinx help file covers using VBA and DDE to read/write data to the PLC.
 
Exporting UDT to Excel

Hello everyone!

I have an UDT array in Control Logix, similar as in ASF's example, but i think i'm missing something, because i took his example, i paste it into my excel, i modified the tag name, but i still don't get nothing.

Can you please explain a little bit more how to get my UDT values?

Thank you!
 
The DDE method has a lot of value. I once did a project with 9 identical lines. Program edits were done on one line, and then copy the file and download it to the other lines.

Problem: there was critical data that would get over written. Things like current product, production counts etc.

Solution: make a spreadsheet that would read the data, then do the download, and then put the data back. Saved a ton of time and made the whole process more reliable (less stuff for me to make mistakes on).
 
Hello everyone!

I have an UDT array in Control Logix, similar as in ASF's example, but i think i'm missing something, because i took his example, i paste it into my excel, i modified the tag name, but i still don't get nothing.

Can you please explain a little bit more how to get my UDT values?

Thank you!

Check which version of linx you have, if its lite then it does not support the DDE links


+1, anyone working with Rockwell products should put this in their toolbox.

Could not agree more, a HUGE time saver & useful tool
 
Not to divert from the RSLinx subject, but just wanted to point a free option of reading an Excel file and writing it to a ControlLogix. There is a sample AdvancedHMI project (AdvancedHMIExcelCLXSampleR1.zip) you can find here:

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/SampleProjects/

It is essentially a template to start with for accessing Excel files and sending data to a ControlLogix. It is completely stand alone and does not need any version of RSLinx. It does require a little VB code writing, but possibly simpler than doing with VBA in Excel.
 

Similar Topics

Does anybody know of a way to export tags from Logix Designer and have it expand the UDTs into individual tag names? For example, say I have a...
Replies
5
Views
1,728
Hi, Im wanting to know if its possible to export a recipe UDT into excel to allow manipulation of the recipe, and then to be able to import it...
Replies
5
Views
3,631
Anyone know how to export and Import UDT Comments only? I have a file that has all the latest and greatest commnets but does not have the...
Replies
4
Views
2,689
How can I export a UDT from a offline V13 project. It does not appear to ave the ability to export in that version. Is there a work around?
Replies
4
Views
2,556
Hey all, What I'm looking to do is import RSLogix5000 UDT into a V16 program that was originally created and exported from a v18 program. It...
Replies
2
Views
2,212
Back
Top Bottom