Writing 2D Array to RSL5k

rechrist87

Member
Join Date
Jul 2014
Location
Wisconsin
Posts
3
Hi.

I am trying to log a large data table into a 2 dimensional array from Control logix. I have been able to successfully load single dimension arrays for both read/write but I will get a #Ref fault when reading the 2-dimension. Below is my sample code for the VB script.
Code:
Private Sub CommandButton1_Click()
    
    rslinx = OpenRSLinx()

    'Loop through reading the CLX array tags and put the values into the cells
    For i = 0 To 73
    For a = 0 To 73
    Data1 = DDERequest(rslinx, "Allergen_CodeTable[" & i & " , " & a & "],L1,C1")
    'iF THERE IS AN ERROR, DISPLAY A MESSAGE BOX
        If TypeName(realData) = "Error" Then
        If MsgBox("Error reading tag Allergen_CodeTable[" & i & " , " & a & "]. " & _
                "Continue with Read?", vbYesNo + vbExclamation, _
                "Error") = vbNo Then Exit For
        Else
           'No error, place data in cell
          DDEPoke rslinx, "Allergen_CodeTable[" & i & " , " & a & "]", Cells(3 + i, 3 + a)

    End If
    Next a
    Next i
'Terminate RSLinx
DDETerminate rslinx
    
End Sub
 
It looks to me like your DDERequest command is incomplete - there is no reference as to where to put the data in the spreadsheet. Shouldn't it read something like?

Data1 = DDERequest(rslinx, "Allergen_CodeTable[" & i & " , " & a & "],L1,C1")
Cells (10, i) = Data1

Steve
 
It looks like it's doing the read just to verify the address exists in the PLC before attempting the write. The results of the read, other than success/fail, are not important.
 
I was trying not to post my entire code, and was using snippets. The main objective is to write a 2-dim array from an excel with starting location (r3,c3) file into tag "Allergen_CodeTable[0,0]". I used the DDRequest for an intermediate step for troubleshooting to see if the code was accessing the file. I have seen little blurbs about this working, but never actually confirmed.
 
I am looking for a DDERequest and DDEPoke command that will successfully write/read to/from an excel file into a 2D array. I have looked through the forum and the following structure did not appear to work:
Code:
For a=0 to 1
For i=0 to 3
Data=DDErequest(rslinx, real_data["&a&","&i&"],L1,C1)
*error
*Cell(1#,2#)
next i
next a
 

Similar Topics

Hi. Not the fist time I'm saying this but just to give a background. 95% of my PLC programming has used Schneider over the last 10 years on...
Replies
66
Views
4,629
I'm working with Crimson 3.1. Is there a way to write an array's position into a tag? For example, I have an array size of 100, I'll call them...
Replies
5
Views
3,988
I have an application where we are setting up recipes for our system. I have a an array of UDTs to store my recipes in the PLC (CLX), We are...
Replies
1
Views
1,546
Hi Thanks for reading this post. I Having trouble writing Wonderware array values to a compactlogix PAC. I can read the values through a...
Replies
1
Views
4,119
Does anyone know of a way to set the values of strings in a string array in a Logix5000 program when offline (before connecting to a PLC) so when...
Replies
1
Views
3,142
Back
Top Bottom