- 目录 -
1. 关于通信功能 ·········································································································································· 1
1.1 概述 ··················································································································································· 1
2. 规格 ························································································································································ 2
2.1 通信规格 ············································································································································ 2
3. 连接 ························································································································································ 3
3.1 跨接器的设定····································································································································· 3
3.2 端子配置(TM2)······························································································································ 3
3.3 连接 ··················································································································································· 4
4. 通信条件设定 ·········································································································································· 6
4.1 设定项目 ············································································································································ 6
4.2 设定操作 ············································································································································ 6
5. MODBUS通信协议 ·································································································································· 7
5.1 概述 ··················································································································································· 7
5.2 信息的结构········································································································································· 8
5.3 从机的应答········································································································································· 9
5.4 功能代码 ·········································································································································· 10
5.5 错误校验代码(CRC-16)的计算 ·····································································································11
5.6 传送控制步骤··································································································································· 13
6. 信息的详细内容····································································································································· 15
6.1 读取字数据[功能代码:03H] ········································································································ 15
6.2 读取只读字数据[功能代码:04H]································································································· 16
6.3 写入字(1 个字)数据[功能代码:06H]······················································································· 17
6.4 写入连续字数据[功能代码:10H]································································································· 18
7. 地址映射表和数据格式·························································································································· 19
7.1 数据格式 ·········································································································································· 19
7.1.1 传输数据格式····························································································································· 19
7.1.2 小数点位置及测量单位的设定方法····························································································· 19
7.1.3 测量数据超过范围时的操作········································································································ 19
7.2 地址映射表······································································································································· 20
-i-
1.1 概述
• 本装置具有通过 RS-232C 及 RS-485 接口进行通信的功能,能够与上位计算机等进行双向数据传
输。
• 通信系统由主机和从机构成。
使用 RS-485 接口时,1 台主机(上位计算机、可编程控制器、图示面板等)最多可以连接 31 台
从机(本装置)。
使用 RS-232C 接口时,1 台主机只可以连接 1 台从机(本装置)。
• 由于每次可以通信的从机仅限 1 台,所以主机要通过设定至各从机的“站号”确定通信对象。
• 为了主机和从机之间进行通信,接收、发送数据的格式必须相同。本装置根据 MODBUS 通信协
议确定了通信数据的格式。
1. 关于通信功能
-1-
2.1 通信规格
① RS-232C 接口
项目 规格
电气规格 符合 EIA RS-232C 标准
通信方式 2线式 半双工
同步方式 起止式同步
连接状态 1:1
最多连接装置数 1台
传输速率
数据格式
传输代码 HEX 值(MODBUS RTU 模式)
错误校验
隔离 通信部位与其它部位为非隔离
② RS-485 接口
2. 规格
38400 bps
数据长度 8位
停止位 1位
奇偶校验 无
X 流程控制 无
CRC-16
项目 规格
电气规格 符合 EIA RS-485 标准
通信方式 2线式 半双工
同步方式 起止式同步
连接状态 1:N
最多连接装置数 31 台
通信距离 最长 500m(最长)
通信速率
数据格式
传输代码 HEX 值(MODBUS RTU 模式)
错误校验
隔离 与内部回路为隔离
38400 bps
数据长度 8位
停止位 1位
奇偶校验 无
X 流程控制 无
CRC-16
信号线与接地之间为功能隔离
-2-
ࡻ
为了防止触电及故障,在所有配线连接完成之前,请勿通电。
3.1 跨接器的设定
按照通信类型,请切换跨接器。
3. 连接
通信类型
RS232C
RS485
JP1 JP2 JP5
3-5
4-6
1-3
2-4
3-5
4-6
1-3
2-4
3.2 端子配置(TM2)
① RS-232C 接口
端子号 信号名称 引脚连接图
1
2
3
② RS-485 接口
端子号 信号名称 引脚连接图
1 RTxD+
2 RTxD–
3
Transmit Data (TXD)
Recive Data (RXD)
信号接地
信号接地
2-3
1-2
123
123
-3-
3.3 连接
① RS-232C 接口
᎐
ൺב༺ღ
۰˄ZKM˅
RXD
TXD
TXD
RXD
SG SG
FG
② RS-485 接口
• 请使用屏蔽双绞线连接。
(我们推荐的电线为:KPEV-SB(古河电工制造))
• 电缆最大长度为 500m。在 1 线路上可以连接 1 台主机和最多 31 台从机(本装置)。
• 请将终端电阻 100Ω(1/2W 以上)接在线路两端。
• 请将屏蔽线在靠主机的一点接地。
፮ޤݢᏟ
᎐
+
100Ω˄1/2W˅
ൺב༺ღ
۰˄ZKM˅
RTxD+
-
RTxD
-
SG
+
-
+
፮ޤݢᏟ
100Ω˄1/2W˅
-
• 并不一定要连接 SG,但是连接 SG 可以减少因噪声引起的通信错误。
-4-
• 在对本装置施加的噪声等级超过 500V 的环境下使用本装置时,我们建议您在靠主机的线路上
使用噪声过滤器(如下图)。
[噪声过滤器](推荐产品):ZRAC2203-11(TDK 制造)
᎐
ወ໌ࣰఌධ
RS-485
ׁᎧ
• 通信期间如果 EMC 发生问题,请在通信电缆上装上铁氧体芯,用来降噪。
铁氧体芯(推荐产品): ZCAT 系列(TDK 制造)
MSFC 系列(森宫电机制造)
-5-
4. 通信条件设定
为了主机与本装置之间能够正常通信,需要进行下列设定:
• 主机与本装置的所有通信条件应设定为同一条件。
• 连接在同一线路上的所有本装置需设定各不相同的“站号”。(请确保没有相同站号的装置)
4.1 设定项目
下表为设定项目。请通过正面的操作键进行设定。
项目 出厂值 设定范围 备注
通信速度
数据长度 8位 固定(不能变更)
停止位 1位 固定(不能变更)
奇偶校验设定 无 固定(不能变更)
站号
4.2 设定操作
请在参数设定画面上进行站号设定。(参见使用说明书)
38400bps
1
固定(不能变更)
0~31
(0:停止通信功能)
请将主机及所有站号的
从机设定为同一条件。
请对各从机设定各不相
同的站号。
-6-
5.1 概述
基于 MODBUS 通信协议的通信系统,通常采用“从主机开始通信,从机分别应答”的形式。
传输的顺序如下:
1)主机向从机发送指令信息。
2)子机确认接收的信息中的站号是否与本站的站号相同。
3)如果一致,则执行指令,并返回应答信息。
4)如果不一致,则丢弃接收的指令信息,等待下一个指令信息。
(a) 指令信息中的的站号与本站的站号相同时,
主机 → 从机
主机 ← 从机
(b) 指令信息中的站号与本站的站号不同时,
主机 → 从机
主机 ← 从机
主机通过在指令信息中指定从机的某一个站号,可以与连接在同一线路上的多台从机分别进行通
5. MODBUS 通信协议
指令信息
应答信息
指令信息
(无应答)
通信线上的数据
通信线上的数据
信。
-7-
5.2 信息的结构
指令信息及应答信息由站号、功能代码、数据区以及错误校验代码 4 个部分构成,并按此顺序发
送。
下面就是各部分的介绍:
(1) 站号
站号(1 字节)
功能代码(1 字节)
数据区(2~133 字节)
错误校验代码(CRC-16)(2 字节)
图 5-1 信息的结构
这是从机的指定编号。仅可由在分析仪参数设定画面上设定为相同“站号”的从机来执行指令。
(2) 功能代码
这是让从机执行的功能的代码。
详细内容请参见
(3) 数据区
这是执行功能代码所需的数据。数据的结构根据功能代码而不同。详细内容请参见第 6 章。
线圈号和寄存器号配置到本装置内部的各个数据。请指定线圈号和寄存器号来执行该数据的通
信。
相对地址 =
例如,由某功能代码指定的寄存器号为 40003 时,
相对地址 = (40003 的低 4 位)- 1
在信息上使用此地址。
(4) 错误校验代码
5.4 节。
⎛
⎜
⎝
= 0002
线圈号 或 寄存器号
的低4位
⎞
-1
⎟
⎠
这是检测信号传输过程中出现的信息错误(位的变化)所需的代码。
MODBUS 通信协议(RTU 模式)使用 CRC-16(Cycric Redundancy Cheek:循环冗余校验)。
CRC计算方法请参见
5.5 节。
-8-
5.3 从机的应答
(1) 正常时的应答
从机生成与各信息对应的应答信息,并回复。此时的信息结构与 5.2 节所解释的相同。
数据区的内容根据功能代码而不同。详细内容请参见第 6 章。
(2) 异常时的应答
指令信息的内容中出现传输错误之外的差错(指定了不存在的功能代码等)时,从机不执行此指
令,并生成错误应答信息。
错误代码 内容 说明
01H
02H
03H
(3) 无应答
错误应答信息的结构如
错误代码如
表 5-1 所示。
功能代码出错
线圈、寄存器的地址出错
线圈、寄存器的个数错误
图 5-2 所示,功能代码为指令信息的功能代码加上 80H的数值。
站号(1 字节)
功能代码 + 80H(1 字节)
错误代码(1 字节)
错误校验代码(CRC-16)(2 字节)
图 5-2 错误应答信息
表 5-1 错误代码
指定了不存在的功能代码。
请确认功能代码。
指定了该功能代码无法使用的线圈号、寄存
器的相对地址。
由于指定的个数过多,指定了不存在的线圈
号、寄存器号。
从机在下列情况下,从机不执行指令信息,也不做应答。
• 指令信息中指定的站号与给从机设定的站号不一致时
• 错误校验代码不一致时,或检测出传输错误(奇偶校验错误等)时。
• 结构信息的数据间隔(空白状态)超过 24 位时间时。(请参见
-9-
5.6 传送控制步骤)