Make sure RS Linx is running and you have created a DDE topic. In our example below, our DDE topic is "M1138".
Using the following code, Open an Excel file and click on Tools then Macro, finally clicking on Visual Basic Editor. This will allow you to write some VBA script to tell Excel what you want to read and where to place the data once read from the PLC.
<<<<<<<<<<<<<<<<<<<BEGIN SAMPLE CODE>>>>>>>>>>>>>>>>>> Sub Start()
Dim lngRow As Long Dim varCycle As Variant Dim varLogging As Variant Dim varResults As Variant On Error GoTo Error
'opens a COLD DDE link RSIchan = DDEInitiate("RSLinx", "M1138")
'assign PLC bit values to VB variant varibles varLogging = DDERequest(RSIchan, "B3/163") varCycle = DDERequest(RSIchan, "B3/161")
'close COLD DDE link DDETerminate (RSIchan)
'check to see if the Cycle bit went to "1" if it did, excute read data If varCycle(1) = "1" And varLogging(1) = "1" Then
'starts at row 3 of sheet lngRow = 3
If Range("INDATA!A3").Value > 3 Then 'look up last cell and change position lngRow = Range("INDATA!A3").Value End If
'check until end of sheet For lngRow = lngRow To 65500 'look for next empty cell If Cells(lngRow, 1) = "" Then Exit For
'write current cell location to sheet INDATA 'rather than writing a loop to search on 'every cycle, by the time the log is at row 21,500 'it could take a long time to search the rows... Range("INDATA!A3").Value = lngRow + 1
'add 1 to row "x" to check next row Next
'opens a COLD DDE link RSIchan = DDEInitiate("RSLinx", "M1138")
'there might be a better way to do this like 'using this somehow ???????? but I don't know how 'data = DDERequest(RSIchan, "f11:0,L7,C7") 'Range("[M1138.xls]LOG!R[x]C1:R[x]C7").Value = data
'read word F8:10 and load into a VB variant variable f810data = DDERequest(RSIchan, "F8:10") 'read word F8:11 and load into a VB variant variable f811data = DDERequest(RSIchan, "F8:11") 'read word F8:12 and load into a VB variant variable f812data = DDERequest(RSIchan, "F8:12") 'read word F8:16 and load into a VB variant variable f816data = DDERequest(RSIchan, "F8:16") 'read word F8:18 and load into a VB variant variable f818data = DDERequest(RSIchan, "F8:18") 'read word F8:17 and load into a VB variant variable f817data = DDERequest(RSIchan, "F8:17") 'read word F8:20 force check #1 and load into a VB variant variable f820data = DDERequest(RSIchan, "F8:20") 'read word F8:21 force check #2 and load into a VB variant variable f821data = DDERequest(RSIchan, "F8:21") 'read word F8:22 force check #3 and load into a VB variant variable f822data = DDERequest(RSIchan, "F8:22") 'read word F8:23 force check #4 and load into a VB variant variable f823data = DDERequest(RSIchan, "F8:23") 'read word F8:24 max force and load into a VB variant variable f824data = DDERequest(RSIchan, "F8:24") 'read word F8:25, get PASS or FAIL status from PLC and load into a VB variant variable varResults = DDERequest(RSIchan, "F8:25")
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Metal 3D printing has rapidly emerged as a key technology in modern design and manufacturing, so it’s critical educational institutions include it in their curricula to avoid leaving students at a disadvantage as they enter the workforce. Download Now
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now