首页 > 其他分享 >Modbus communication types

Modbus communication types

时间:2024-02-02 15:12:44浏览次数:16  
标签:RTU used protocol communication Modbus registers data types

An Introduction to the Modbus Communication Protocol https://www.solisplc.com/tutorials/modbus

The Modbus Organization https://modbus.org/

Introduction to the modbus protocol

Original equipment manufacturers (OEMs) all have proprietary communication protocols such as Profinet, CIP, DeviceNet, and ControlNet used to communicate with all their devices on the plant floor. As we know, there are different manufacturers of controllers, instruments, and peripheral devices, which leaves the question of how to make them exchange data with each other. This led to open-source protocols that bridge the gap left by proprietary protocols in communicating with third-party devices. Standard open protocols are Modbus, OPC DA, OPC UA, MQTT. This article will look in-depth into the MODBUS protocol, its benefits, types, and implementation.

What is Modbus

MODBUS is a communication protocol developed by Modicon in 1979 (now Schneider Electric) used by programmable logic controllers. Modbus transmission of data can be over serial lines or ethernet. Many devices are now Modbus compliant since it's now a widely accepted communication protocol. Supervisory Control and Data Acquisition mainly use Modbus (SCADA) to receive data from remote terminal units (RTU) and PLCs.

Modbus communication types

Modbus can be grouped into three broad types:

  1. Modbus RTU
  2. Modbus ASCII
  3. Modbus TCP

Modbus RTU

Modbus RTU is the most often used Modbus protocol. Modbus RTU is a straightforward serial protocol that may be sent using standard UART technology. At baud speeds ranging from 1200 bits per second (baud) to 115200 bits per second, data is delivered in 8-bit bytes, one bit at a time. The majority of Modbus RTU devices support only 38400 bits per second. A Modbus RTU operates a Master to slave structure. A Modbus master can connect with up to 254 slaves and exchange data. Each slave has its own 8-bit device address, often known as a unit number. The address of the slave for whom the communication is intended is included in the packets transmitted by the master. The slave must only answer if its address is recognized, and it must do so within a specific amount of time, or the master will consider it a "no response" error.

A slave is any peripheral device that analyzes data and delivers a response message to the master using Modbus, such as an I/O transducer, valve, network drive, or other measuring devices. The communication media for an RTU network is serial, either using RS232, RS422, or RS485.

Figure 1 - Modbus Protocol | Physical connection of RS232, RS485, RS422 using a DB9 cable Figure 1 - Modbus Protocol | Physical connection of RS232, RS485, RS422 using a DB9 cable

Modbus ASCII

Modbus ASCII is an older version of the protocol that contains all of the elements of an RTU packet but is entirely written in understandable ASCII characters. Modbus ASCII isn't supported, isn't widely used, and isn't included in the official Modbus protocol specification.

Modbus Protocol TCP

Since its inception, Ethernet IP/TCP has been the most common network protocol. Modbus TCP wraps Modbus RTU data packets in a TCP packet that can be sent over conventional Ethernet networks. In TCP, the slave address is not the primary method of addressing. The IP address, for example, 192.168.0.20, is the most essential here. The regular Modbus TCP port is 502, but it is frequently reconfigured if necessary. Modbus TCP follows the OSI network model.

Modbus shifts from the conventional master to slave relationship to the client to server, where the master becomes the client and the slave the server. There can be multiple clients and multiple slaves, which is one of the beauties of Modbus TCP made possible through the peer-to-peer communication of Ethernet IP. A standard RJ 45 cable (LAN) is used for physically connecting Modbus TCP compliant devices.

Modbus message structure

To be able to use any technology to its full capacity, it is pertinent to understand how it functions. Modbus makes use of registers in sending the different types of data. Registers are like ‘buckets’ that house data points. Some of the registers used in Modbus include the following;

  1. Discrete inputs (contacts): Discrete inputs are bit contact registers, and they can only be read. They can best be described as the contacts in PLC programming.
  2. Discrete Outputs (Coils): Coils are one-bit registers used as outputs. They are both read and write registers.
  3. Input registers: Inputs registers are 16-bit registers used for inputs. They are read only.
  4. Holding registers: Holding registers are 16-bit registers that are both read and write. They are the most universal register as they can be used for inputs, outputs, and for holding any kind of data.
Figure 2 - Modbus Protocol | Message Structure Figure 2 - Modbus Protocol | Message Structure

Modbus function codes

The Modbus protocol specifies the number of function codes that can be used to access Modbus registers. Modbus defines four separate data blocks, each with addresses or register numbers that overlap. As a result, both the address (or register number) and the function code are required to comprehensively explain where to find a piece of data (or register type).

The function codes recognized by Modbus are listed in the table below. Although this is not an exhaustive list of function codes, they are the most used and important ones to familiarize with.

