I need help getting data into Microsoft Excel from an Allen-Bradley PLC automatically each time an "event" happens. For example, each time an alarm for a steam valve turns on, I need to record date, time, and duration of the problem. I can write the PLC code to gather the information. However, I am not sure how do get the information from the PLC to Microsoft Excel. Any help is greatly appreciated!
-
I would recommend familiarizing yourself with the world of OPC. – controller Jul 24 '17 at 15:48
-
Well you would have to start with a PLC driver to access your PLC from your computer. What model Allen-Bradley PLC do you have? Do you have a HMI/SCADA software installed on your computer that access the PLC? – Roan Aug 15 '17 at 05:56
2 Answers
The best and simplest way is to use AdvancedHMI & EPPlus. They are very easy to use.
'***************************************
'* Open the existing Excel file
'***************************************
Using ExcelPackage As New OfficeOpenXml.ExcelPackage(New System.IO.FileInfo(".\HistoricalData.xlsx"))
'***************************************
'* Search for the first blank Excel row
'***************************************
Dim FirstBlankRow As Integer = 1
While ExcelPackage.Workbook.Worksheets(1).Cells(FirstBlankRow, 1).Value IsNot Nothing
FirstBlankRow += 1
End While
'**************************************
'* Show om the form the row to use
'**************************************
StatusLabel.Text = "Status: Blank Row found at " & FirstBlankRow
'***********************************************************************
'* Read the first tag within the UDT, then store in the Excel Worksheet
'***********************************************************************
Dim StartTime As String = EthernetIPforCLXCom1.Read("FillRecords[0].StartTime")
ExcelPackage.Workbook.Worksheets(1).Cells(FirstBlankRow, 1).Value = StartTime
'***********************************************************************
'* Read the second tag within the UDT, then store in the Excel Worksheet
'***********************************************************************
Dim EndTime As String = EthernetIPforCLXCom1.Read("FillRecords[0].EndTime")
ExcelPackage.Workbook.Worksheets(1).Cells(FirstBlankRow, 1).Value = EndTime
'**********************************
'* Save the Excel file changes
'**********************************
StatusLabel.Text = "Status: Saving Excel File on " & Now
ExcelPackage.Save()

- 96
- 5
There are many different ways to go about that. Rockwell sells software specifically for that use at a cost. It mostly depends on the scale of the data (amount/freq) and the number of PLCs that you are requesting the data from.
If it is just a smaller application you could use the licensed version of RSLinx Classic (about a grand) to setup a DDE link into Excel. That would be your most direct way in. Shawn over at AutomationBlog has a nice step by step.
https://theautomationblog.com/getting-allen-bradley-plc-and-pac-data-into-excel-using-rslinx/
If you have experience with VisualBasic you could use AdvancedHMI. It is free and can get the data out of your PLC, but then you will have to write the code to either fill your Excel worksheet or put the data into a SQL database.
Otherwise contact your local Rockwell rep and have them determine what might be the best fit.

- 22
- 2
- 5