In my learning path to program Allen Bradley PLC, I choose RSLogix5000, RSLogix Emulate 5000 and RSLinx Classic Gateway to be able to have an environment capable of editing and testing the logics I write. RSLinx plays, as its name imply, to link these two components, such that we may write, download, monitor and test if the written program is fulfilling the control philosophy we are looking for. But still we need to another component that should facilitate the simulation to mimic the behavior we usually expect from the devices that a real PLC will work within a real plant with. There are many applications that do this, releasing the control engineer to focus on his program and the way he should satisfy the customer’s need, by doing exactly what in control philosophy is requested. As in this stage I cannot afford to buy such application, that are usually very high priced as they are intending to simulate very complex processes and behaviors that we may face in a real plant, so I decided to write one very simple simulator for my own use, to help me in my learning process.
The main goal then is to write an application, that provide the needed devices behavior and responses to the PLC through the interfaces RSLogix Emulator provide. For the first tests, thanks to Mr. Marc Waarle from Rockwell Automation (Allen Bradley) group of LinkedIn, I decided to use DDE interface. So to share my expertise and what I have learnt, I am writing this short guide. The following is steps I have done to communicate through DDE from MS Excel® to RSLogix Emulate and vice versa. I am not claiming that this is the best way, but it is the way I have tested and it works. Any suggestion so is welcomed and will be applied if appropriate.
-
- The first thing first, so I opened the RSLogix 5000, and build a new project. I choose 1756-A17 Backplane, and added Emulator RSLogix Emulate 5000 Controller Version 17 as controller, in slot 16. Usually PLC is inserted in slot 1, but here as it is the simulation, and in a real situation this project should be capable to be shared with one that is used directly in the site to program the real PLC, I have reserved slot 1 for this purpose, and inserted the emulated PLC in slot 16. Then when we have tested the program and get sure about everything to work the way they should, we just delete the emulated PLC, and insert the real one used in control panel in slot 1. In this project I just defined some tags, of type REAL and DINT, because they are used frequently in real projects. Also I have added some I/O card to make the situation a bit closer to real feeling. I didn’t write any code, as I just want to test how I may read and write tags from PLC and to it.
- Then I opened RSLogix Emulate 5000 Chassis Monitor, in slot 16 I insert RSLogix Emulate 5000 EmuLogix5868 Controller Version 17.
- Now it is time to define links in RSLinx. First I configure a Virtual Backplane (SoftLogix58xx, USB) and name it AB_VBP-1, in slot 0. Now if we check in RSWho, we may see the AB_VBP-1 has been added to the workstation tree, and if we expand its node we may see our emulator and its communication channel 0, DF1 active and working. From DDE/OPC menu I also define a new topic through “DDE/OPC>Topic Configuration” menu selection. I name it “topic1”, and while this topic is selected in left pane of the “DDE/OPC Topic Configuration” dialog, in right pane I highlighted the AB_VBP-1 and then press “Done” button of this dialog to complete the topic definition and closing the dialog. If we open “Active DDE/OPC Topic/Item List” from “DDE/OPC” menu item, we should see the new topic “topic1” in the “List of Topics/Items currently being serviced”.
- Then I create a new excel file and define in it two buttons that one read from the PLC to cells of the excel file, and the other write from cells to the PLC. I am using MS Excel® 2007 and I did the actual communication with the following functions :
- DDEInitiate – to initiate the DDE communication.
DDE_RSLinx = DDEInitiate(“RSLINX”, “topic1”)
If successful the “DDE_RSLinx” will contains the DDE channel number used in subsequent DDE communication. Otherwise the function will be terminated with a proper message. - DDERequest – to request a tag from PLC.
realdata = DDERequest(DDE_RSLinx, “REAL_Array[” & i & “]”)
dintdata = DDERequest(DDE_RSLinx, “DINT_Array[” & i & “]”)
i is the number of the desired tag in the PLC. Actually the second parameter to DDE_Request should be the name of the tag as is defined exactly in the PLC project. Hear as I have defined an array of DINT and REAL, the request was done by asking about the array tag name.
Again if the operation is successful we may continue, otherwise we should check for the reason and resolution of the error. - Finally to call DDETerminate to terminate and closing and releasing the resources reserved for the connection.
DDETerminate DDE_RSLinx
- DDEInitiate – to initiate the DDE communication.