Using model-based simulation in automation.

Using computer to model a P&ID to its closest level to the reality is not a new concept in industrial control. There are many applications and devices especially developed to fulfill this goal, to simulate the actual pumps, valves, tanks, and even physical and chemical processes defining the real behavior of the different parts of the process to make it as real as possible. In some situation the communication processes are also simulated to minimize the effort needed to get to a successful control system.

I am currently using a very simple environment using Siemens PLCSIM, to simulate the actual PLC device, and a self developed environment in Delphi that communicate with the PLCSIM, to mimic the various parts of the process, including various kind of pumps, valves, level transmitters, analog values, switches, and likes, to simulate as close as possible to reality before deploying the system control at site. Some parts of process are simulated in the background code, to simulate other parts of process that needs more sophisticated models involving some sort of mathematical modeling of physical and chemical behavior of that element. The complexity of the model depends of many factors, but usually some very simple assumptions eliminate the use of complex parts, and let me to concentrate more on the behavior of the control system itself. But it doesn’t prevent me to use complex algorithms when they are available and necessary.

The processes I usually worked with are mostly very simple in nature, involving only simple conditions that can be simulated with very simple physical laws, and even this simple and none mathematical simulation environment has its own benefits.

  1. Allowing the process expert of the contractor to see what their designed system will look like from an automatic control system point of view. It will help them to apply the final touch before even turning on/off an actual device.
  2. Allow us to test the control system, and to test various working and error scenarios with the designed control system.
  3. It will help us to find errors and correct them, in a very peaceful environment, without worrying about the issues if this would happen in a real place with real devices. In some situation the control sequences can be very complex, and testing and debugging this algorithm, and finding implementation bugs, in real circumstances can be very hard, if not impossible.
  4. This will help us to be open to apply changes even after the system has been deployed in the site, and to test the new needs, that usually arise in fields from an operator point of view, because of the new conditions that no one has been faced with it before.
  5. All the above benefits decrease the time, effort and negative effects on devices and experts involving in all steps of design, implementation and deployment. This will minimize the time and financial impact that is inherited in situation that these modifications and debugging would be done in the site with real operators and devices.
  6. My own simulating system doesn’t have automatic code generation ability, but I have compensated it with writing and using pre-built components in the Delphi programming environment to be able to use these blocks as building brick of the model-based simulated process. In future effort this approach can be diverted as close as possible to a real model-based simulation.

Connecting to Allen Bradley RS Emulate through DDE with MS Excel

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

Using virtual systems in automation.

Virtual systems are life saver in many industries, to use many benefits of the changing technology. Fortunately trend of this changing is toward better and more powerful systems. I don’t like to discuss its financial reasons of the technology growth, but I always look at this with positive impression. We have to adapt ourselves to this evolution and it is unavoidable.

I am using virtualization with three types of my projects.

  1. The first is a fire alarm system that is using for programming an old DOS type application that is not really compatible with even Windows XP SP3 DOS command prompt. So I use a Windows XP operating system virtual machine, without any service pack that will conflict with the application.
  2. The second type is an HMI application used in the above mentioned fire alarming system that uses bitmap graphics as background, with absolute positioning of the device icons on this background. To have strictly the same environment at office and in the site, I use a very similar virtual system to the computer of that site, so that I may transfer the files from office to site and vice versa, without needing to have the actual system that should be used in site at office, and also to transfer the files from site to office and to work on them later.
  3. I am using Step7 and WinCC on Windows XP, and when I want to transfer the files to site, I use my laptop that has as its host system Windows Vista. This situation can be used in many similar situations, to bypass the compatibility issues.

To summarize to use the virtualization in our industry, automation and control, is very similar to the other virtualization using industries. They are using this method in very intuitive methods, and I used them extensively when I was involved in ISP (Internet Service Provider) industry. It has the following saving and benefit. But I should note that using this technique is only applied to the parts that are PC dependant. I haven’t used PC based control systems, but in this case in am not quite sure if the virtualization may work with real-time specification that is usually embedded in such systems.

  1. Unused CPU power- It may better use idle times of an ordinary PC for doing job of many.
  2. Green environment- Producing less heat and less gases to help us to have a better environment.
  3. Needing less power- This means using less energy and of course less expenses on power bills.
  4. Independence from Platform- This add a new layer of abstraction of using hardware, in situation that changing hardware will impose costs that are not feasible at that time. Also this abstraction is used in software, as we may install different type of OS even on the same PC.
  5. Portability- We may install and configure the system in a peaceful office environment, and then transfer it to the site, and vice versa, in case when we want to investigate into the causes of problems of the systems that were in site.
  6. Re-usability- This virtual system can be used many times in many different situations, without getting into the time consuming process of installation of systems.