SoftwareSerial and RS485 RTU slave communication

I need to make some "simple" tool for collecting data from one of the controller. Communication is rs485 rtu. I tried to make reader with arduino nano and MAX485 module converter. Problem is that this task is not as simple as it seems...

I have no problems to connect two arduinos and send data between them - I have problems when Register address is like 7000, 8000 and communication with 485 is on SoftwareSerial on 19200 as I need to use Serial to communicate with PC (parsing data from 485 and send it to pc). My arduino is slave, always on address 7.

I guess that i need to know when write multiple registers function is called as there are messages about status of device..

Can you please point me to some good library or example that could do that? I will appreciate and take any help

Register address: 7000
Function: write multiple registers

typedef __packed struct{
uint8_t inf1= 1;
uint8_t inf2;
uint16_t inf3;
uint16_t inf4;
uint32_t inf5;

txRegistryDeviceState device_state;

} xQCReport_t;

typedef __packed struct
{
unsigned short bool1 :1,
bool2 :1,
bool3 :1,
bool4 :1,
bool5 :1,
bool6 :1,
bool7 :1,
bool8 :1;
}txRegistryDeviceState;

Register address: 8000
Function: read multiple registers
Data length: 4 registers (8Byt)

I started with:
Arduino Nano (https://store.arduino.cc/usa/arduino-nano)
max485 module (https://www.itead.cc/max485-module.html)

and library SimpleModbus NG from:

with example provided (same with wiring)

Communication is rs485 rtu.

I guess that means Modbus RTU. Can you acknowledge this?

My arduino is slave, always on address 7.

If the Arduino is slave which device is the master? Post a link to that device!

I have problems when Register address is like 7000, 8000 and communication with 485 is on SoftwareSerial on 19200 as I need to use Serial to communicate with PC (parsing data from 485 and send it to pc).

Why do you need the PC connection on a Modbus RTU slave device? Just for debugging?

with example provided

That probably won't work as it most probably don't match the expectation of your master device.

Please start be describing what exactly you're trying to achieve (not how you think you should achieve that). Should your Arduino emulate some other device? If so, please provide a link to that device that should be emulated.

What type of Arduino are you using?

You are right, it is MODBUS rtu.

Device that act as master is some custom device that I get.. it is not published anywhere. In every Modbus register is status of device relay for and i need to check if that is true - when i read from modbus that relay 3 should be open I have to check if that is true and sent over serial "relay 3 ok"..

Master is writing status all the time..

Device that act as master is some custom device that I get.. it is not published anywhere. In every Modbus register is status of device relay for and i need to check if that is true - when i tead from modbus that relay 3 should be open I have to check if that is true and sent over serial "relay 3 ok"..

That doesn't sound as if your device will be a slave. The slave doesn't get the status from the master. It's the master who is asking the slaves for their states.

Master is writing status all the time..

To where? That's not how Modbus is working.

Post the documentation you have for your Modbus device. Without documentation you won't get that thing running.

pylon:
To where? That's not how Modbus is working.

I understand that this is not standard behaviour of master device but in this case it is made like this.. in first 10 seconds device is writing registers to slave device on specified address. that is made just for test - later on it is searching for other type of devices.

pylon:
Post the documentation you have for your Modbus device. Without documentation you won't get that thing running.

function definition pasted in first post is all I got.. I can also record rs485 requests- there you see that it is really writing to address 7000 in first 10 seconds and after that it start to search for other slaves.

My problem is that I cannot see requests from master on my arduino..

communication with 485 is on SoftwareSerial on 19200 ...

19200is just too high for reliable software serial comms.

Watcher:
19200is just too high for reliable software serial comms.

maybe that is my problem then.. but i cannot change baudrate on device.
And somehow i need to send results to pc also.. any other idea?

with example provided (same with wiring)

That example doesn't react on address 7000. It's made for typical slave setups where you can define the address layout. With that library you cannot set the address range, it provides all information at the first few addresses (0-x). Most slave Modbus libraries for the Arduino handles it the same way. I remember one that allowed to each address explicitly but I cannot find the link at the moment.

And somehow i need to send results to pc also.. any other idea?

If you need that connection to be reliable buy a Mega2560 which has 4 hardware serial interfaces.

Mega2560 resolved the problem:)