• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
April 25, 2024, 05:34:25 pm

News:

SMF - Just Installed!


Modbus functionality

Started by Sandor Dobi, February 02, 2019, 08:57:43 pm

Previous topic - Next topic

Sandor Dobi

Hi,

I would like to implement a MODBUS Slave, and Master  in the same application (over TCP/IP)

I started to check the demo and find the following issues.
The modbus adressing standard is not forced, we can read/write coils, registers in any address.
https://en.wikipedia.org/wiki/Modbus
Quotecoil numbers span from 000001 to 065536,
    discrete input numbers span from 100001 to 165536,
    input register numbers span from 300001 to 365536,
    holding register numbers span from 400001 to 465536.


Is it means that we need to specify explicitly that the first coil is at 0 address but the first DI is at 100001 etc ?
Is there any need to lock the modbus slave register/coil list to refresh its contents while the slave is accepting remote connections and commands?

Best Regards



Roman Novgorodov

Hello

Possible I do not understand your doubts correctly.

My thoughts are following:
1) You can reply (in slave part of your app) on any request from master. If master requests DI 3 you can reply exception or correct value.
2) Usual the real modern devices do not use same number (address of value) for COIL and DI. The same statement is correct for input and holding registers.
3) Also please note that current TnrModbus RTU implementation uses 16-bit value for register or coil address that means address or coil number is in 0..65535 range.
4) You can lock a list value on start TCP session or do not do that and reply actual (live) value to master.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Sandor Dobi

Hi,

thank you for the fast reply.
So the components only processing raw 16 bit adresses. They don't do any register/coil/input number translating to the address. So if we need lets say DI #100001, then I need fetch 0. DI input. And only the Coil numbers overlaps (more or less) with the addresses (numbers start from 1 and addresses start from 0)

It would be nice some utility function for reading/writing by number thought because in the modbus world all technical docs operating with numbers and not addresses.

For slave device it is not good to lock the list at the start of the Session, because it can be that the master is polling the device, so it will be connected at the start of the application and disconnected days later, so the salve Tlist will be locked all the time.
It would b nice to change the implementation of the class from Tlist to some Locking aware one, and introduce 2 function, one for reading out the datas and one for updating them while the slave is active and accepting modbus actions from remote masters.

Best regards.