IDEC FC5A Tutorial

FC5A Modbus Communication Training
Table of Contents
1 System Setup......................................................................................................................3
1.2 1:N Network (Up to 31 Slaves)..................................................................................3
2 Modbus Communication Examples................................................................................... 4
2.1 Example 1 - Reading 1 word and 1 bit data from a slave ..........................................4
2.2 Example 2 - Reading 2 words and 3 bits data from a slave..................................... 11
2.3 Example 3 - Writing 1 word and 1 bit to a slave......................................................12
2.4 Example 4 - Using Request Execution Relay ..........................................................15
2.5 Example 5 - Changing the preset values of Timers or Counters.............................. 20
2
1 System Setup
1.1 1:1 Network
Port 2 Port 2
Modbus Master Modbus Slave
RS2323C/RS485
1.2 1:N Network (Up to 31 Slaves)
Port 2 Port 2
Modbus Master
RS485
Port 2
Port 2
Modbus Slave
Modbus Slave
Modbus Slave
3
2 Modbus Communication Examples
2.1 Example 1 - Reading 1 word and 1 bit data from a slave
In this example, a FC5A Modbus Master will communicate with a FC5A Modbus Slave, whose slave number is 15. The master reads D8057 of the slave, stores it in D0100, reads M8121 and stores it in M0100.
2.1.1 System Setup
Port 2 of two FC5A All-in-one CPUs is connected with a RS232C/RS485 cable. The master communicates with the slave using two communication reque sts.
Port 2 Port 2
Modbus Master Modbus Slave #15
2.1.2 Programming WindLDR - Setting up the Modbus Slave #15
(1) Start WindLDR and create a new program. (2) Select the appropriate PLC type. In this example, FC5A-C24R2 is used.
Select Configure > PLC Selection from the main menu to open the PLC Selection dialog box. Select FC5A-C24R2 in the PLC list and click OK to close the dialog box.
Request #1
Request #2
RS2323C/RS485
Read
Read
D8057 D0100
M8121 M0100
(3) Select Configure > Function Area Settings… from the main menu to open the Function Area
Settings dialog box, and then select the Communication tab.
4
(4) Select Modbus RTU Slave from the dropdown list for Port 2, and then the Communication
Parameters dialog box will appear. Input “15” as the Slave Number, click OK to close the dialog
box, and then click OK to close the Function Area Settings dialog box.
(5) Connect the FC5A as the Modbus Slave to the PC and select Online > Download Program…
from the main menu to open the Download Program dialog box. Click the Download button to start downloading the program.
(6) The Program Download confirmation dialog box will appear, letting you know the setup for the
Modbus Slave has finished.
5
2.1.3 Programming WindLDR - Setting up the Modbus Master
(1) Create a new program and select the appropriate PLC type. In this example, select FC5A-C10R2. (2) Select Configure > Function Area Settings from the main menu to open the Function Area
Settings dialog box, and then select the Communication tab.
(3) Select Modbus RTU Master from the dropdown list for Port 2, the Modbus Master Request Table
dialog box will appear.
(4) Define the first communication request.
(5) Click on the Function Code cell for Request #1 in the dialog box, and the dropdown list will appear.
From the dropdown list, select the 03 Read Holding Register.
Request #1
Modbus Master Modbus Slave
Read
D8057 D0100
6
Note: Modbus Device, Modbus Address, and Function Code.
When using FC5A as a Modbus Slave device, Modbus Addresses are assigned to all the operands available on FC5A. In the page 30-9 of the FC5A User’s Manual, the Address Map of the FC5A Modbus Slave is shown as below. For example, special data registers D8000 thru D8499 are considered the Holding Registers. The Modbus Addresses 408001 thru 408500 are assigned to these operands, and the Function Codes 3, 6 or 16 can be used to manipulate these operands.
In order to obtain the Modbus address of MicroSmart operands, the formula shown in the images below can be used. For example, the Modbus address of D8057 can be calculated as follows:
D8057 (MicroSmart Operand) = (8057 - 8000) + 408001 = 408058 (Modbus Address).
Notes: For your reference, the Modbus Address table “FC5A_ModbusSlave_Ad dressMap.xls” showing all the operands available on FC5A and corresponding Modbus address is available on the IDEC MicroSmart Pentra web page under ‘Documents and Downloads.’
7
Loading...
+ 14 hidden pages