Modbus Protocol vs TCP/HTTP Protocol


Tallak Tveide

Modbus comes in two (major) variants. The first one runs on serial port communications, while the other (modbus-tcp) runs over tcp/ip (ie ethernet). Choose the one you need based on your chosen physical layer for communication. The protocols are similar but not exactly the same. Converters exist that convert between the two
Your message's title and message content are asking two different questions. I will try to answer both. TCP/IP is a protocol that is used to transport other protocols. That is, it takes care of the details delivering the messages without worrying about what they mean. Modbus and HTTP are application level protocols, which means they provide some organization and meaning to the data so your software can make sense of it.

Modbus is a very common industrial protocol that comes in several forms:

1) Modbus/RTU and Modbus/ASCII - These are normally delivered over RS-232 or RS-485. There is no transport protocol involved here, and Modbus has to take care of any delivery issues.

2) Modbus/TCP - This is normally delivered over Ethernet using TCP/IP. This uses a modified version of Modbus/RTU.

3) There are several other Modbus variants, but we won't discuss them here.

HTTP is the protocol used to deliver the web pages. Your web browser (e.g. Firefox) makes an HTTP request indicating which page it wants, and the web server responds with the web page. TCP/IP is used to handle the actual delivery however.

HTTP can also be used for more than just web pages. It can transport information which is read by a computer to be used in a program. In that sense, it is being used as transportation protocol for an even high lever protocol. Protocols that use HTTP to transport them are called "web service protocols". There are many, many different web service protocols, most of which are created on an ad hoc basis for a particular application. It's probably the easiest way to create a custom protocol.

Here's some more information on Modbus:
That will tell you some of the details on how Modbus itself works.

The way your computer knows which program to hand an Ethernet message over to is by the use of "IP ports". An IP port is a number which gets sent along with the TCP/IP message. A protocol server program will ask the OS to be allowed to "bind" to a particular port. That is, it will ask to be the program that handles all messages sent to that port number. Normally, each protocol will use a particular port number by convention. HTTP will normally use port 80 and Modbus/TCP will use port 502. However, there is nothing enforcing this convention, and a protocol could use any port, provided the other computers that want to talk to it know what that port number is. The operating system is responsible for routing the messages to the correct server program by port number. This is why multiple server programs can run simultaneously on the same computer.

If you have any more questions, let me know.