Talkredius
I'm a beginner with Modbus and PLC programming and have a general question about reading Input registers

As far as I understand, OpenPLC is designed to read/write all registers, which are defined in the modbusdevice.cfg file.
The registers are read/written constantly in the background without any option of changing the start address or number of registers via an OpenPLC program

a) No gaps are allowed, e.g. I can't read 4 registers from start address 0000 and 6 registers from 0100 ?

b) All registers are read/written with a single query by the master ? (function code 3 / 4) ?

c) the max number of registers is 125 ? ( limited by the libmodus, got an error message with > 125 registers)

reason for asking is that the SMD630M-CT has 382 input registers and only 80 registers are allowed to be read by a single query.. I guess I can live with these restrictions, if not I may change the source code of modbus_master.cpp.

please confirm or correct me if I'm wrong.
Reply 0 0
thiagoralves
Your assumptions are correct. However, if your device is Modbus/TCP, you can just create another device on the Modbus device.cfg file with the same address and give it the remaining registers you want to read. It will be read by OpenPLC on another thread and should work properly
Reply 2 0
Talkredius
your suggestions might even work with Modbus RTU, which my device is. I tested it shortly with the smart meter SM63MCT, with an acceptable amount of connection errors.

For some reason I had to change my smart meter to a Schneider iEM3255 which is also Modbus RTU. And here cones my next problem, the iEM3255 comes only with holding registers which can be read with function code 3, your modbus_master.cpp allows only to write to this holding registers.

As a quick and dirty hack I''ll replace modbus_write_registers by modbus_read_registers that should ihmo do the trick.

Edit : It works, now I can read the holding registers.

In case you are considering an improvement I have  another idea.

Because ScadaBr doesn't work on my opensuse 42.1 I found pvbrowser http://pvbrowser.de/pvbrowser/index.php?lang=en&menu=1&left=1  which comes with a lot of daemons for many fieldbus systens, eg. Ethernet/IIP, Can etc. The daemon gathers all data from the fieldbus and writes it  to shared memory.
If OpenPLC could access this data in shared memory, that would be a great improvement.

And of course thanks for your support.
Reply 0 0
Reply