21

Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like I do out there.

Open to any other materials that might have been a help to you as well...

GEOCHET
  • 21,119
  • 15
  • 74
  • 98

5 Answers5

22

I have done a lot of communication with devices for the past few years, since I work for a home automation company, but we don't use Modbus. We do communication in a standard and open way using Web Services for Devices(WSD) which is also know as Devices Profile for Web Services(DPWS).

During this time at one point, I did hear of a project called NModbus. It is an open source library for working with modbus. I have not used it, but looking at the site and the changesets on Google Code, it looks pretty active. You may want to give it a look and even get involved in. This is the only library that I have heard of that targets .Net.

earlNameless
  • 2,878
  • 20
  • 25
Dale Ragan
  • 18,202
  • 3
  • 54
  • 70
  • Yeah, I saw nmodbus and it looked ok, but last time I tried it it was a bit rough around the edges. I will give it a try. Really, I am now interested in reading up on WSD. Thanks for the link! – GEOCHET Sep 10 '08 at 18:12
  • Sure thing. WSD is really the way to go. Modbus is a very old protocol, I know you may not have a choice, but devices of today are starting to target WSD. – Dale Ragan Sep 10 '08 at 18:18
  • 1
    Thumbs up for NModbus: works really well – castle1971 Sep 10 '09 at 14:11
6

AdvancedHMI has a drivers package included that's just great for almost anything comms, though it may be a bit heavy if all you want is Modbus. AdvancedHMI is also under active development and has a strong user base. http://sourceforge.net/projects/advancedhmi/

NModbus seems to be the most likely to have continued development and there are lots of example projects scattered over the internet. https://code.google.com/p/nmodbus/

I have liked using this one in the past (Modbus via TCP): http://www.codeproject.com/Tips/16260/Modbus-TCP-class

Modbus to a Siemens Logo PLC is a little different. I have an example project I could send upon request.

VoteCoffee
  • 4,692
  • 1
  • 41
  • 44
5

Modbus is a very simple protocol to implement. All information you need can easily be found for free on the Internet.

If you choose to implement it yourself, I will be happy to answer any questions you have along the way.

If you choose to go for a modbus master library I would look for:

  • Modbus TCP support.
  • Modbus RTU over TCP/UDP and COM-port.
  • Configurable byte swapping, word swapping
  • Configurable "base" address so you can choose address 1 to actually be address 0 (sounds stupid, but I prefer to always specify addresses the same way they are documented)
  • it must support reading several addresses as a block, but it need to be flexible, some modbus slaves will return error if any address in the block is unused/reserved).
GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Martin Liesén
  • 1,308
  • 11
  • 14
1

FieldTalk Modbus Library - handles all Modbus functions

CSharpDev
  • 869
  • 1
  • 13
  • 22
-1

Have a look at the offering from Colway Solutions http://www.colwaysolutions.com. They have a unique licensing scheme where you pay for each Modbus function code that you desire to use. Its not free but the pricing seems to be low. I also saw a few ports of the library to some popular microcontrollers and RTOS.

Ganesh
  • 9