Novice Using Modbus, Question's

  • Thread starter Fred Intiso - Intern
  • Start date
F

Thread Starter

Fred Intiso - Intern

My project as an intern is to communicate with the Opto22 and Beckhoff 9000 with the modbus protocol. I'm not 100% familiar with "protocols" in general but i have done a sample client/server app's in C which just send messages via a char array to two different Xterm's on a UNIX box (in my data com class at college).

So my question really is how do I get started, I understand the jargin of packets and headers Etc. But via the protocol we are just sending strings via char arrays? If anyone could point my in the right direction or has a sample app or code that I could use to communicate with this via an I/O operation (Vusual basic or C).

Thanks, email @ [email protected]

P.S. This will lend itself to an incapsulated I/O Library that we use and will be developed using C#.
 
L

Lewis Bodden

Most people who develop code for MODBUS do it to earn money. So you will not find any code for free. So I don’t think you are going to get a sample. Let me ask you, if you develop some code would you post it as a sample here? Would your boss or the management of your company permit you to post it?

What you will get is advice. Remember that you get what you pay for. With that said, I will give you some free advice.

MODBUS and client/server app's are a world apart. Of course there are similarities. MODBUS communicates via a serial port. You should study up on serial communications and how UARTs work. Don’t get too detailed in it. Just a good background will do. Get a good communications analyzer. Another PC with the right software can work fine. If you have access to a working system, connect the analyzer and study the communications. Get a feel for the timing.

[email protected]
 
F

Fred Intiso - Intern

No need to flame and have an underlying tone. I'm totally new with this and wanted to send out "feelers". That's why I said, "Sample" not a robust application, I wanted to learn how to do this, not have someone do it for me - Don't we learn by example, anyways no need to rant.

With that said, if MODBUS communicates with the TCP Protocol stack (I believe at the application level) how can socket programming (i.e. sending and receiving) not be a major part of it, correct me if im wrong. I'm going to read some more documentation that I just printed, thanks for replying, hopefully I'll have more questions.

Thanks
 
C

Chiron Consulting

Lewis Bodden wrote:
>Most people who develop code for MODBUS do it to earn money. So you will not find any code for free. So I don't think you are going to get a sample.<

Sure you can. This question gets asked on this list every few weeks, most recently on May 22:

"http://www.control.com/1026149685/index_html":http://www.control.com/1026149685/index_html

For now, the answer looks like this:

* The MAT/PLC project has Modbus master source in 'C' at http://mat.sf.net

* There are two Sourceforge projects with Java implementations of Modbus:

"http://jmodbus.sourceforge.net/":http://jmodbus.sourceforge.net/
"http://jamod.sourceforge.net/":http://jamod.sourceforge.net/

* There is a sample 'C' program at:
"http://www.pmcrae.freeserve.co.uk/linuxmbus.ZIP":http://www.pmcrae.freeserve.co.uk/linuxmbus.ZIP that issues a ModbusRTU "read holding registers" query and prints the response.

* There's a Windows C++ implementation, with source code, at
"http://members.tripod.com/~mbserver/":http://members.tripod.com/~mbserver/

* The Modbus.org site used to include code samples with the protocol docs, but I don't see them (yet) at the recently reorganized site.

> Let me ask you, if you develop some code would you post it as a sample here? Would your boss or the management of your company permit you to post it?<

For many of us, the answer is 'yes'. Discussion of this and related questions can be found by searching the web for references to Open
Source. Perhaps the easiest place to start is with Eric Raymond's treatise "The Cathedral and the Bazaar" (online at
"http://www.tuxedo.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/":http://www.tuxedo.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/ ).

Regards,

Greg Goodman
Chiron Consulting
 
Hey Greg thanks so much, this stuff is actually starting to make sense with all the examples and me reading the MODBUS/TCP implementation spec from the MODBUS website.

If I have anymore questions I'll be sure to ask you, thanks!!
 
J

Joe Jansen/ENGR/HQ/KEMET/US

"http://mat.sf.net"://http://mat.sf.net

There is code there, in C, for Modbus. It is free. Sometimes you get what you _don't_ pay for.

Caveat: It is licensed under the GPL. You cannot put that code into a program and then market the end result in binary only format. Since you are going to use C#, you will probably have to edit it significantly anyway. Just letting you know: It is free for you to look at and use, but if you use it, you cannot make it un-free.

I ranted a bit on another thread about the 'you get what you pay for' argument. I no longer put any stock in it.

The rest of the advice sounds good. The more you know about the hardware, the better you will be at controlling it through software.

--Joe Jansen
 
L

Lewis Bodden

I didn't mean it to come off as a flame. I was merely trying to point out a few facts. So far I haven't seen any post of source code on this thread. There are a few links to some sites, but I didn't find much on usable source. Also I didn't get a response from you (Fred Intiso - Intern) about your boss or the management of your company permitting you to post the source here. If you get permission to publish it here as freeware I am willing to collaborate with you on the development.

After doing some checking on the Beckhoff 9000 and assuming that you are trying to communicate to these devises via MODBUS/TCP, I think I see why you may be having problems.

Are you attempting to communicate over a TCP/IP connection or a serial port?

MOBUS is a protocol for a serial port when MODBUS/TCP is meant to go over a network. It may still go out a serial port to a device. (See Figure 1 on page 9 of the MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE Rev 1.0 8May02 from "www.modbus.org":http://www.modbus.org )
 
Top