Connecting to PLCs of MITSUBISHI product family
Overview
Emulation module makes FlexSim able to connect to PLCs of Mitshubishi MELSEC family.
Several steps are necessary to build a fully functional example:
- Create a GX Works3 project.
- Write the PLC code, compile it and download it to a physical PLC.
- Prepare a FlexSim model and connect it to the PLC.
- Test the model.
Step 1 Create a GX Woks3 project
In this tutorial GX Works3 will be used.
Open GX Works3 and select Project → New from
the menu bar.
Select the PLC Series, Model (this tutorial use a iQ-R R02 CPU) and
Ladder as programming language:
Press OK to continue and confirm subsequent forms:
A new empty project will be created:
Before continue save the project.
Select Online → Current Connection Destination to configure and test the communication with the PLC.
Select Ethernet Board for the PC side I/F and PLC Module for the PLC side I/F
Press CPU Module Direct Coupled Setting button and select Ethernet interface to be used to reach the PLC:
Press Yes and confirm subsequent forms.
Then press Connection Test to verify the connection with the PLC:
Press Ok to close the Current Connection Destination
Now proceed with the project's configuration.
From the Navigation tree select Module Parameters:
Set the IP Address / Sub-net Mask / Default gateway to be used for the PLC.
Moreover set the Enable/Disable Online Change option to Enable All (SLMP).
Do a mouse double click on <Detailed Setting> of the External Configuration Option.
The Ethernet Configuration form will be shown:
Expand the Ethernet Device (General) on the right and drag from the list a SLMP Connection Module on the blue line at the bottom:
Set the Port No. to 4095 (default value for the MC protocol, use another if needed) for the SLMP Connection Module row:
Close the Ethernet Configuration and confirm setting changes.
Now the project is configured.
Step 2 Write the PLC code
Write the PLC code, compile it and download it to a PLC.In this tutorial we will realize a simple delayer where a digital input is delayed in output of 1 seconds.
Once the project is created and configured, from the Navigation tree double click the Device Label:
Then type TIMER1 into column Label Name of row 1, press the "…" ,select Function Block from the Type Category group and from the Data Type list select TON.
Then press Ok to confirm selection and then close the Local Label page.
Now start write the ladder program.
From the Navigation tree select ProgramBody, the ladder editor will be show.
Do a mouse double click at row 1 column 4 and enter TIMER1 in the value field. Then press OK.
The timer will be added. Select row 2 and col 1 then press F5 and write X0 in the value field:
Complete the ladder logic as follow:
When completed the project need to be compiled and downloaded to the PLC.
Select Convert → Rebuild All from the menu bar to compile the project.
Check the Progress output console to verify that there are no errors:
The select Online → Write to PLC... to open the download page:
Select the checkbox at topmost level to select everything then press Execute to start download process:
Wait until download process is complete.
Select Online → Remote Operation(S) to check that the PLC has no error and it is running:
If Program Run led is not green select the RUN radio button and press Execute.
Now the PLC is running and can reached by FlexSim.
Step 3 Prepare a FlexSim model
Prepare a FlexSim model to connect to the device.The model that we will use for this tutorial represents a really simple production system where a box item is packaged into a tote:
Build a model with two sources (one for boxes and one for totes), a queue for totes and a combiner that will join boxes and totes.>
Connect the elements with conveyors, as represented in the figure above and set conveyor speed to 0.5 m/s.
Rename the sources to “Boxes” and “Totes”: Totes source is configured to produce 100 totes at time 0, Boxes source is configured to produce a box every 10s.>
A photo-eye is placed on boxes conveyor, approximately 1 meter before totes conveyor start.
Combiner puts a box into a tote in 5 seconds.
At last, configure the queue to close its outputs at reset and every time that a tote exits from it.
Step 4 Test the model
At first, we will create a Mitsubishi MC Connection to connect our model directly with the PLC.
On FlexSim, create a new Mitsubishi MC Connection by adding a new Emulation/Connection from the Tools menu.
Insert the IP Address and the TCP Port of the PLC then press “Test Connection” button: if everything is all right you should see a detailed message.
If the connection is successful it's possible to create the Control and Sensor variable to connect the PLC tags.
From the menu add a Mitsubishi MC Sensor and Mitsubishi MC Control variables
Now, it’s necessary to define how FlexSim models drives PLC input and how PLC’s output is managed by FlexSim as well.
In our model we want that – when a box covers the photoeye – the PLC input is set to 1 and when the PLC output is set to 1 a tote is released from its queue.
The PLC input should be reset to 0 when the photoeye is clear.
To do this, select the Mitsubishi
MC Sensor, set the Data Type to Bool and
set the Address to X0.
Then associate it to the photoeye and configure it to write values 1 and
0 when the photoeye is covered and cleared.
Also set the initial value to 0 to reset the PLC input at model reset:
Now select the output variable and associate it to the Tote queue.
To do this, select the Mitsubishi MC Control, set the Data Type to Bool and set the Address to Y0.
Then configure a new action and set the queue open its output when the PLC value turns from 0 (oldValue) to 1 (newValue):
Now the model is fully configured and can be reset and run.
Remember to set the FlexSim’s run speed to 1 to match the timing of the PLC.
You should see a tote exiting the queue 1 second after a box covers the photoeye.