哈尔滨九洲MCModbus07367培训资料.docx

上传人:b****2 文档编号:20024293 上传时间:2023-04-24 格式:DOCX 页数:22 大小:27.71KB
下载 相关 举报
哈尔滨九洲MCModbus07367培训资料.docx_第1页
第1页 / 共22页
哈尔滨九洲MCModbus07367培训资料.docx_第2页
第2页 / 共22页
哈尔滨九洲MCModbus07367培训资料.docx_第3页
第3页 / 共22页
哈尔滨九洲MCModbus07367培训资料.docx_第4页
第4页 / 共22页
哈尔滨九洲MCModbus07367培训资料.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

哈尔滨九洲MCModbus07367培训资料.docx

《哈尔滨九洲MCModbus07367培训资料.docx》由会员分享,可在线阅读,更多相关《哈尔滨九洲MCModbus07367培训资料.docx(22页珍藏版)》请在冰豆网上搜索。

哈尔滨九洲MCModbus07367培训资料.docx

哈尔滨九洲MCModbus07367培训资料

 

哈尔滨九洲MC-Modbus-07367

HJZ-MC-Ⅳ型监控装置

HJZ-MC-IVMonitorEquipment

通讯规约(MC-Modbus-07367)

CommunicationConventions(MC-Modbus-07367)

 

哈尔滨九洲电气股份有限公司

HARBINJIUZHOUELECTRICCO.,LTD.

用户通讯规约

CommunicationConventionsForConsumer

一,Modbus规约说明

1.ModbusInstruction

在Modbus规约通讯过程中每个字节的格式为:

1个开始位,8个数据位,2个停止位。

InthecommunicationcourseabidingbytheModbusConventions,eachbyte’sformatis:

1start-bit,8data-bitsand2stop-bits.

数据的桢结构的格式为:

地址域(8位),功能域(8位),数据域(n×8位),CRC校验(16位)。

Theframeformatofdata:

addressfield(8-bit),functionfield(8-bit),datafield(n×8-bit),CRCparity(16-bit).

对于九洲公司的监控装置来说:

地址域(即监控的地址)是可以通过监控装置设定的。

功能域只识别功能编码03表示读一组寄存器;对于收到其他功能编码时,本监控发出例外情况响应。

数据域包括多组数据,传送时,高位字节在前,低位字节在后。

主机召唤从机的数据域包括从机寄存器的地址和数量,寄存器的地址是以0为参考的(例如查询地址为1的寄存器数值时,寄存器的地址为0);从机响应主机的数据域包括返回数据的字节计数和主机所要的数据。

当本监控收到的数据地址是不允许时(即从机的寄存器地址是不允许的),将发出例外情况响应;当收到数据域的数值是不允许时(例如从机的寄存器的数量是不允许的),将发出例外情况响应。

CRC域包括一个16位的二进制数,占两个字节,在传送时,低位字节在前,高位字节在后。

CRC校验码具体生成方式后面已给出C语言程序。

InthemonitorequipmentsproducedbyJiuzhouCo.,addressfield(formonitor)canbesetthroughitself.Itsfunctionfieldcanonlyidentifyfunctioncode03whichstandsforreadingagroupofregisters;whenitreceivesotherfunction-codes,themonitorequipmentexecutesexceptionresponse.Datafieldcontainsgroupsofdata,andlow-bitbytegoesafterhigh-bitbyte.Thedatafieldofmainmachinecallingsub-machinecontainsaddressinformationandthenumberofsub-machine’sregisters;thereferencepointofaddressis0(Namely,theregister’sreferenceaddresswouldbe0ifitsactualaddressis1.);thedatafieldofsub-machine’sresponsetomainmachinecontainsabytecountofreturneddataandthedatademandedbymainmachine.Whenthemonitorreceivesunavailableaddress(namely,theaddressofsub-machine’sregisterisunavailable.),themonitorequipmentexecutesexceptionresponse;whenitreceivesunavailablevalueofdatafield(namely,thenumberofsub-machine’sregistersisunavailable.),themonitorequipmentexecutesexceptionresponse.CRCfieldcontainsabinaryunit,16-bitandwhichisoccupying2bytes.Low-bitbytegoesbeforehigh-bitbyte.ThedetailedgenerationofCRCparitycodeisgiveninthefollowingClanguageprogram.

1.读保持寄存器(功能码03H)

1.ReadHoldRegister(FunctionCode03H)

下图是主机查询和从机响应的一个例子。

