Elevator Simulator
CoDeSys V3
Elevator Simulator
Tab3_CoDeSys_Intro 2014-02-03
1
Settings in CoDeSys
• The exercises with CoDeSys are using an ’Elevator Simulator’
that is written in iX Developer 2.0, and run as a standalone
Modbus TCP slave on localhost (ip 127.0.0.1) in the computer
• The embedded CoDeSys controller are using the
driver “Modbus Master TCP” to communicate
with the ‘Elevator Simulator’ unit
• To control the ’Elevator Simulator’ we need to
make Modbus TCP master settings in the
configuration of the CoDeSys project
• The Modbus drivers are as default present
in the Device Repository of CoDeSys V3.5
Tab3_CoDeSys_Intro 2014-02-03
2
Create a Modbus TCP connection
• First add an ‘Ethernet Adapter’ to the CoDeSys project
• Highlight the ‘Device’ in your CoDeSys application and right-click
• Select ‘Add Device’ and expand ‘Ethernet Adapter’ and select ‘Ethernet’
• Click ‘Add Device’ and ‘Close’
1. Right-click
3. Select Ethernet Adapter
2. Add Device…
4. Add Device
Tab3_CoDeSys_Intro 2014-02-03
3
Add a Modbus TCP Master
• Add the Modbus TCP Master to the Ethernet Adapter
1. Right-click
3. Select Modbus TCP Master
2. Add Device…
Tab3_CoDeSys_Intro 2014-02-03
4. Add Device
4
Add a Modbus TCP Slave
• Add the Modbus TCP Slave to the Master configuration
1. Right-click
3. Select Modbus TCP Slave
2. Add Device…
Tab3_CoDeSys_Intro 2014-02-03
4. Add Device
5
Configure the Modbus TCP Master
• Configure: “ModbusTCP Master Configuration”
Socket Timeout
may need to be
increased to
100ms
Check “auto-reconnect”
Tab3_CoDeSys_Intro 2014-02-03
6
Configure the Modbus TCP Slave
• Configure: “ModbusTCP Slave”
- Localhost ip address: 127.0.0.1
- Unit-ID: 2
Ip = 127.0.0.1
Unit-ID = 2
Tab3_CoDeSys_Intro 2014-02-03
7
Configure the Modbus TCP Slave
• Configure: “Modbus Slave Channel”
• Channel 1 - Read Coils, CYCLIC, t#5ms, READ Offset=16#0, length=16
• Channel 2 - Write Single Register, CYCLIC, t#5ms, WRITE Offset=16#0, length=1
• Channel 3 - Read Holding Registers, CYCLIC, t#100ms, READ Offset=16#1, length=3
• Channel 4 - Write Single Register, CYCLIC, t#100ms, WRITE Offset= 16#4,length=1
Tab3_CoDeSys_Intro 2014-02-03
Add Channel 1, 2, 3 and 4
8
Configure the Modbus TCP Slave
• Configure the “ModbusTCPSlave I/O Mapping” - Channel 1 (Read)
From a browse menu,
Tab3_CoDeSys_Intro 2014-02-03
select GVL variables of
your application, in
this specific order!
9
Configure the Modbus TCP Slave
• Configure the “ModbusTCPSlave I/O Mapping” - Channel 2 (Write)
Tab3_CoDeSys_Intro 2014-02-03
From a browse menu,
select GVL variables of
your application, in
this specific order!
Check “Always update
variables”
10
Settings in Elevator Simulator
• Modbus Slave settings
Note! Settings of the
’Elevator Simulator’
do not need to be
changed!
Tab3_CoDeSys_Intro 2014-02-03
11
Settings in Elevator Simulator
• Modbus TCP controller tags
Note! Settings of the
’Elevator Simulator’
do not need to be
changed!
Tab3_CoDeSys_Intro 2014-02-03
12
Run the Elevator Simulator
• Run the iX Developer exported file, requires iX Developer ver 2.0 Build 2.0.356.0
- PLCSimulator.exe in directory ”PLCSimulator_RT” or …
- Run PLCSimulator.exe in the Output directory of the iX application
Tab3_CoDeSys_Intro 2014-02-03
13
Tab3_CoDeSys_Intro 2014-02-03
14