Modbus RTU slave : Problem of time consuming when multiple slave on same bus

365 views
Skip to first unread message

Mickael mk

unread,
Dec 5, 2020, 11:15:55 AM12/5/20
to libmodbus
Hi,

I'm using a arduino every ( ATMEGA4809) with library official from arduino, so i think this one ?

Modbus RTU 9600.
The arduino is the slave.

I had some issues of time consuming "ModbusRTUServer.poll();" method so i made a measure and had these results :

- when the master is not polling any devices on modbus : 0 to 2ms maximum => Fine for me
- when the master pool the arduino device : 36-37ms => fine for me
- when the master pool another address :
ms: 7
ms: 500
ms: 7
ms: 500
ms: 8
ms: 500
ms: 8
ms: 500

So here there is a problem because it block my program for half a second when the master interrogate another device.

Do i need to configure something for to solve this ?
Is the library capable of doing 1 master with several slaves ?

Thanks
Best regards

#include <ArduinoRS485.h>
// ArduinoModbus depends on the ArduinoRS485 library
#include <ArduinoModbus.h>

//  LED MODBUS
#define LEDMODBUS 7

//  MODBUS
#define MODBUS_ADDRESS 102
#define MODBUS_INPUTREG 11
#define MODBUS_BAUDRATE 9600




// Variables General
unsigned int cycle;




/**********************************************/
/********** Setup *****************************/
/**********************************************/
void setup(void) {


  byte i;

  //  LED Modbus
  pinMode(LEDMODBUS, OUTPUT);
  digitalWrite(LEDMODBUS, LOW);

  Serial.begin(115200);

  delay(500);

  digitalWrite(LEDMODBUS, HIGH);


  ModbusRTUServer.begin(MODBUS_ADDRESS, MODBUS_BAUDRATE);
  ModbusRTUServer.configureInputRegisters(0x00, MODBUS_INPUTREG);
}

/**********************************************/
/********** Main LOOP *************************/
/**********************************************/
void loop(void) {
  byte i;



  digitalWrite(LEDMODBUS, LOW);
  cycle = millis();

  // Pool for modbus requests
  ModbusRTUServer.poll();

  cycle = millis() - cycle ;
  if ( cycle > 2 )
  {
    Serial.print("ms: ");
    Serial.println(cycle);
  }


  digitalWrite(LEDMODBUS, HIGH);
}

Mickael mk

unread,
Dec 5, 2020, 11:21:41 AM12/5/20
to libmodbus
The master is a industrial automation system configured :


COM3|9600 Bauds|None|8 Data Bits|1 Stop Bit|RS485

and when sending this chain, it create a 500ms blocking in the arduino slave modbus:
  65|04|00|00|00|0B|B9|E9

Flavio Castro Alves Filho

unread,
Dec 16, 2020, 11:35:44 AM12/16/20
to libm...@googlegroups.com
Hello,

I don't think it is the same thing.

Best regards,

Flavio
> --
> Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
> Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
> Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/3c8529ab-d4f2-4332-89f7-215bce562449n%40googlegroups.com.



--
Flavio de Castro Alves Filho

flavio...@gmail.com
Twitter: http://twitter.com/#!/fraviofii
LinkedIn profile: www.linkedin.com/in/flaviocastroalves

Mickael mk

unread,
Dec 19, 2020, 10:02:38 AM12/19/20
to libmodbus
Hi Again,

I made another test with a regular arduino Mega , and found same problem.
This library has a problem.
I put an issue here :
Reply all
Reply to author
Forward
0 new messages