290 likes | 562 Views
Using Modbus Protocol with OEMax Products Feb 26 ~ Mar 2, 2007. K.J Kim RAK OBB Strategic Marketing. What is Modbus ?. Introduced by Modicon ,1979 Modbus communication interface for a multidrop network based on a master/client architecture Connection Type: RS-232, RS-485, TCP/IP
E N D
Using Modbus Protocol with OEMax ProductsFeb 26 ~ Mar 2, 2007 K.J Kim RAK OBB Strategic Marketing
What is Modbus ? • Introduced by Modicon ,1979 • Modbus communication interface for a multidrop network based on a master/client architecture • Connection Type: RS-232, RS-485, TCP/IP • Message based Communication • Coil : Discrete Output Value
Modbus Communication Stack Only, explain Modbus RS-232C In this training
Modbus Serial Transmission Modes • Two Modbus Serial Modes • Modbus/ASCII ASCII Code Format • Modbus/RTU (Remote Terminal Unit) Binary Format
General Modbus Frame • General Modbus Frame PDU (ProtocolData Unit) Additional Address Function Code Data Error Check ADU (ApplicationData Unit)
Modbus Addressing • Device and Modbus address ranges • All Registers will be assigned a number between 1 and 10000 • Modbus message addresses are used a number between 0 and 9999 • So, To access correctly, You must subtract -1 (or -10001 or -40001) • [Example] If you want to read Output coil 18, You must use value 17 in Modbus message Maximum Value is device dependent.
Modbus Function Code • Common Modbus Function Code NX Series PLC supports these kinds of Functions which are blue color.
Function 01 : Read Coil Status Function 01 : Query Structure Function 01 : Answer Structure This sample is “Read Coils 20 (0x14) to 56 (0x38) from device 17 ((0x11)” The Address will be 0013H because 20-1=19=13H.
Function 02 : Read Input Status Function 02 : Query Structure Function 02 : Answer Structure This sample is “Read Inputs 10197 ~ 10218 from device 17” The Address will be 00C4H because 10197-10001=196 =C4H .
Function 03 : Read Holding Registers Function 03 : Query Structure Function 03 : Answer Structure This sample is “Read Register 40108 ~ 40110 from device 17” The Address will be 006BH because 40108-40001=107= 6BH.
Function 04 : Read Input Registers Function 04 : Query Structure Function 04 : Answer Structure This sample is “Read Register 30009 from device 17” The Address will be 0008H because 30009-30001=8.
Function 05 : Force Single Coil Function 05 : Query Structure Function 05 : Answer Structure This sample is “Request to Force Coil 173 ON in Slave Device 17” The Address will be 0xAC because 173-1=172=0xAC FF00 ON, 0000OFF
Function 06 : Preset Single Register Function 06 : Query Structure Function 06 : Answer Structure This sample is “Request to preset register 40002 to 00 03 in Slave Device 17” The Address will be 0001H because 40002-40001=1.
Function 07 : Read Exception Status Function 07 : Query Structure Function 07 : Answer Structure This sample is “Request to Read Exception Status in Slave Device 17”
Function 15 : Force Multiple Coils Function 15 : Query Structure Function 15 : Answer Structure This sample is “Request to Force 10 Coils starting at coil 20 in Slave Device 17”
Function 16 : Preset Multiple Registers Function 16 : Query Structure Function 16 : Answer Structure This sample is “Request to preset two registers starting at 40002 to 00 0A and 01 02 in Device 17
Function 17 : Report Slave ID Function 11 : Query Structure Function 11 : Answer Structure This sample is “Request to Report ID and Status of Slave Device 17”
Samples Master Query with ASCII/RTU Framing Slave Response with ASCII/RTU Framing
Communicationwith NX Series PLC • To operate Modbus RTU, Must Enable F12.2 (Port1) or F12.9 (Port2) • Addresses Map for Modbus • NX7(S) : Port 1 – Slave , Port2 – Slave & Master
Communication with NX Series PLC • Let’s see Modbus/RTU Communication Sample Program which is programmed by Visual Basic.Net 2005.
Configuration Flag in NX Series PLC When F12.2 or F12.9 are set, Port1 or 2 of CPU will be configured to support Modbus RTU slave protocol.
Communication System Register • Special Register (SR298 ~ SR373) is provided for holding the data transmitted and received
Calculation CRC 2 Byte CRC CRC Calculation Scope CRC = 65535 For i = 0 To PL - 1 CRC = Int(CRC / 256) Xor CRCTable((CRC Xor DATABLOCK(i)) And 255) Next i CRC : Cyclic Redundancy Check
TM SM Maximum Value for OEMs