Validating PLC Logic

Overview of Validating PLC Logic

Before reading this topic, you might want to ensure you are familiar with the concepts in Key Concepts About Emulation and Validating PLC Logic.

In this topic, you'll learn more about the phase in which you validate PLC logic by connecting your model to a PLC or server. We'll refer to an OPC DA Connection, but the setup is similar for other connection types.

Once the PLCs have been programmed, you could possibly use FlexSim to then validate whether the PLCs had been programmed correctly before they are actually implemented in a manufacturing system. To validate this logic, you'd need to connect FlexSim to a PLC server.

After inputting all of the server's permissions, you'd also have to assign all your emulation variables to their appropriate tag IDs on the server. You'd then make the connection shared asset active in FlexSim so that it will directly read or write values on the actual server. This will also cause your internal ladder logic to stop working. Sensors will no longer trigger their on Change event, meaning that any event listening activities will no longer be notified when a sensor variable is changed. Instead, this logic will be handled by the PLC.

At this point you could run the simulation model and test that the PLCs are operating the way they should operate in the actual system. In theory, you would have created a simulation of your future business system in FlexSim. So, the PLC will directly control the elements in the simulation model. You can then observe how the actual PLC has been programmed and compare it to the way the simulation model ran before the PLC was directly connected to the model.

Connecting the Server

To connect a PLC server to a FlexSim simulation model:

  1. Connect the server to the computer on which you'll run the simulation model. You can either run the model on the same computer the server is on or you could connect to it remotely. If connecting remotely, you'll need to ensure that the computer running FlexSim can connect with the computer running the server. You may need to talk to your network administrator to get that working.
  2. Find your connection variable (either in a process flow or in the Emulation tool) and set it to active. You can set it to active by changing the Active property to 1.
  3. In the Address box, type the server's IP Address if needed. You can use localhost if you're running it locally on the same machine as the simulation model.
  4. In the Server box, browse to find the server you'll connect to at the address you specified.
  5. If required, you can enter in the necessary credentials in the User Name and Password boxes.
  6. Set the Update Rate for communicating with the server.
  7. If needed, you can check the Asynchronous update box. This will cause FlexSim to send write events to the server and then continue running the model without waiting for a response from the server.

Adding Tag IDs

You read and write data to an OPC server by defining the tag ID of the data. You can think of a tag ID as a path to where the data is stored. You need to assign tag IDs to all the variables (sensors and controls) that you've added to your simulation model. Each sensor and control has been assigned a tag ID in the PLC server so you need to make sure they are linked together with the same tag ID.

To update the tag ID:

  1. Open the variable's Quick Properties.
  2. Enter the tag ID in the Tag ID box. If you are connected to an OPC server, you can click the Browse button to open the server and browse to the variable's tag ID on the server.
  3. If the variable is a control, you should consider checking the Subscribe to Changes box. This will notify you when the value for the control changes on the OPC server. If needed, you can use the % Deadband if the server uses analog data such as voltage drops or increases to track changes. You can indicate a percentage deadband to filter out small changes and only receive notifications from the server when the voltage change is significant.

Running the Simulation Model

One thing you need to pay attention to when running the simulation model while connected to an active server is the speed at which you are running the model. While you can technically set the run speed to a greater value, you should ideally run it at the 1.00 speed, which means it will run in real time.

Be aware that FlexSim will run in high precision time when the server is active. High precision run time means it will keep the run speed of FlexSim in sync with the run speed of the computer. Stepping will be unavailable while you are connected to an active server.

During the simulation run, it might be good to open the server and watch the values change. You'll be able to better ensure that they match what happens in the simulation model. The ladder logic used with Sensors should no longer be used when the connection is active. You should ensure that there are no tokens moving through this ladder logic during the simulation run.