哈尔滨九洲MC-Modbus-07367.doc

上传人:大张伟 文档编号:8973576 上传时间:2021-01-27 格式:DOC 页数:25 大小:487KB
返回 下载 相关 举报
哈尔滨九洲MC-Modbus-07367.doc_第1页
第1页 / 共25页
哈尔滨九洲MC-Modbus-07367.doc_第2页
第2页 / 共25页
哈尔滨九洲MC-Modbus-07367.doc_第3页
第3页 / 共25页
哈尔滨九洲MC-Modbus-07367.doc_第4页
第4页 / 共25页
哈尔滨九洲MC-Modbus-07367.doc_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《哈尔滨九洲MC-Modbus-07367.doc》由会员分享,可在线阅读,更多相关《哈尔滨九洲MC-Modbus-07367.doc(25页珍藏版)》请在三一文库上搜索。

1、HJZ-MC-型监控装置HJZ-MC-IV Monitor Equipment通讯规约(MC-Modbus-07367)Communication Conventions(MC-Modbus-07367)哈尔滨九洲电气股份有限公司HARBIN JIUZHOU ELECTRIC CO., LTD.用户通讯规约Communication Conventions For Consumer一, Modbus规约说明1. Modbus Instruction在Modbus规约通讯过程中每个字节的格式为:1个开始位,8个数据位,2个停止位。In the communication course abidi

2、ng by the Modbus Conventions, each bytes format is: 1 start-bit, 8 data-bits and 2 stop-bits.数据的桢结构的格式为:地址域(8位),功能域(8位),数据域(n8位),CRC校验(16位)。The frame format of data: address field (8-bit), function field (8-bit), data field (n8-bit), CRC parity (16-bit).对于九洲公司的监控装置来说:地址域(即监控的地址)是可以通过监控装置设定的。功能域只识别功能

3、编码03表示读一组寄存器;对于收到其他功能编码时,本监控发出例外情况响应。数据域包括多组数据,传送时,高位字节在前,低位字节在后。主机召唤从机的数据域包括从机寄存器的地址和数量,寄存器的地址是以0为参考的(例如查询地址为1的寄存器数值时,寄存器的地址为0);从机响应主机的数据域包括返回数据的字节计数和主机所要的数据。当本监控收到的数据地址是不允许时(即从机的寄存器地址是不允许的),将发出例外情况响应;当收到数据域的数值是不允许时(例如从机的寄存器的数量是不允许的),将发出例外情况响应。CRC域包括一个16位的二进制数,占两个字节,在传送时,低位字节在前,高位字节在后。CRC校验码具体生成方式后

4、面已给出C语言程序。In the monitor equipments produced by Jiuzhou Co., address field (for monitor) can be set through itself. Its function field can only identify function code 03 which stands for reading a group of registers; when it receives other function-codes, the monitor equipment executes exception res

5、ponse. Data field contains groups of data, and low-bit byte goes after high-bit byte. The data field of main machine calling sub-machine contains address information and the number of sub-machines registers; the reference point of address is 0 (Namely, the registers reference address would be 0 if i

6、ts actual address is 1.); the data field of sub-machines response to main machine contains a byte count of returned data and the data demanded by main machine. When the monitor receives unavailable address (namely, the address of sub-machines register is unavailable.), the monitor equipment executes

7、 exception response; when it receives unavailable value of data field (namely, the number of sub-machines registers is unavailable.), the monitor equipment executes exception response. CRC field contains a binary unit, 16-bit and which is occupying 2 bytes. Low-bit byte goes before high-bit byte. Th

8、e detailed generation of CRC parity code is given in the following C language program.1. 读保持寄存器(功能码 03H)1. Read Hold Register (Function Code 03H)下图是主机查询和从机响应的一个例子。主机要查询6号从机的寄存器,寄存器地址为12至14,寄存器地址为12的内容为260(十六进制104),寄存器地址为13的内容为270(十六进制10E),寄存器地址为14的内容为15(十六进制0F)。请注意,信息中规定起始寄存器的地址为11(十六进制为B)。从机以功能编码响应

