有一块温控仪表,用的是Modbus RTU协议,我用的是Visual Basic 6.0来开发通讯,仪表的地址设置是2,有一个参数的地址是1450(Hex),读功能码用3写功能码用6
现在我读这个参数最大只能读取显示到6553.5,即仪表上这个参数显示只要大于6553.5,用我的软件代码读取参数的结果就都是32768,仪表显示小于6553.5我的软件上都可以正常的读取显示
发送帧命令 02 03 14 50 00 01 81D8
接收帧命令02 03 02 8000 9D84(只要仪表该参数大于6553.5返回的数据就都是8000转成十进制就是32768)
第二个问题还是同一个参数的写入问题,从我的软件上修改这个参数最大不能超过3276.7这个数值,小于3276.7的任意数可以正常修改,比如我现在想把这个参数从我的软件上修改成4000,这个参数带一位小数点而小数点不传输,要把它修改成4000实际要发送数据是40000(Hex9C40),发现接收数据好像都不对
发送帧命令 02 06 14 50 9C 40 E4E8
接收帧命令 02 86 03 F2 61
通讯手册上有这么一段话,翻译过来也看的不是很明白,请问我的这两个问题和这段话有关么?
PARAMETER RESOLUTION
JBUS and MODBUS protocol limit data to 16 bits per parameter. This reduces the active range of parameters to 65536 counts. In instruments this is implemented as - 32767 (8001h) to +32767 (7FFFh).
The protocol is also limited to integer communication only. instruments allow the user to configure either Integer or full resolution. In integer mode all parameters will be rounded to the nearest integer value, whereas in full resolution mode the decimal point position will be implied so that 100.01 would be transmitted as 10001. From this, and the 16 bit resolution limitation, the maximum value communicable with 2 decimal place resolution is 327.67. The parameter resolution will be taken from the slave user interface, and the conversion factor must be known to both master and slave when the network is initiated.
VB用Modbus RTU协议和仪表通讯的问题
答案:2 悬赏:20
解决时间 2021-03-12 12:32
- 提问者网友:回憶丶初
- 2021-03-11 16:18
最佳答案
- 二级知识专家网友:伤口狠精致
- 2021-03-11 16:47
你发 02 03 14 50 00 01 81D8
你要读的数据是小数 怎么只读1位 要么2位(float)要么4位(double)
我认为你可能是数据类型不对 ,读的数据类型要和数据存入的数据类型一致
你照下面试试
读命令你发 02 03 14 50 00 02 xx xx
写入4000 你发 02 10 14 50 00 02 04 00 00 45 7A xx xx 写入小数怎么能用06? 06 只能写整数
你要读的数据是小数 怎么只读1位 要么2位(float)要么4位(double)
我认为你可能是数据类型不对 ,读的数据类型要和数据存入的数据类型一致
你照下面试试
读命令你发 02 03 14 50 00 02 xx xx
写入4000 你发 02 10 14 50 00 02 04 00 00 45 7A xx xx 写入小数怎么能用06? 06 只能写整数
全部回答
- 1楼网友:说多了都是废话
- 2021-03-11 17:58
这两个问题应该是同一个原因,integer类型不够大。
在vb6里,integer是有符号的,其取值范围是 -32767 到 32676。
试试看用 long 取代 integer 吧,应该能行。
再说说modbus,读取指令 02 03 14 50 00 01 指定了读取一个单位(16位)的数据。
如果数据超过了65536,一个16位就显示不过来了,试试读取两个字的数据吧。
当然,也有部分设备使用某个特定数组来表示溢出,查查说明书应该会有收获。
发送问题也是类似的,如果该地址数据是有符号的,那么上限就是32767。
试试写两个字(32位)的数据。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