Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modbus stack for Microchip PIC

Can someone suggest an open source implementation of a Modbus RTU Slave for a Microchip PIC18 processor? I'm looking for an implementation of Modbus RTU for RS-232/RS-485, but a Modbus TCP/IP implementation would be welcome as well.

like image 735
mjh2007 Avatar asked Jan 25 '10 15:01

mjh2007


People also ask

What is Modbus stack?

Modbus is an application layer messaging protocol, positioned at level 7 of the OSI model that provides client/server communication between devices connected on different types of buses or networks. Modbus is a request/reply protocol and offers services specified by function codes.

What three things make up a Modbus frame?

The Modbus message structure uses an ADU/PDU frame. The protocol data unit (PDU) is independent of the underlying communication layers. The ADU includes the address of the server device, the PDU, and a checksum field. The PDU includes a function code with a read or write command, and any data, where relevant.

What is rs485 Modbus?

The RS-485 bus used by WattNode® Modbus energy meters (and most other slave devices) is referred to as a “two wire” half-duplex bus (vs. “four wire” full-duplex). A half-duplex, two-wire bus requires fewer signal conductors, but only allows one device to transmit at any given time.

What is a Modbus bridge?

What is a Modbus Bridge? The Modbus Bridge allows Modbus devices to work on a lot of types of networks. A Modbus bridge is a device that connects Modbus serial products to Modbus TCP Masters. It can be an important part of a Modbus network.


2 Answers

I've implemented a Modbus RTU (and ASCII) slave for PIC18 but using USB instead of RS232/485. It would be very easy to convert to RS232/485 though as the protocol code only requires character transmit and receive functions. I can help you with this if required.

Take a look at my USB Modbus I/O page at http://www.fieldofcows.com/index.php?title=USB_Modbus_Interface to see if it meets your needs. The page includes a download link for the source code. The source is released under GNU GPL.

like image 67
user259655 Avatar answered Oct 03 '22 11:10

user259655


You can find a Modbus RTU and TCP slave implementation in 'C' source code form at http://www.colwaysolutions.com. Since the implementation is in ANSI 'C' you can port it easily to PIC too. The vendor also provides ports to a few popular micro controller cores like 8051, ARM, Coldfire etc. including for some RTOS kernels (OS9, MQX, uc-OS). The library is very light weight consuming negligible RAM and ROM space.

like image 40
gho Avatar answered Oct 03 '22 11:10

gho