Master Data access using Nmodbus

M

Thread Starter

Manish

Hi,

We are developing a SCADA in C#, where we need to access data from Modbus TCP slaves. We are planning to use nmodbus library for this purpose.
I have 2 questions:

1. Has anybody used nmodbus for production ready software. If you know some product which is been developed using nmodbus?

2. As per my understanding master implementation in nmodbus is blocking while reading some data from slaves, Can somebody suggest how we can access the data in more efficient way.
 
L

Lynn August Linse

I have *NOT* used nmodbus, however all of my 'master' or 'bridge' code uses 1 thread (or task) per remote, and while they do not 'block', they do wait & timeout for a single request at a time.

So if you have 20 remotes, use 20 threads and 20 sockets (I assume nmodbus is re-entrant). So use queues or another means for your 1 'main-task' to issue orders to the subtasks, which should either return a response or a timeout.

A modern SCADA/PC-class computer has no problem running dozens or even hundreds of light-weight tasks. Our 'small' Cold-fire or ARM embedded systems support up to 128 tasks without complaint.
 
Hello,

> So if you have 20 remotes, use 20 threads and 20 sockets...

Be advised, on gateways i.e. TCP to 485, where you are using the slave ID to communicate with the slaves, opening twenty concurrent connections (sockets) to the gateway might not be permitted.

Good luck,

Mark
http://www.peakhmi.com/
 
L

Lynn August Linse

> Are you using libmodbus or your own implementation of Modbus

It is our own proprietary library based on 'thread-X' and 'streams'. Nothing I can share.

Mark's comment applies to commercial 'Modbus/TCP to Modbus/RTU bridges', as common limits are 4, 8, 10 or 12 concurrent sockets. However, in Digi products, we allow/limit it to 32 or 64 sockets (depends on memory size of base product) just to prevent Modbus from consuming all resources.

Since Manish is doing PC programming, concern about 20 sockets not be allowed are moot - a PC can handle an awful lot of concurrent sockets :)
 
Hello,

Sorry to disagree, my advisement is not 'moot' and it does not apply only to TCP to RTU devices. I used that as an example.

The OP only states he will be on a PC for his software. What about the other side?

We have run into devices that only allow 4 concurrent connections. When the fifth connection is attempted the device closes the first connection and accepts the new connection request.

Good luck,
Mark
http://www.peakhmi.com/
 
Top