Go Down

Topic: Why can I only send 28 holding registers over modbus? (Read 190 times) previous topic - next topic

Mickey_blu_eyes

Hi, following the tutorials, I'm using a TTL-to-RS485 converter and a RS485-to-USB converter with a 2m USB extension cable to send various sensor outputs over modbus to a receiving program on my PC. I'm using the enum method as here (please ignore the lhs channel numberings):
Code: [Select]

enum
{
  T1a,       //CHANNEL 3 //0
  T1b,       //CHANNEL 4 //1
  T2a,       //CHANNEL 5 //2
  T2b,       //CHANNEL 6 //3
  T3a,       //CHANNEL 7 //4
  T3b,       //CHANNEL 8 //5
  T4a,       //CHANNEL 9 //6
  T4b,       //CHANNEL 10 //7
  T5a,       //CHANNEL 11 //8
  T5b,       //CHANNEL 12 //9
  T6a,       //CHANNEL 13 //10
  T6b,       //CHANNEL 14 //11
  T7a,        //CHANNEL 15 //12
  T7b,        //CHANNEL 16 //13
  T8a,        //CHANNEL 17 //14
  T8b,        //CHANNEL 18 //15
  FP1a,        //CHANNEL 19 //16
  FP1b,        //CHANNEL 20 //17
  FP2a,        //CHANNEL 21 //18
  FP2b,        //CHANNEL 22 //19
  FP3a,        //CHANNEL 23 //20
  FP3b,        //CHANNEL 24 //21
  FP4a,        //CHANNEL 25 //22
  FP4b,        //CHANNEL 26 //23
  FP5a,        //CHANNEL 27 //24
  FP5b,        //CHANNEL 28 //25
  FP6a,        //CHANNEL 29 //26
  FP6b,        //CHANNEL 30 //27
  FP7a,        //CHANNEL 31 //28
  FP7b,        //CHANNEL 32 //29
  FP8a,        //CHANNEL 33 //30
  FP8b,        //CHANNEL 34 //31
  //Error1,     //CHANNEL 35 //32
  //Error2,     //CHANNEL 36 //33
  HOLDING_REGS_SIZE
};

unsigned int holdingRegs[HOLDING_REGS_SIZE];

Modbus slave(1, 0, TXEN); // this is slave @1 and RS-485

 slave.begin(115200);

 slave.poll( holdingRegs, HOLDING_REGS_SIZE );


But I can only seem to be able to send a maximum of 28 registers, can someone enlighten me please?

From looking at similar threads I thought it might be the USB RS485 converter's buffer wasn't big enough - but it uses a cp2104 chip and the datasheet says the buffer is 576 bytes, which is 10x larger than 28 registers right?

Cheers all

noiasca

Check if there are any limitations documented in the library you are using.
By the way ... which library you are using (please provide exact version and download - link).

DE: Wie man Fragen postet:
1. was hat man (Sketch und Hardware)
2. was SOLL es machen
3. was macht es: IST (Fehlverhalten, Fehlermeldungen, Serial.Output ...)
4. Eine Frage stellen bzw. erklären was man erwartet

Mickey_blu_eyes

Hi noiasca, I'm using the modbustru library by smarmengol. On line 147 it says the max buffer size is 64 bytes. Doesn't 64 bytes equate to 32 holding registers?

But anyway thanks, it must be this. I will try looking for a different library with a larger buffer.

Cheers

noiasca

... or as a workaround define two objects and split the registers...

Modbus slave(1, 0, TXEN);
Modbus slave2(1, 0, TXEN);

you know what I try to say?
DE: Wie man Fragen postet:
1. was hat man (Sketch und Hardware)
2. was SOLL es machen
3. was macht es: IST (Fehlverhalten, Fehlermeldungen, Serial.Output ...)
4. Eine Frage stellen bzw. erklären was man erwartet

pylon

The library you use has a buffer for the response message of size 64 bytes. That includes the data and the message header as well as the CRC.

Quote
But anyway thanks, it must be this. I will try looking for a different library with a larger buffer.
What about simply increasing the buffer size if you really need to transfer all values in one message.

Mickey_blu_eyes

Ah, thanks both. Didn't realise you could do either of these things...Will have a fiddle and get back to you, Cheers

pylon

Quote
... or as a workaround define two objects and split the registers...

Modbus slave(1, 0, TXEN);
Modbus slave2(1, 0, TXEN);

you know what I try to say?
That doesn't help. The size of the array supplied is not the problem but the buffer size of the result message.

Go Up