Ch3 modbus rtu master subroutine example – Rockwell Automation 1769-SM2 Compact I/O DSI/Modbus Communication Module User Manual
Page 124

7-22
CompactLogix Example Ladder Programs
CH3 Modbus RTU Master Subroutine Example
In Multi-Drive mode, any channel can be configured for Modbus RTU
Master operation. In the CompactLogix Multi-Drive ladder logic
example, CH3 is used to communicate with a PowerFlex 70 drive via
Modbus RTU operation.
Figure 7.7 Example CompactLogix Modbus RTU Ladder Logic CH3 Subroutine
1769-SM2 Channel 3 Modbus RTU Master Subroutine
Channel 3 consists of a single PowerFlex 70 drive with a 20-COMM-H adapter.
Write Logic Command and Reference.
CH3_MSG1_REQ[0] = Slave Address ("15" is the 20-COMM-H address)
CH3_MSG1_REQ[1] = Function Code ("16" is Write Multiple Registers command)
CH3_MSG1_REQ[2] = Starting Address ("0" = 4x0001)
CH3_MSG1_REQ[3] = Length ("3")
CH3_MSG1_REQ[4] = Logic Command word
CH3_MSG1_REQ[5] = MSW of 32-bit Reference
CH3_MSG1_REQ[6] = 16-bit Reference or LSW of 32-bit Reference
0
Channel 3
Write Control
CH3_WR_Control
EN
DN
ER
Type - CIP Generic
Message Control
CH3_MSG1 ...
MSG
i
Execute the control message continuously if the CH3_WR_Control bit is ON.
1
CH3_MSG1.DN
CH3_MSG1.ER
U
CH3_MSG1.EN
Read Logic Status and Feedback.
CH3_MSG2_REQ[0] = Slave Address ("15" is the 20-COMM-H address)
CH3_MSG2_REQ[1] = Function Code ("4" is Read Input Registers command)
CH3_MSG2_REQ[2] = Starting Address ("0" = 3x0001)
CH3_MSG2_REQ[3] = Length ("3")
The response data is stored in:
CH3_MSG2_RESP[0] = Logic Status word
CH3_MSG2_RESP[1] = MSW of 32-bit Feedback
CH3_MSG2_RESP[2] = 16-bit Feedback or LSW of 32-bit Feedback
2
Channel 3
Read Status
CH3_RD_Status
EN
DN
ER
Type - CIP Generic
Message Control
CH3_MSG2 ...
MSG
Execute the status message continuously if the CH3_RD_Status bit is ON.
3
CH3_MSG2.DN
CH3_MSG2.ER
U
CH3_MSG2.EN