If you'll recall from the Key Concepts About Emulation topic, the following is the basic process for building an emulation simulation project:
In this topic, you'll learn more about the phase in which you create the PLC logic in a process flow:
Before reading this topic, consider reading the chapter about Conveyors for more information about working with conveyor objects in FlexSim. You might also want to consider completing the Emulation Tutorial if you'd like hands-on experience with the principles discussed in this topic.
Before starting an emulation project, it will be good to know which kind of protocol your future system will use. Although you can change these settings later, it helps to know which kind of protocol your system will use before you design the PLC logic in process flow.
FlexSim currently supports the following protocols:
After you know which type of protocol you're using, it might also be helpful to learn about what kinds of logical inputs it can accept, such as boolean values, strings, numbers, etc. Talking to the eventual PLC programmer about these concerns could help.
The first step in setting up an emulation project is to add variables to your process flow. Variables are a special type of process flow shared asset that can store different values, reference objects and nodes or take on the functionality of another class. For emulation, Variables can be used as server connections, sensors (PLC inputs) or controls (PLC outputs). See Key Concepts About Emulation - Key Terms for a more comprehensive explanation of the differences between these types of variables.
When adding sensor variables to a process flow, keep in mind that sensors will input values from the 3D model and write those values to the server. When you're setting up a sensor, you need to determine which events in the simulation model will change the value for that sensor on the server. Be aware that the range of possible values will depend on the type of server you are using and the types of sensor inputs that are available.
To add a sensor to your process flow:
Alternatively, you could set up the sensor in the Emulation tool and then link the process flow variable to that sensor in the tool instead. See Using the Emulation Tool for more information.
When adding control variables to a process flow, keep in mind that controls will output values to the 3D model. Controls only read values from a server; they never write them. When you're setting up a control, you need to determine which actions the control will take when it receives a specific value from the server. Be aware that the range of possible values will depend on the type of server you are using and the types of control output settings that are available.
To add a control to your process flow:
Alternatively, you could set up controls in the Emulation tool and then link the process flow variable to that sensor in the tool instead. See Using the Emulation Tool for more information.
When adding a server connection, the important thing to keep in mind is whether the server is inactive or active. See Key Concepts About Emulation - Active vs. Inactive Connections for information about the differences.
To set up a server connection:
0
.Alternatively, you could set up the server connection in the Emulation tool. See Using the Emulation Tool for more information.
In many respects you'll build the PLC logic in a process flow the same way you would build the logic in any process flow. The Emulation Tutorial provides an example of some of the logic you could possibly build in an emulation project.
When building you can use some additional activities to read from and write to your sensors and controls:
You can alternatively use the Emulation tool to set up your connections, sensors, and controls.
You can open the Emulation tool from the Toolbox. The Emulation tool can be found under the Connectivity sub-menu.
Use the Connections tab to add a connection. The options that are available for connections are the same ones available for a connection variable in the process flow.
Then use the Variables tab to add sensors and controls. Again, the options that are available will mirror the same properties that you'll find in the process flow variables.
To link a process flow variable to the emulation tool:
Alternatively, you can use the Sampler button
next to the
Variable or Value box and click on the emulation tool
in the Toolbox or the connection or variable in the emulation tool window.
If desired, you can use the ability of process flows to create instances in an emulation project. Process flow instances might be ideal if you have two or more objects in your 3D model that will use identical logic and might possibly each use identical PLC servers that all have the same logic but with different variables.
For example, perhaps you've got a machine that is a labeler or a packaging machine and it will need an entire PLC dedicated to it. However, you might have 50 of these kinds of machines throughout your system that will run identical logic. You could create a fixed resource object for this labeler and emulate the PLC logic for it using a fixed resource process flow. Then, you'd add copies of this fixed resource object to the 3D model. When the model runs, each fixed resource would run its own instance (copy) of the process flow.
There are a few things you need to consider when working with process flow instances, which will be explained in the following sections:
When you are using emulation variables in a fixed resource process flow, you have the option to set their Type property to either global or local:
In this section we'll refer to properties of an OPC DA Connection, but the premise is the same for other protocols.
If your connection type is set to Local so that each instance will create a new
connection, you'll need to define the address and server for each instance. If all of the
servers are running on the same computer, then the Address will
remain the same for all connections. In this case, you would make the
Server property dynamic. You could possibly use the code
current.ServerName
to get the value of a label on the object.
If the servers are running on different computers, then you'll need to make the Address property dynamic to define a different address for each instance. This could be done in the same way the Server was made dynamic.
In this section we'll refer to properties of an OPC DA Tag, but the premise is the same for other protocols.
When you get to the stage in which you are going to validate the PLC logic, you'll need to be able to assign a unique tag ID to each instance of the fixed resource:
current.name
to get the name of the object.
Then you could name each object based on what group they will use. As another
alternative, you can set each object to have the same label such as GroupName
and then give each object its own unique value. In the Tag Instance Specifier, you'd
then use the code current.GroupName
to get the value of that label for each
object.%s
to dynamically reference the tag instance specifier. Add
additional text to define the specific tag ID for the variable. For example,
%s.PhotoEyes.A13
or PhotoEyes.%sA13
See Process Flow Instances for more information.