For industrial engineers, sometimes there arises need to import process data to a computer for manipulation. The data contained in the PLC resgisters can be imported to Excel using Dynamic Data Exchange (DDE). DDE can be used to exchange data between two programs in a server-client setting. The program that has the data is the server and the program that is acquiring the data is the client.
Things You'll Need
- A PLC with connected to the Ethernet,
- computer installed with MS Excel, RSLinx and has an Ethernet connection.
Ensure that the PLC and the computer are connected to the Ethernet. Enable DDE communication in the computer. Simply go to Control Panel>Administrative Tools>Services and enable Network DDE and Network DDE DSDM
Open up RSLinx and configure the drivers so that the PLC can be seen online. To do this, in RSLinx click Communications>Configure Drivers>Ethernet Devices. Then enter the IP address of the PLC.
Before you proceed, check to make sure that the PLC is online. To do this go to Communications>RSWho. If online then go to the next step.
For people communicate, they need a topic to talk about. Therefore you will need to configure a topic in RSLinx. To do this, go to DDE/OPC>Topic Configuration.... Click on New and give it a name. Then associate this topic with the PLC by clicking on the PLC name on the Data Source tab of the same window then click apply.
We are now ready to start a DDE communication. We need to start MS Excel and tell it what the topic is and we are set. This can be done in two ways; using a DDE link and using Macros.
Using DDE Link.
Using Macros (as contained in the RS Linx Online reference):
Reading data from a PLC via DDE requires a macro like the following. This macro assumes that there is a worksheet created and saved as RSLINXXL.XLS. This is the destination of the data that will be read by the macro. This routine reads a word:
'open dde link: testsol=DDE Topic
RSIchan = DDEInitiate("RSLinx", "testsol")
'get data and store in data variable
data = DDERequest(RSIchan, "N7:30")
'Paste data into selected range
Range("[RSLINXXL.XLS]DDE_Sheet!C7").Value = data
'close dde link
Hurray!! Now we are done! Use the data imported as desired.
Tips & Warnings
- To use macros in Excel, you will need to enable them and sometimes have to set security level to low.
- The RS Linx Online reference is a great resource to troubleshoot and correct errors.
How to Connect to Micrologix PLC
Miicrologix PLCs are manufactured and sold by Allen Bradley. PLCs are programmed using ladder logic. In order to program PLCs, it first...