主机要查询6号从机的寄存器,寄存器地址为12至14,寄存器地址为12的内容为260(十六进制104),寄存器地址为13的内容为270(十六进制10E),寄存器地址为14的内容为15(十六进制0F)。

请注意,信息中规定起始寄存器的地址为11(十六进制为B)。

从机以功能编码响应,表明是一种正常的响应。

字节计数表示将返回多少个8位数据项。

作为遥测和遥信使用.

Thefollowingtableisanexamplethatmainmachinequeriesandsub-machineresponds.Mainmachineinquiresaboutregistersofsub-machine6#,andtheregisters’addressesare12~14:

12---260(104inhexadecimal);13---270(10Einhexadecimal);14---15(0Finhexadecimal).Thebeginningregister’sreferenceaddressis11(Binhexadecimal)complyingwithouraddressrule.Thenormalresponseofsub-machineistorespondwithfunctioncode.Thecountofbytesmeanshowmany8-bitdataitemswillbereturned.Anditisusedtoremotelydetectandcommunicate.

从机地址(第1个字节)

06

功能编码(第2个字节)

03

开始地址高位(第3个字节)

00

开始地址地位(第4个字节)

0B

寄存器个数高位(第5个字节)

00

寄存器个数低位(第6个字节)

03

校验码(第7、8个字节)

CRC低位

CRC高位

主机查询(十六进制)

Sub-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

03

BeginningAddress,High-bit(ThirdByte)

00

BeginningAddress,Low-bit(FourthByte)

0B

Register’sunit,High-bit(FifthByte)

00

Register’sunit,Low-bit(FifthByte)

03

ParityCode

(SeventhAndEighthByte)

CRCLow-bit

CRCHigh-bit

Mainmachinequery(hexadecimal)

从机地址(第1个字节)

06

功能编码(第2个字节)

03

字节计数(第3个字节)

06

数据高位(第4个字节)

01

数据低位(第5个字节)

04

数据高位(第6个字节)

01

数据低位(第7个字节)

0E

数据高位(第8个字节)

00

数据低位(第9个字节)

0F

校验码(第10、11个字节)

CRC低位

CRC高位

从机响应(十六进制)

Sub-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

03

CountOfbytes(ThirdByte)

06

Data’sHigh-bit(FourthByte)

01

Data’sLow-bit(FifthByte)

04

Data’sHigh-bit(SixthByte)

01

Data’sLow-bit(SeventhByte)

0E

Data’sHigh-bit(EighthByte)

00

Data’sLow-bit(NinthByte)

0F

ParityCode

(TenthAndEleventhByte)

CRCLow-bit

CRCHigh-bit

Sub-machineresponding(hexadecimal)

2.预置单个寄存器(功能码06H(十六进制))

2.InitializeSingleRegister(FunctionCode06H(hexadecimal))

预置单个寄存器为某个值,查询确定预置那个寄存器,预置值在查询数据域中。

作为遥控使用.

Initializeasingleregisterwithacertainvalue,andtheninquireittomakesuretheinitializationofthisregister.Initialvalueisinthequerydatafieldtobeusedinremotecontrol.

例子:

主机把数据07D0(十六进制),保存到地置为002C(十六进制)的从机寄存器中。

Example:

Mainmachinesavesdata07D0(hexadecimal)tosub-machine’sregisterwhoseaddressis002C(hexadecimal).

从机地址(第1个字节)

06

功能编码(第2个字节)

06

寄存器地置高位(第3个字节)

00

寄存器地置低位(第4个字节)

2C

预置数据高位(第5个字节)

07

预置数据低位(第6个字节)

D0

校验码(第7个字节)

(第8个字节)

CRC低位

CRC高位

主机查询(十六进制)

Sub-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

06

Register’sAddress,High-bit(ThirdByte)

00

Register’sAddress,Low-bit(FourthByte)

2C

InitialData,High-bit(FifthByte)

07

InitialData,Low-bit(SixthByte)

D0

ParityCode(SeventhByte)

(EighthByte)

CRCLow-bit

CRCHigh-bit

Mainmachinequery(hexadecimal)

从机地址(第1个字节)

06

功能编码(第2个字节)

06

寄存器个数高位(第3个字节)

00

寄存器个数低位(第4个字节)

2C

预置数据高位(第5个字节)

07

预置数据低位(第6个字节)

D0

校验码(第7个字节)

(第8个字节)

CRC低位

CRC高位

从机响应(十六进制)与主机查询信息相同.

