node-modbus-serial icon indicating copy to clipboard operation
node-modbus-serial copied to clipboard

[question] How to scan a modbus network

Open robertsLando opened this issue 5 years ago • 2 comments

Hi @yaacov , firstly thanks again for this awesome module :)

I'm looking for a way to scan available unitsIds in a modbus network, I was thinking about simply try to read for example the holding register 1/0 and if the function returns I can say there is an available device matching that unitid, but I wonder if there is a better way to implement this.

Any suggestions?

robertsLando avatar Oct 02 '20 09:10 robertsLando

Hi, thank you for the question.

Any suggestions?

As you suggested, pooling a ** known register you know exist in all your devices ** sound a good option.

p.s. When implementing you should think of the affect such a poll cycle will have on other readings, on a serial line, pooling all addresses may take some time.

p.p.s. IMHO it depends on the devices you have, some devices may have a status register that is specifically designed so you can poll it at known intervals and keep a table of connected devices and their status. some devices don't like to be pooled and may cause delays and noise if pooled to many times or try to contact bad addresses.

yaacov avatar Oct 03 '20 10:10 yaacov

I heard about a function code 17 that may be used for such purposes but not all devices support it, like the FC 43, unfortunately. Anyway from my modbus experience Usually register 0/1 are used for versioning the hw or the firmware of the device so I think that’s actually the best option. Maybe also requesting a coil could be a little bit faster but not every device support it.


Daniel

On 3 Oct 2020, at 12:27, Yaacov Zamir [email protected] wrote:

 Hi, thank you for the question.

Any suggestions?

As you suggested, pooling a ** known register you know exist in all your devices ** sound a good option.

p.s. When implementing you should think of the affect such a poll cycle will have on other readings, on a serial line, pooling all addresses may take some time.

p.p.s. IMHO it depends on the devices you have, some devices may have a status register that is specifically designed so you can poll it at known intervals and keep a table of connected devices and their status. some devices don't like to be pooled and may cause delays and noise if pooled to many times or try to contact bad addresses.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

robertsLando avatar Oct 03 '20 10:10 robertsLando