Hello Guest it is April 18, 2024, 08:34:29 PM

Author Topic: RSLinx DDE/OPC  (Read 12086 times)

0 Members and 1 Guest are viewing this topic.

RSLinx DDE/OPC
« on: May 26, 2014, 03:17:48 PM »
Hello all!

I have been trying for over a week now to figure out how to make Mach3 talk to an Allen Bradley SL5/05 processor through Ethernet.  What I have come to is loading RSLinx on the Mach3 computer and sharing a DDE object from there.  What I really need now is sample code to read the DDE object from RSLinx.

The end game is to set a number in the N7 register to tell Mach3 which program to load and run from the PLC.

Thanks for any help anyone can give!

Cam McCrackin
Roboticist
Re: RSLinx DDE/OPC
« Reply #1 on: May 28, 2014, 10:25:08 AM »
Well, after 3 weeks of messing with it  ??? and reading every post I could find from Rockwell to Mach and Cypress Enable, here's the code that finally works  ;D :

Dim MyData As Object
Dim data As Integer
Dim xlworksheet As Object
Set MyData = GetObject("c:\mach3\n751.xls")
Set xlworksheet = mydata.Worksheets("sheet1")
Set data = (xlWorkSheet.Cells(1, 1).value)
message data

The file n751.xls has the ole object in cell A,1 from RSlinx.  Excel does not need to be open on the computer, but it does have to be loaded and available.

The number in Data can now be used to open a specific file number in the mach3\files directory.  I'm still working the bugs out of that one, but will post my results here if anyone is interested.

Cam McCrackin
Roboticist
Re: RSLinx DDE/OPC
« Reply #2 on: June 11, 2014, 01:21:08 PM »
Ok, new problem, same programming issue.  Here's what's going on: 

I am currently attempting to use GetObject to read cells from an Excel file.  The Excel file is loaded with values linked to RS Linx and works very well.  The problem is that even though the code works in the editor as expected, it will not work when called from a line of code as a macro.  The error message "coinitialize has not been called" comes up and the macro will not run.

I have the latest version of Mach3 running and licensed.  I read in the forums where the problem was fixed for CreateObject but could not find anything for GetObject.

Please let me know if I'm doing something wrong or if you can help me.

Thanks.

Code follows:

Dim MyData As Object
Dim data As Integer
Dim gobit As Integer
Dim xlworksheet As Object
Dim filename As String
Dim temp As String
Dim count As Integer

Set MyData = GetObject("c:\mach3\n751.xls")

Set xlworksheet = mydata.Worksheets("sheet1")



While gobit = 0
   Set gobit = (xlWorkSheet.Cells(1, 2).value)
   message gobit
Wend

Set data = (xlWorkSheet.Cells(1, 1).value)
'message data

Set filename = ("C:\mach3\GCode\" & data & ".txt")

'message filename

temp = Dir(filename)


If temp = "" Then
   message "not loading file"

Else

   message "loading file"
   LoadRun(filename)
   
   
End If
Re: RSLinx DDE/OPC
« Reply #3 on: June 12, 2014, 12:56:53 PM »
I hope nobody minds me filling space here.  You never know when someone else my want to try this.

The problem is now resolved.  I had to got to Excel 2003 and update Mach3 to the latest version.  Even though my version number matches it didn't work till I updated it. ???

Also Excel needs to be open in the background with my file in it to work right.  Could have something to do with the math I'm doing in Excel.

So all is well now.

Thanks!

Offline Tweakie.CNC

*
  • *
  •  9,198 9,198
  • Super Kitty
    • View Profile
Re: RSLinx DDE/OPC
« Reply #4 on: June 17, 2014, 03:37:46 AM »
Hi Roboticist,

No worries about filling space here - thank you for posting the information.

Tweakie.
PEACE
Re: RSLinx DDE/OPC
« Reply #5 on: January 28, 2015, 12:36:57 PM »
I saw your write up.  I have a Allen Bradley L23E I wanted to play around with Mach3.  I just have not started.  I was wanted to build a touchscreen remote pendant but have not had much success with what I had.  What are you using the RSlinx for?  I did get some sample code to talk Modbus Slave or Master for compact logix.  If wanted.  Like I said it is a sample though.
Re: RSLinx DDE/OPC
« Reply #6 on: January 28, 2015, 12:40:49 PM »
RS Linx is used to transfer the registers of the PLC to Microsoft Excel where it can be read by Cypress Enable native to Mach3.  There are 3rd party drivers and code, but I found they didn't work at all with Mach3.
Re: RSLinx DDE/OPC
« Reply #7 on: March 04, 2015, 01:51:03 PM »
I hope you have found a solution by now.  If not have you considered using MODBUS (serial or TCP/IP) to communicate with the PLC and format the data in brains?