Sub-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

06

Register’sunit,High-bit(ThirdByte)

00

Register’sunit,Low-bit(FourthByte)

2C

InitialData,High-bit(FifthByte)

07

InitialData,Low-bit(SixthByte)

D0

ParityCode(SeventhByte)

(EighthByte)

CRCLow-bit

CRCHigh-bit

Informationofsub-machine’sresponse(hexadecimal)isthesameasthatofmainmachinequery

3.预置多个寄存器(功能码10H(十六进制))

3.InitializeMultipleRegisters(FunctionCode10H(hexadecimal))

主机通过这个功能码,把多个数据保存到从机寄存器中

作为遥调使用。

Mainmachinesavesdata07D0tosub-machine’sregisterforthepurposeofremotedebugging

例如:

主机把0064、0010保存到地址为002C、002D的寄存器

中。

从机地置为06H.

Example:

Mainmachinesaves0064,0010toregisterswhoseaddressesare002Cand002Drespectively.Sub-machine’saddressis06H.

从机地址(第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-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

10

BeginningAddress,High-bit(ThirdByte)

00

BeginningAddress,Low-bit(FourthByte)

2C

InitialRegister’sunit,High-bit(FifthByte)

00

InitialRegister’sunitLow-bit(SixthByte)

02

CountOfInitialBytes(SeventhByte)

04

Data1,High-bit(EighthByte)

00

Data1,Low-bit(NinthByte)

64

Data2,High-bit(TenthByte)

00

Data2,Low-bit(EleventhByte)

10

ParityCode(TwelfthByte)

(ThirteenthByte)

CRCLow-bit

CRCHigh-bit

Mainmachinequery(hexadecimal)

从机地址(第1个字节)

06

功能编码(第2个字节)

10

起始地址高位(第3个字节)

00

起始地址低位(第4个字节)

2C

预置寄存器个数高位(第5个字节)

00

预置寄存器个数低位(第6个字节)

02

校验码(第7个字节)

(第8个字节)

CRC低位

CRC高位

从机响应(十六进制)

Sub-machine’sAddress(FirstByte)

06

FunctionCode(SecondByte)

10

BeginningAddress,High-bit(ThirdByte)

00

BeginningAddress,Low-bit(FourthByte)

2C

InitialRegister’sunit,High-bit(FifthByte)

00

InitialRegister’sunit,Low-bit(SixthByte)

02

ParityCode(SeventhByte)

(EighthByte)

CRCLow-bit

CRCHigh-bit

Sub-machineresponding(hexadecimal)

4.例外情况响应

QUERY

字节内容例子

1从机地址06

2功能编码03

3开始地址高位00

4开始地址低位0B

5寄存器个数高位00

6寄存器个数低位03

7、8CRC校验低字节、高字节

EXCEPTIONRESPONSE

1从机地址06

2功能编码83

3例外情况代码02

4、5CRC校验低字节、高字节

主机查询和从机例外情况响应

4.ExceptionResponse

QUERY

ByteContentExample

1Sub-machine’sAddress06

2FunctionCode03

3OriginationAddressHigh-bit00

4OriginationAddressLow-bit0B

5Register’sNumberHigh-bit00

6Register’sNumberLow-bit03

7、8CRCParityHigh-bit,Low-bit

EXCEPTIONRESPONSE

1Sub-machine’sAddress06

2FunctionCode83

3ExceptionCode02

4、5CRCParityHigh-bit,Low-bit

Mainmachinequeryandsub-machineexceptionresponse

正常响应时,从机以原来查询的功能编码应答,在例外情况响应是,从机将功能编码的MSB设为1。

Innormalresponse,sub-machinerespondswithoriginalqueryfunctioncode;inexceptionresponse,sub-machinesetsMSBoffunctioncodeto1.

 

代码

意义

01

从机收到的功能编码是不允许的

02

查询中的数据地址对于从机来说是非法的

03

查询中的数据域的数值不是从机所允许的

例外情况代码和意义

 

Code

Meaning

01

Thefunctioncodereceivedbysub-machineisunallowed.

02

Thedataaddressinqueryisnonlicetforsub-machine.

03

Thevalueofdataareainqueryisunallowedbysub-machine.

CodesandMeaningsofexceptioncases

 

4.生产CRC校验码的C语言程序:

ClanguageprocedureofformingCRCparitycode:

StaticndignedcharauchCRCHi[]=

{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,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,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,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,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,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

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

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1