Go Down

Topic: Regarding Modbus RTU with solar Inverters (Read 587 times) previous topic - next topic

adwsystems

I asked the same to the Inverter technician. He said its not needed to be connected for the communication and just A & B are enough. A' and B' are inverting output & input. Whereas A and B are non inverting output and input.
I'm not confident in that answer. There is no concept of "inverting" in RS-485.

I'm not switching the serial yet. How should I switch them?
You can only plug in the PC or the modbus. You will have to disconnect one to use the other.

Prasannaa

You can only plug in the PC or the modbus. You will have to disconnect one to use the other.
Is it possible to use it with Mega? Because it has extra UARTs right.

adwsystems

Is it possible to use it with Mega? Because it has extra UARTs right.
BINGO! Then configure your constructor to use Serial1 and the corresponding pins.

Prasannaa

BINGO! Then configure your constructor to use Serial1 and the corresponding pins.
Thanks so much. I'll make the changes and update you with the result.

I have another doubt. Is it possible to use this library with Particle series of IoT baords?

Juraj

@pylon, it could be that the inverter has two modbus rtu interfaces. one where it is master (for BMS and/or Smart Meter) and one where it is slave. on my Fronius Symo I can't use Modbus RTU to request data because the inverter is master for BMS and Smart Meters. only Modbus TCP is available to request data.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Prasannaa

@pylon, it could be that the inverter has two modbus rtu interfaces. one where it is master (for BMS and/or Smart Meter) and one where it is slave. on my Fronius Symo I can't use Modbus RTU to request data because the inverter is master for BMS and Smart Meters. only Modbus TCP is available to request data.
@Juraj, Hi, This inverter also has TCP in it. The company has said that its possible to use  RTU and TCP. Which one would be the best?

Juraj

@Juraj, Hi, This inverter also has TCP in it. The company has said that its possible to use  RTU and TCP. Which one would be the best?
I planed to use RTU (20 m cable) to not flood my home TCP network with realtime requests. I started with WiFi, so TCP. Then I discovered I can't use RTU, but cable is better, so now I use Ethernet (over power line). I make 4 request every 4 seconds. I started with shorter interval, but the values didn't change so fast. So it doesn't flood my home network.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Prasannaa

I planed to use RTU (20 m cable) to not flood my home TCP network with realtime requests. I started with WiFi, so TCP. Then I discovered I can't use RTU, but cable is better, so now I use Ethernet (over power line). I make 4 request every 4 seconds. I started with shorter interval, but the values didn't change so fast. So it doesn't flood my home network.
Sounds great.
Can you please help me by sharing the code for reference.

Juraj

Sounds great.
Can you please help me by sharing the code for reference.
https://github.com/jandrassy/Regulator
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Prasannaa

https://github.com/jandrassy/Regulator
Thank you so much. Should I use the modbus.ino file?

Juraj

Thank you so much. Should I use the modbus.ino file?
most of Modbus.ino is for SunSpec Modbus registers and for integration with my project. only the modbusRequest and modbusWriteSingle functions are generic.

depending on how you plan to use the data retrieved from the inverter, some parts of my project could be useful for you, but only if you understand them, to which the best way is try it to code yourself and the compare with my code.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Prasannaa

BINGO! Then configure your constructor to use Serial1 and the corresponding pins.
Hi,
       I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.


Code:

Quote
#include <ModbusRtu.h>

// data array for modbus network sharing
uint16_t au16data[16];
uint8_t u8state;

/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  u8serno : serial port (use 0 for Serial)
 *  u8txenpin : 0 for RS-232 and USB-FTDI
 *               or any pin number > 1 for RS-485
 */
Modbus master(0,1,2); // this is master and RS-232 or USB-FTDI

/**
 * This is an structe which contains a query to an slave device
 */
modbus_t telegram;

unsigned long u32wait;

void setup() {
  master.begin( 19200 ); // baud-rate at 19200
  master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
  u32wait = millis() + 1000;
  u8state = 0;
}

void loop() {
  switch( u8state ) {
  case 0:
    if (millis() > u32wait) u8state++; // wait state
    break;
  case 1:
    telegram.u8id = 1; // slave address
    telegram.u8fct = 3; // function code (this one is registers read)
    telegram.u16RegAdd = 3841; // start address in slave
    telegram.u16CoilsNo = 1; // number of elements (coils or registers) to read
    telegram.au16reg = au16data; // pointer to a memory array in the Arduino

    master.query( telegram ); // send query (only once)
    u8state++;
    break;
  case 2:
    master.poll(); // check incoming messages
    if (master.getState() == COM_IDLE) {
      u8state = 0;
      u32wait = millis() + 100;
    }
    break;
  }
}

adwsystems

Hi,
       I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.

You didn't receive any data while the MEGA was connected to the PC and the MODBUS both using the same serial connection (Serial)? I would try moving to the Modbus to use Serial1 while the PC is connected.

Prasannaa

You didn't receive any data while the MEGA was connected to the PC and the MODBUS both using the same serial connection (Serial)? I would try moving to the Modbus to use Serial1 while the PC is connected.
Yeah. I used Serial1.

pylon

Quote
I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.
Sure, you don't send anything to Serial. Modbus is handled on Serial1 but any result is just kept in the sketch, nothing is reported to Serial.

Go Up