9、,表明是一种正常的响应。字节计数表示将返回多少个8位数据项。作为遥测和遥信使用.The following table is an example that main machine queries and sub-machine responds. Main machine inquires about registers of sub-machine 6#, and the registers addresses are 1214: 12- 260 (104 in hexadecimal); 13- 270 (10E in hexadecimal); 14- 15 (0F in hexad

10、ecimal). The beginning registers reference address is 11 (B in hexadecimal) complying with our address rule. The normal response of sub-machine is to respond with function code. The count of bytes means how many 8-bit data items will be returned. And it is used to remotely detect and communicate.从机地

11、址(第1个字节)06功能编码(第2个字节)03开始地址高位(第3个字节)00开始地址地位(第4个字节)0B寄存器个数高位(第5个字节)00寄存器个数低位(第6个字节)03校验码(第7、8个字节)CRC低位CRC高位主机查询(十六进制)Sub-machines Address(First Byte)06Function Code(Second Byte)03Beginning Address, High-bit(Third Byte)00Beginning Address, Low-bit(Fourth Byte)0BRegisters unit, High-bit(Fifth Byte)00R

12、egisters unit, Low-bit(Fifth Byte)03Parity Code(Seventh And Eighth Byte)CRC Low-bitCRC High-bitMain machine query (hexadecimal)从机地址(第1个字节)06功能编码(第2个字节)03字节计数(第3个字节)06数据高位(第4个字节)01数据低位(第5个字节)04数据高位(第6个字节)01数据低位(第7个字节)0E数据高位(第8个字节)00数据低位(第9个字节)0F校验码(第10、11个字节)CRC低位CRC高位从机响应(十六进制)Sub-machines Address(F

13、irst Byte)06Function Code(Second Byte)03Count Of bytes(Third Byte)06Datas High-bit(Fourth Byte)01Datas Low-bit(Fifth Byte)04Datas High-bit(Sixth Byte)01Datas Low-bit(Seventh Byte)0EDatas High-bit(Eighth Byte)00Datas Low-bit(Ninth Byte)0FParity Code(Tenth And Eleventh Byte)CRC Low-bitCRC High-bitSub-

