modbus默认寄存器类型
(2014-08-26 19:14:32)
标签:
股票 |
分类: 电子技术 |
最近在写modbus程序,记录要点:
1.易控程序中默认寄存器类型
00001 表示的是第一路数字量输出
10002 表示第二路数字量输入
30008 表示第八路模拟量输入
40018 表示第18路模拟量输出
2.
2.1.modbus_read_registers()方法读取float型字节数为2个字节;
2.2.modbus_read_registers()方法读取int型字节数为1个字节;
2.3.由于float占2个字节,从高位开始读所以获取正确的float值从addr位置开始对齐,int型和bit型从addr-1开始读
2.4.一次性读取float不能超过124位
3.
uint16_t temp_float_value;
temp_float_value =
modbus_get_float_dcba(&array_float_values[i]);
str = string("get_float : ") +
string(gcvt(temp_float_value,10,temp_buf));