广州大彩串口屏论坛_大彩开发者交流论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 459|回复: 4

Modbus RTU Communication Issue — Sending Random Float Data from Arduino Opt...

[复制链接]

3

主题

6

帖子

33

积分

新手上路

Rank: 1

积分
33
发表于 2025-10-27 14:39:37 | 显示全部楼层 |阅读模式
I’m working on a Modbus RTU communication setup between an Arduino Opta (as Master) and a Dacai HMI (as Slave) using RS-485.
My goal is to send random float data from the Opta to be displayed on the HMI screen.

Below i attached arduino Opta (Master) Code
  1. #include <ArduinoRS485.h>
  2. #include <ModbusMaster.h>

  3. constexpr uint32_t BAUDRATE = 9600;
  4. constexpr uint8_t HMI_SLAVE_ID = 1;
  5. constexpr uint16_t HMI_REG_ADDR = 0x9C41;  // Dacai HMI register address

  6. ModbusMaster node;

  7. void setup() {
  8.   Serial.begin(115200);
  9.   RS485.begin(BAUDRATE);
  10.   node.begin(HMI_SLAVE_ID, RS485);
  11.   Serial.println("Modbus RTU Master started...");
  12. }

  13. void loop() {
  14.   float randomFloat = random(0, 10000) / 100.0;  // Random 0.00–100.00

  15.   union { float f; uint16_t words[2]; } floatData;
  16.   floatData.f = randomFloat;

  17.   node.setTransmitBuffer(0, floatData.words[0]);
  18.   node.setTransmitBuffer(1, floatData.words[1]);

  19.   uint8_t result = node.writeMultipleRegisters(HMI_REG_ADDR, 2);

  20.   if (result == node.ku8MBSuccess)
  21.     Serial.println(randomFloat);
  22.   else {
  23.     Serial.print("Modbus Error: 0x");
  24.     Serial.println(result, HEX);
  25.   }

  26.   delay(2000);
  27. }
复制代码


Also i have attached photo of Slave Configuration

The Opta is continuously reporting the following error:

Modbus Error: 0xE2


Can Anyone Help me to solve this ?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

0

主题

851

帖子

2498

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2498
发表于 2025-10-27 15:13:39 | 显示全部楼层
监测指令 如果不能正常显示浮点数,修改下byte order字节顺序
回复

使用道具 举报

3

主题

6

帖子

33

积分

新手上路

Rank: 1

积分
33
 楼主| 发表于 2025-10-27 15:48:45 | 显示全部楼层
dctechnology 发表于 2025-10-27 15:13
监测指令 如果不能正常显示浮点数,修改下byte order字节顺序

I tried this too. This resulting the same result. There is no Modbus communication between Arduino Opta(Master) and HMI (slave)..Can u help me to solve this issue?
回复

使用道具 举报

0

主题

851

帖子

2498

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2498
发表于 2025-10-27 17:10:54 | 显示全部楼层
监测指令信息发我看看  

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

3

主题

6

帖子

33

积分

新手上路

Rank: 1

积分
33
 楼主| 发表于 2025-11-9 17:59:18 | 显示全部楼层
本帖最后由 Dhinakaran 于 2025-11-9 18:04 编辑
dctechnology posted on 2025-10-27 17:10:
Send me the monitoring command information.

Sorry for the delay. I've attached the screenshot of the monitoring command for your reference.



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|广州大彩串口屏论坛_大彩开发者交流论坛

GMT+8, 2025-12-3 21:56 , Processed in 0.056249 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表