14、machine responding (hexadecimal)2预置单个寄存器(功能码 06H(十六进制)2. Initialize Single Register (Function Code 06H (hexadecimal)预置单个寄存器为某个值,查询确定预置那个寄存器,预置值在查询数据域中。作为遥控使用.Initialize a single register with a certain value, and then inquire it to make sure the initialization of this register. Initial value is in t

15、he query data field to be used in remote control.例子:主机把数据07D0(十六进制),保存到地置为002C(十六进制)的从机寄存器中。Example: Main machine saves data 07D0 (hexadecimal) to sub-machines register whose address is 002C (hexadecimal).从机地址(第1个字节)06功能编码(第2个字节)06寄存器地置高位(第3个字节)00寄存器地置低位(第4个字节)2C预置数据高位(第5个字节)07预置数据低位(第6个字节)D0校验码 (第7

16、个字节) (第8个字节)CRC低位CRC高位主机查询(十六进制)Sub-machines Address (First Byte)06Function Code (Second Byte)06Registers Address, High-bit (Third Byte)00Registers Address, Low-bit (Fourth Byte)2CInitial Data, High-bit (Fifth Byte)07Initial Data, Low-bit (Sixth Byte)D0Parity Code (Seventh Byte)(Eighth Byte)CRC Low-

17、bitCRC High-bitMain machine query (hexadecimal)从机地址(第1个字节)06功能编码(第2个字节)06寄存器个数高位(第3个字节)00寄存器个数低位(第4个字节)2C预置数据高位(第5个字节)07预置数据低位(第6个字节)D0校验码 (第7个字节) (第8个字节)CRC低位CRC高位从机响应(十六进制)与主机查询信息相同.Sub-machines Address (First Byte)06Function Code (Second Byte)06Registers unit, High-bit (Third Byte)00Registers uni

18、t, Low-bit (Fourth Byte)2CInitial Data, High-bit (Fifth Byte)07Initial Data, Low-bit (Sixth Byte)D0Parity Code (Seventh Byte)(Eighth Byte)CRC Low-bitCRC High-bitInformation of sub-machines response (hexadecimal) is the same as that of main machine query3. 预置多个寄存器(功能码 10H(十六进制)3. Initialize Multiple

19、Registers (Function Code 10H (hexadecimal)主机通过这个功能码,把多个数据保存到从机寄存器中作为遥调使用。 Main machine saves data 07D0 to sub-machines register for the purpose of remote debugging例如:主机把0064、0010保存到地址为002C、002D的寄存器中。从机地置为06H.Example: Main machine saves 0064, 0010 to registers whose addresses are 002C and 002D respec

20、tively. Sub-machines address is 06H.从机地址(第1个字节)06功能编码(第2个字节)10起始地址高位(第3个字节)00起始地址低位(第4个字节)2C预置寄存器个数高位(第5个字节)00预置寄存器个数低位(第6个字节)02预置字节计数(第7个字节)04数据1高位(第8个字节)00数据1低位(第9个字节)64数据2高位(第10个字节)00数据2低位(第11个字节)10校验码(第12个字节) (第13个字节)CRC低位CRC高位主机查询(十六进制)Sub-machines Address (First Byte)06Function Code (Second By

21、te)10Beginning Address, High-bit (Third Byte)00Beginning Address, Low-bit (Fourth Byte)2CInitial Registers unit, High-bit (Fifth Byte)00Initial Registers unit Low-bit (Sixth Byte)02Count Of Initial Bytes (Seventh Byte)04Data 1, High-bit (Eighth Byte)00Data 1, Low-bit (Ninth Byte)64Data 2, High-bit (

22、Tenth Byte)00Data 2, Low-bit (Eleventh Byte)10Parity Code (Twelfth Byte)(Thirteenth Byte)CRC Low-bitCRC High-bitMain machine query (hexadecimal)从机地址(第1个字节)06功能编码(第2个字节)10起始地址高位(第3个字节)00起始地址低位(第4个字节)2C预置寄存器个数高位(第5个字节)00预置寄存器个数低位(第6个字节)02校验码 (第7个字节) (第8个字节)CRC低位CRC高位从机响应(十六进制)Sub-machines Address (Fir

23、st Byte)06Function Code (Second Byte)10Beginning Address, High-bit (Third Byte)00Beginning Address, Low-bit (Fourth Byte)2CInitial Registers unit, High-bit (Fifth Byte)00Initial Registers unit, Low-bit (Sixth Byte)02Parity Code (Seventh Byte)(Eighth Byte)CRC Low-bitCRC High-bitSub-machine responding

24、 (hexadecimal)4例外情况响应QUERY字节 内容 例子1 从机地址 062 功能编码 033 开始地址高位 004 开始地址低位 0B5 寄存器个数高位 006 寄存器个数低位 037、8 CRC校验 低字节、高字节EXCEPTION RESPONSE1 从机地址 062 功能编码 833 例外情况代码 024、5 CRC校验 低字节、高字节主机查询和从机例外情况响应4. Exception ResponseQUERYByte Content Example1 Sub-machines Address 062 Function Code 033 Origination Addre

25、ss High-bit 004 Origination Address Low-bit 0B5 Registers Number High-bit 006 Registers Number Low-bit 037、8 CRC Parity High-bit, Low-bitEXCEPTION RESPONSE1 Sub-machines Address 062 Function Code 833 Exception Code 024、5 CRC Parity High-bit, Low-bitMain machine query and sub-machine exception respon

26、se正常响应时,从机以原来查询的功能编码应答,在例外情况响应是,从机将功能编码的MSB设为1。In normal response, sub-machine responds with original query function code; in exception response, sub-machine sets MSB of function code to 1.代码意义01从机收到的功能编码是不允许的02查询中的数据地址对于从机来说是非法的03查询中的数据域的数值不是从机所允许的例外情况代码和意义CodeMeaning01The function code received by

27、 sub-machine is unallowed.02The data address in query is nonlicet for sub-machine.03The value of data area in query is unallowed by sub-machine.Codes and Meanings of exception cases4生产CRC校验码的C语言程序:C language procedure of forming CRC parity code:Static ndigned char auchCRCHi=0x00,0xc1,0x81,0x40,0x01,

28、0xc0,0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81, 0x40,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01,0xc0, 0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01, 0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x01,0xc0,0x80,0x41, 0x00,0xc1,0x81,0x40,0

29、x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81, 0x40,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x01,0xc0, 0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x01, 0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40, 0x00,0xc1,0x81,0x

30、40,0x01,0xc0,0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81, 0x40,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0, 0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01, 0xc0,0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41, 0x00,0xc1,0x8

31、1,0x40,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81, 0x40,0x01,0xc0,0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x01,0xc0, 0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41,0x01, 0xc0,0x80,0x41,0x00,0xc1,0x81,0x40,0x00,0xc1,0x81,0x40,0x01,0xc0,0x80,0x41, 0x00,0xc1

32、,0x81,0x40,0x01,0xc0,0x80,0x41,0x01,0xc0,0x80,0x41,0x00,0xc1,0x81,0x40;static char auchCRCLo=0x00,0xc0,0xc1,0x01,0xc3,0x03,0x02,0xc2,0xc6,0x06,0x07,0xc7,0x05,0x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4B,0x8B,0x8A,0x4A,0x4E,0x8E,0x8F,0x4F,0x8D,0x4D,0x4C,0x8C, 0x44,0x84,0x85,0x45,0x87,0x47,0x46,0x86,0x82,0x42,0x43,0x83,0x41,0x81,0x80,0x40;unsigned short CRC16(unsigned char *pushMsg,unsigned short usDataLen) unsigned char uchCRCHi=0xff; unsigned cha

37、r uchCRCLo=0xff; unsigned uIndex; while(usDataLen-) uIndex=uchCRCHi *pushMsg+; uchCRCHi=uchCRCLo auchCRCHiuIndex; uchCRCLo=auchCRCLouIndex; return(uchCRCHi 8 | uchCRCLo); 监控装置寄存器地址如下:Registers Address Of Itinerant Inspection Meter: 名称-寄存器地址Name-Registers Address充电机电压-1Charge Voltage-1充电机电流-2Charge C

38、urrent-2控母电压-3KM Voltage-3控母电流-4KM Current -4电池组电压-5Battery Group Voltage-5电池组电流1-6Battery Group Current-6模拟量备用-7 Analogue Res-7放电电流-8 Discharge IA -8相电压-9A-phase Voltage-9B相电压-10B-phase Voltage-10C相电压-11C-phase Voltage-11A相电流-12A-phase Current-12B相电流-13B-phase Current-13C相电流-14C-phase Current-14说明:

39、以上量传送的数据都是有符号数。 以上量传送的数据和实际显示数据的计算关系如下:实际显示数据=(上传数据高位字节*256+上传数据低位字节)/10Note: All data sent with up quantum are numbers with symbols. The transformation between data sent with up quantum and Actually displayed data are listed below: Actually displayed data = (High-bit byte of data sent up256 + Low-bit byte of data sent up) /10名称-寄存器地址Name-Registers Address第1只电池电压-31Voltage Of Battery 1# -31第2只电池电压-32Voltage Of Battery 2#-32第3只电池电压-33Voltage Of Batter

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1