Modbus an Introduction

Fieldbus

Before Modbus was invented the issue of connection-oriented control was addressed, where each contact had to be individually wired, requiring two wires per contact. As the amount of information to be transmitted increased, the complexity of the wiring also grew.

The solution came with the introduction of the fieldbus, whose basic principle is similar to Morse code. Both transmitters and receivers must use the same coding system (protocol).

Modbus

Modbus was developed by Modicon in 1979. The general data-model has not changed since them. Modbus-TCP is a standard since 2007.

Modbus includes:

  • Modbus RTU – serial data technology – RS485
  • Modbus Acsii – serial data technology – RS485, RS232
  • Modbus-TCP – RJ45

Datamodel

DatatypeLengthTypeDescription
Discretes Inputs1 BitReadDigital Input
Coils1 BitRad and WriteDigital Output
Input Registers16 BitReadAnalog Input
Holding Registers16 BitRead and WriteAnalog Output

Examples

Discretes Inputs: open/closed
Coils: on/off
Input Registers: -20 -80°C
Holding Register: 0-100%

Discrete Input

The discrete input has a length of 1 Bit. The possible access to this data-type is just read. Corresponds to a digital input.

Example

The PLC calls the state of n inverter.

Possible states: true/false – 0/1

Corresponds to the Boolean data type in PLC programming

Coils

Coils also have a length of 1 Bit, the difference to Discrete Inputs is, that the access to this data-type is read and write. This allows you to change information of this data type. This provides digital output.

Example

The PLC calls the state of n switch relay.

Possible states: true/false – 0/1

Corresponds to the Boolean data type in PLC programming

Input Register

Is an analog data-type, as the name input says, it has read access to the data. The size is 16 Bit which corresponds to 2 Bytes and can therefore map data from 0-65535

Example

Temperature or humidity sensor.

How exactly the transmitted values are to be interpreted must be looked up in the manual of the specific venvor.

Holding Register

Last but not least, the analog output. Also with a length of 16 Bit but with read and write access to the data.

Example

The power of a servomotor which is to be set in %.

Data Points

It’s important to refer to the manufacturer’s instructions here. It describes how the data points are provided. Each piece of information that a device makes available via Modbus is assigned a register number and a data type.

  • Register number
  • Data type
  • (Read/Write access)

Single Data-Areas

A distinction is made here between a large memory area in which all information is listed one after the other.

It should be noted that not all data points have to be listed directly one after the other; there may well be larger gaps. They do not have to be grouped; for example, discrete inputs can come first, then coils and then discrete inputs again. This depends on the manufacturer’s specification.

Separate Data Areas

However, it is possible for each data type to be assigned its own memory area. This means that there can be double data points, e.g. 1 as a coil and to the input register. And here only the function code distinguishes which data type is used.

But, this variant is not as widespread as a single data area.

Function Codes

Describe the actions to be performed read, write, read and write. Compatible with a Morse code table. A distinction is made between the following types of function code. This function codes are specified by the Modbus organisation.

Public Function Codes

This function codes are specified by the Modbus organisation, public and documented.
Enabled Area: 1-65;72-100;110-127

FCData-typeAction
FC1CoilReading of one or more digital Outputs
FC2Discrete InputReading of one or more digital Inputs
FC3Holding RegisterReading of one or more analog Outputs
FC4Input RegisterReading of one or more analog Inputs
FC5CoilWrite of one digital Output
FC6Holding RegisterWrite of one analog Output
FC15CoilWrite of more digital Output
FC16Holding RegisterWrite of more analog Output

User-Defined Function Codes

Developed by vendors and users, more company internal usage.
Enabled Area: 65-72;100-110

Reserved Function Code

Used by old products (legacy devices)

Example FC-1 in detail

Reads out the status of one or more coils (digital outputs). Cannot change the digital output but you can query the current status.

Access: Read
Data-Type: Coils
Count: 1-2000

Request

A request consists of three components:

To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.

RequestSizeExample hexaExample dezimal
Function Code1 Byte0x011
Modbusregister (Startregister)2 Bytes0x007D55
Count of reading Coils1 Byte0x00011

Answer

To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.

AnswerSizeExample hexaExample dezimal
Function Code1 Byte0x011
Byte Count2 Bytes0x00011
Status der Coils1 Byte0x011

The byte count indicates exactly how large the status of the coils is (1 byte = 8 bits = 8 possible states)

Convert decimal notation and hex notation to binary to explain the value.

The first byte is responsible for the lowest registers.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert