How Does a Modbus Master and Slave Work?

stock-photo-modern-blue-circuit-harddisk-board-207068815Modbus is an industrial communication protocol that has been around since 1979. 

Originally developed to connect programmable logic controllers together, Modbus has become a de facto standard for communicating between industrial equipment.

How does a Modbus master and slave work? Modbus is a master/slave multidrop protocol. The master initiates all communication transactions. Each slave has a unique id, responding to the master only when addressed by the master.

Tricky Timing Requirements

Although Modbus is a simple communication protocol, its timing requirements can be difficult to meet in an embedded system with other strict timing requirements.

Recently I designed a custom industrial controller requiring both modbus master and slave support. The controller had to communicate with Modbus slaves on one serial port while simultaneously responding to a plc master on another serial port.

Of course it had to do all this while running the primary control algorithm and communicating over Ethernet. The math didn't work. I could not guarantee the modbus timing under all processor load conditions. 

An Affordable Solution for On-Time Delivery

Instead of risking the project schedule, we decided to add two $0.95 msp430 microcontrollers to the project. One msp430 acted as the Modbus master, the other as a Modbus slave. Both microcontrollers connected to the primary microcontroller (running the controller and Ethernet code) via i2c. The design reduced the timing risk considerably. The msp430 could handle the Modbus timing easily while buffering the Modbus data.

The primary controller simply generated a Modbus packet and sent it over i2c to the msp430 Modbus master. The msp430 took over from there, freeing the primary controller. After the Modbus transaction was complete, the msp430 sent a signal to the primary controller which read the Modbus response via i2c.

The slave Modbus port was handled entirely by the msp430. All Modbus transaction were done in the msp430. The result, the primary processor was completely off loaded.

Using this type of architecture, adding Modbus slave or Modbus master support to almost any product is made easier. Tecnova's electronic engineering team has in-depth experience with Modbus. If you want to add modbus to your current system or you are developing a new Modbus project, contact us for a free project consultation

 

FREE PROJECT CONSULTATION  Talk to one of our experts about your  electronic contract manufacturing,  engineering, or test solutions project.

Topics: Electronic Engineering