Learn how to use Microsoft Excel VBA to read and write data from Microsoft Excel to ControLogix using RSLinx.
Note that to read the values from the Allen-Bradley PLC, the Microsoft Excel spreadsheet need not be a Excel Macro-Enabled Workbook. However, if you have to write to the Allen-Bradley PLC, the Microsoft Excel spreadsheet has to be a Excel Macro-Enabled Workbook.
Below is a quick overview of what you need to do in order to read to the ControlLogix PLC from Microsoft Excel spreadsheet via RSLinx Gateway.
1) Create a topic
A topic name with a lock means that the topic is currently connected via DDE connection.
2) Copy DDE/OPC Link from the Edit pull down menu.
Select the item and click on OK. The Data Table Address will be copied to your clipboard.
3) In your Microsoft Excel spreadsheet, right-click on any cell and select Paste Special from the context menu.
Select Paste link and then click on OK button.
4) You should see a Microsoft Excel formula for DDE.
To write a value to the ControlLogix PLC from Microsoft Excel spreadsheet via RSLinx Gateway, is a bit involved. Please see the KZitem video below.
Below is the VBA source code to write value to the Allen-Bradley ControlLogix PLC.
Sub Button1_Click()
DDEChannel = Application.DDEInitiate(app:="RSLinx", topic:="NEW_TOPIC")
DDEItem = "Local:2:I.Data.1"
Set RangeToPoke = Worksheets("Sheet1").Range("B14")
Application.DDEPoke DDEChannel, DDEItem, RangeToPoke
Application.DDETerminate DDEChannel
End Sub
#rockwell, #allenbradley, #ControlLogix,
Негізгі бет Read and Write Data From Microsoft Excel To Allen-Bradley ControLogix Using RSLinx
Пікірлер: 9