epsilonrt / modbus-arduino

A library that allows your Arduino to communicate via Modbus protocol, acting as a slave. Application layer library (OSI 7), used by all implementations over serial line and TCP/IP.
https://epsilonrt.github.io/modbus-arduino/
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Read Ists issue #1

Closed kscccc closed 1 year ago

kscccc commented 1 year ago

It should return 0D 02 02 FF FF but coil 8 looks wrong? image

epsilonrt commented 1 year ago

what is the platform ? and the version of modbus-arduino and modbus-serial ?

epsilonrt commented 1 year ago
#include <Arduino.h>
#include <ModbusSerial.h>

ModbusSerial mb (Serial, 10);

const uint8_t NbOfIsts = 24;
const uint16_t FirstIsts = 197;
const uint32_t IstsValues = 0xB5DBAC;

void setup() {

  Serial.begin (38400);
  mb.config (38400);

  for (uint8_t i = 0; i < NbOfIsts; i++) {

    mb.addIsts (FirstIsts -1 + i, (IstsValues & (1 << i)) != 0);
  }
}

void loop() {

  mb.task();
}

Reading test with mbpoll :

C:\Users\pasca>mbpoll -a10 -b38400 -t1 -r197 -c24 -1 -v com6
mbpoll 0.1-19 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2015 Pascal JEAN aka epsilonRT
All rights reserved.
This software is governed by the CeCILL license <http://www.cecill.info>

Opening com6 at 38400 bauds (E, 8, 1)
Protocol configuration: Modbus RTU
Slave configuration...: address = [10]
                        start reference = 197, count = 24
Communication.........: com6, 38400-8E1
                        t/o 1.00 s, poll rate 1000 ms
Data type.............: discrete input

-- Polling slave 10...
[0A][02][00][C4][00][18][38][86]
Waiting for a confirmation...
<0A><02><03><2C><DB><B5><23><BB>
[197]:  0
[198]:  0
[199]:  1
[200]:  1
[201]:  0
[202]:  1
[203]:  0
[204]:  0
[205]:  1
[206]:  1
[207]:  0
[208]:  1
[209]:  1
[210]:  0
[211]:  1
[212]:  1
[213]:  1
[214]:  0
[215]:  1
[216]:  0
[217]:  1
[218]:  1
[219]:  0
[220]:  1

The bug is confirmed, investigations in progress.

kscccc commented 1 year ago

what is the platform ? and the version of modbus-arduino and modbus-serial ?

Arduino 1.8.15 Arduino AVR Boards 1.8.6 Arduino Mega2560 modbus-arduino 1.1.1 modbus-serial 2.0.4

Attach my test code

epsilonrt commented 1 year ago

THANKS. Could you update modbus-arduino to version 1.1.1 and verify that your problem is gone ? https://github.com/epsilonrt/modbus-arduino/archive/refs/tags/v1.1.1.zip

kscccc commented 1 year ago

THANKS. Could you update modbus-arduino to version 1.1.1 and verify that your problem is gone ? https://github.com/epsilonrt/modbus-arduino/archive/refs/tags/v1.1.1.zip

Tested version 1.1.1 and verify. It work normal now. Thanks