Figure 3 - Modbus Protocol | Function Codes Figure 3 - Modbus Protocol | Function Codes

Modbus error (exception) code explanation

When a Modbus slave detects a packet but concludes that the request contains an error, it responds with an exception code rather than a data response. The slave address or unit number, a copy of the function code with the high bit set, and an exception code make up the exception reply.

Figure 4 - Modbus Protocol | Error Code Explanations Figure 4 - Modbus Protocol | Error Code Explanations

Conclusion

This is only an introduction to what the Modbus protocol is all about. Numerous resources on the internet will explain some of these concepts. I encourage the reader to explore some of these resources. The Modbus protocol is a versatile industrial network protocol that has gained relevance in the automation society; hence having a good understanding is imperative.

 

 

 

翻译

搜索

复制

标签:RTU,used,protocol,communication,Modbus,registers,data,types
From: https://www.cnblogs.com/papering/p/18003197

相关文章

  • [Typescript 5] Intro to Variants (keyword in & out)
    Covariance-producer-out-functionreturnposition-samearrowdirectionContravariance-packager-in-functionparamposition-differentarrowdirectionInvariance-bothproducerandpackager-oneinfunctionreturnpositionandanotherinfun......
  • 从零搭建Vue3 + Typescript + Pinia + Vite + Tailwind CSS + Element Plus开发脚手架
    项目代码以上传至码云,项目地址:https://gitee.com/breezefaith/vue-ts-scaffold目录前言脚手架技术栈简介vue3TypeScriptPiniaTailwindCSSElementPlusvite详细步骤Node.js安装创建以typescript开发的vue3工程集成Pinia安装pinia修改main.ts创建一个store在组件中使用store集......
  • [Typescript] The type Registry pattern (declare module)
    OurprojectmighthaveafilestructurelikeOurprojectmighthaveafilestructurelikedata/book.ts//AmodelforBookrecordsmagazine.ts//AmodelforMagazinerecordslib/registry.ts//Ourtyperegistry,anda`fetchRecord`f......
  • vue3 在 TypeScript 文件中,const route = useRoute();route undefined 不能在顶层作用
    ts文件内部不能使用import{useRoute}from'vue-router';constroute=useRoute();routeundefined在TypeScript文件中,不能在顶层作用域内使用Vue组件的Hooks函数,例如useRoute。Hooks函数只能在Vue组件中使用。如果你想在TypeScript文件中获取当前路由信息,你可......
  • 项目实践 采集Profinet IO从站设备数据转modbus方案
    1 功能需求在很多项目应用中,需要把ProfinetIO设备的数据发送到modbus协议的scada系统中。因为在系统主要是modbus协议,ProfinetIO设备不能直接接入到系统。ProfinetIOA协议内容非常复杂,所以modbus设备不直接支持ProfinetIO协议。使用一个协议转换的网关设备可以很好的实现两个......
  • 物联网浏览器(IoTBrowser)-Modbus协议集成和测试
    Modbus协议在应用中一般用来与PLC或者其他硬件设备通讯,Modbus集成到IoTBrowser使用串口插件模式开发,不同的是采用命令函数,具体可以参考前面几篇文章。目前示例实现了Modbus-Rtu和Modbus-Tcp两种,通过js可以与Modbus进行通讯控制。   一、开发插件添加引用添加NModbus4,......
  • pyinstaller -noconsole报错win32ctypes.pywin32.pywintypes.error: (225, '', '无法
    将pyinstaller6.3.0,卸载后,安装6.2.0重新打包即可https://www.cnblogs.com/uoky/p/17916300.html但是使用-w或者--noconsole就会报错win32ctypes.pywin32.pywintypes.error:(225,'','无法成功完成操作,因为文件包含bingdu或潜在的垃圾软件。')......
  • [Typescript 5] infer Constraints
    Sincetypescript5,weareabletoaddconstraintsoverinfer.Followingcodedoesn'tapplyconstraints,sotheinferredelementcouldbe stringand numbertypeGetFirstStringIshElement<T>=Textendsreadonly[inferS,..._:any[]]?S:n......
  • MySQL 系统变量 group_replication_get_communication_protocol
    MySQL系统变量group_replication_get_communication_protocol(MonJan2923:14:512024)[root@GreatSQL][(none)]>selectversion(),group_replication_get_communication_protocol();+-----------+------------------------------------------------+|version()|gr......
  • [Typescript] Native ES module support
    Node.js13.2.0introducedsupportfornativeESmodules.Thismeansyoucannativelyruncodecontainingthinglike import{Foo}from'bar',usetop-level await andmore!Howtounambiguouslyindicatewhichtypeofmoduleyou’reauthoringFil......