Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadHoldingRegisters takes 2seconds #182

Open
JODLatGit opened this issue Dec 8, 2022 · 3 comments
Open

ReadHoldingRegisters takes 2seconds #182

JODLatGit opened this issue Dec 8, 2022 · 3 comments

Comments

@JODLatGit
Copy link

JODLatGit commented Dec 8, 2022

I am using a Seneca Z-8NTC to readout NTC's resistors.
I have seen that underneath commands:

// Read 16 registers starting at 74)
waitPeriod = millis();
result = Modbus1.readHoldingRegisters(74, 16);
waitPeriod1 = millis();
if (result == Modbus1.ku8MBSuccess)
  {
  NTC2 = Convert4bytesToFloat(2);  (In the function I use getResponseBuffer)
  NTC4 = Convert4bytesToFloat(6);
  NTC6 = Convert4bytesToFloat(10);
  }

The command readHoldingRegisters takes up 2 seconds ?
It of course slows down the response time of my Controllino application .

The serial settings are :

// Init RS485
Controllino_RS485Init(19200);
//NTC module
Modbus1.begin(2, Serial3 );

Do I something wrong ?
What can I do to let it response faster ?
It is always almost exactly 2 seconds measured with the millis() function.

ModbusMaster version

[Version : 2.0.1]

Arduino IDE version

[Version : 1.8.19]

Arduino Hardware

[Controllino Max]

@JODLatGit
Copy link
Author

Did another test instead of reading 16 registers I read only 2 but the execution time stays the same 2 sec .
It seems that readHoldingRegisters cmd takes up 2 seconds ??

@JODLatGit
Copy link
Author

Another test learns me that apparently changing underneath the value from 2000 to 50 in the header file the readHoldingRegisters command response in 50ms instead of the 2000 !!??
// Modbus timeout [milliseconds]
static const uint16_t ku16MBResponseTimeout = 50; ///< Modbus timeout [milliseconds]
Seems that the readHoldingRegisters command isn't working properly !!! Took almost 1 day to solve it.

@rob040
Copy link

rob040 commented Feb 22, 2023

Another test learns me that apparently changing underneath the value from 2000 to 50 in the header file the readHoldingRegisters command response in 50ms instead of the 2000 !!?? // Modbus timeout [milliseconds] static const uint16_t ku16MBResponseTimeout = 50; ///< Modbus timeout [milliseconds] Seems that the readHoldingRegisters command isn't working properly !!! Took almost 1 day to solve it.

That is not a solution, but a workaround.
Still, if your implementation is hit by the timeout, be it 2 or 0.05 seconds, then there is something wrong with your communication or modbus slave.
please check the return value of readHoldingRegisters (). It should be 0 on success, but will be ku8MBResponseTimedOut (0xE2) in case of timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants