SlideShare a Scribd company logo
1 of 45
Download to read offline
CONTENTS
PC-BASED MEASUREMENT AND
CONTROL
CHAPTER 8: MODBUS
PhD. NGUYỄN HOÀNG GIÁP
8.1 INTRODUCTION
• MODBUS is an application-layer messaging protocol, positioned at level 7 of the Open
Systems Interconnection (OSI) model. It provides client/server communication between
devices connected on different types of buses or networks.
• The de facto industrial serial standard since 1979, MODBUS continues to enable
millions of automation devices to communicate. Today, support for the simple and
elegant structure of MODBUS continues to grow. The Internet community can access
MODBUS at a reserved system port 502 on the TCP/IP stack.
• MODBUS is a request/reply protocol and offers services specified by function codes.
MODBUS function codes are elements of MODBUS request/reply PDUs. This protocol
specification document describes the function codes used within the framework of
MODBUS transactions.
8.1 INTRODUCTION
8.1 MODBUS APPLICATION PROTOCOL(MBAP) SPECIFICATION
• MODBUS is an application layer messaging protocol for client/server communication
between devices connected on different types of buses or networks. It is currently
implemented using:
• TCP/IP over Ethernet. See MODBUS Messaging Implementation Guide V1.0a.
• Asynchronous serial transmission over a variety of media (wire : EIA/TIA-232-E,
EIA-422, EIA/TIA-485-A; fiber, radio, etc.)
• MODBUS PLUS, a high speed token passing network.
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• The MODBUS protocol allows an easy communication within all types of network
architectures.
• Every type of devices (PLC, HMI, Control Panel, Driver, Motion control, I/O Device…)
can use MODBUS protocol to initiate a remote operation. The same communication can
be done as well on serial line as on an Ethernet TCP/IP networks. Gateways allow a
communication between several types of buses or network using the MODBUS protocol.
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• The MODBUS protocol defines a simple protocol data unit (PDU) independent of the
underlying communication layers. The mapping of MODBUS protocol on specific buses
or network can introduce some additional fields on the application data unit (ADU).
■ PROTOCOL DESCRIPTION
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
■ PROTOCOL DESCRIPTION
MODBUS transaction (error free)
MODBUS transaction (exception response)
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• The size of the MODBUS PDU is limited by the size constraint inherited from the first
MODBUS implementation on Serial Line network (max. RS485 ADU = 256 bytes).
• Therefore: MODBUS PDU for serial line communication = 256 - Server address (1 byte)
- CRC (2 bytes) = 253 bytes.
• Consequently: RS232 / RS485 ADU = 253 bytes + Server address (1 byte) + CRC (2
bytes) = 256 bytes. TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes.
• The MODBUS protocol defines three PDUs. They are :
MODBUS Request PDU, mb_req_pdu
MODBUS Response PDU, mb_rsp_pdu
MODBUS Exception Response PDU, mb_excep_rsp_pdu
■ PROTOCOL DESCRIPTION
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• MODBUS uses a ‘big-Endian’ representation for addresses and data items. This means
that when a numerical quantity larger than a single byte is transmitted, the most
significant byte is sent first.
• For example:
Register size Value
16 - bits 0x1234 the first byte sent is 0x12 then 0x34
■ DATA ENCODING
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• MODBUS bases its data model on a series of tables that have distinguishing
characteristics. The four primary tables are:
■ MODBUS DATA MODEL
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
• The MODBUS application protocol defines precisely PDU addressing rules.
• In a MODBUS PDU each data is addressed from 0 to 65535. In the MODBUS data
Model each element within a data block is numbered from 1 to n.
• The pre-mapping between the MODBUS data model and the device application is totally
vendor device specific.
■ MODBUS ADDRESSING MODEL
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
■ DEFINE MODBUS TRANSACTION
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
■ FUNCTION CODES
There are three categories of MODBUS Functions codes. They are : Public Function Codes,
User-Defined Function Codes, Reserved Function Codes
8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION
■ FUNCTION CODES
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
❖ The MODBUS messaging service provides a Client/Server communication between
devices connected on an Ethernet TCP/IP network. This client / server model is based on
four type of messages:
• MODBUS Request,
• MODBUS Confirmation,
• MODBUS Indication,
• MODBUS Response
■ CLIENT / SERVER MODEL
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
❖ A communicating system over MODBUS TCP/IP may include different types of device:
• A MODBUS TCP/IP Client and Server devices connected to a TCP/IP network
• The Interconnection devices like bridge, router or gateway for interconnection
between the TCP/IP network and a serial line sub-network which permit connections
of MODBUS Serial line Client and Server end devices.
■ PROTOCOL DESCRIPTION
MODBUS TCP/IP communication architecture
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
❖ MODBUS On TCP/IPApplication Data Unit
• A dedicated header is used on TCP/IP to identify the MODBUS Application Data Unit. It
is called the MBAP header (MODBUS Application Protocol header).
■ PROTOCOL DESCRIPTION
MODBUS request/response over TCP/IP
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
❖ MBAP Header description
■ PROTOCOL DESCRIPTION
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ MODBUS COMPONENT ARCHITECTURE MODEL
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS CLIENT
MODBUS Client unit
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS CLIENT DESIGN
A MODBUS client can receive three events:
• A new demand from the user application to send a request, in this case a MODBUS
request has to be encoded and be sent on the network using the TCP management
component service. The lower layer ( TCP management module) can give back an error
due to a TCP connection error, or some other errors.
• A response from the TCP management, in this case the client has to analyze the content
of the response and send a confirmation to the user application
• The expiration of a Time out due to a non-response. A new retry can be sent on the
network or a negative confirmation can be sent to the User Application. Remark :
These retries are initiated by the MODBUS client, some other retries can also be done
by the TCP layer in case of TCP acknowledge lack.
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS CLIENT DESIGN
MODBUS Client Activity Diagram
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ EXAMPLE: BUILD A MODBUS REQUEST
MODBUS request ADU encoding for reading the
register # 5 in a remote server :
MODBUS Request ADU encoding :
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS SERVER
MODBUS Server unit
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS SERVER DESIGN
The MODBUS Server design depends on both :
• The kind of access to the application objects (simple access to attributes or advanced
access to services)
• The kind of interaction between the MODBUS server and the user application
(synchronous or asynchronous).
8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b
■ COMMUNICATION APPLICATION LAYER
❖ MODBUS SERVER DESIGN
Process MODBUS Indication activity diagram
8.3 MODBUS OVER SERIAL LINE
■ MODBUS MASTER/SLAVE PROTOCOL PRINCIPLE
• The MODBUS Serial Line protocol is a Master-Slaves protocol.
• Only one master (at the same time) is connected to the bus, and one or several (247
maximum number) slaves nodes are also connected to the same serial bus.
• A MODBUS communication is always initiated by the master.
• The slave nodes will never transmit data without receiving a request from the master
node.
• The slave nodes will never communicate with each other.
• The master node initiates only one MODBUS transaction at the same time.
8.3 MODBUS OVER SERIAL LINE
■ MODBUS MASTER/SLAVE PROTOCOL PRINCIPLE
The master node issues a MODBUS request to the slave nodes in two modes:
• In broadcast mode, the master can send a
request to all slaves. No response is
returned to broadcast requests sent by
the master. The broadcast requests are
necessarily writing commands. All
devices must accept the broadcast for
writing function.
• In unicast mode, the master addresses an
individual slave. After receiving and
processing the request, the slave returns
a message (a 'reply') to the master . In
that mode, a MODBUS transaction
consists of 2 messages : a request from
the master, and a reply from the slave.
8.3 MODBUS OVER SERIAL LINE
■ MODBUS ADDRESSING RULES
• The MODBUS addressing space comprises 256 different addresses.
• The Address 0 is reserved as the broadcast address. All slave nodes must recognise
the broadcast address.
• The MODBUS Master node has no specific address, only the slave nodes must have
an address. This address must be unique on a MODBUS serial bus.
8.3 MODBUS OVER SERIAL LINE
■ MODBUS FRAME DESCRIPTION
• On MODBUS Serial Line, the Address field only contains the slave address.
• The function code indicates to the server what kind of action to perform. The function
code can be followed by a data field that contains request and response parameters.
• Error checking field is the result of a "Redundancy Checking" calculation that is
performed on the message contents. Two kinds of calculation methods are used
depending on the transmission mode that is being used (RTU or ASCII).
8.3 MODBUS OVER SERIAL LINE
■ MASTER/SLAVE STATE DIAGRAMS
The MODBUS data link layer comprises two separate sub layers :
• The Master / slave protocol
• The transmission mode ( RTU vs ASCII modes)
8.3 MODBUS OVER SERIAL LINE
■ MASTER/SLAVE STATE DIAGRAMS
❖ MASTER STATE DIAGRAM
8.3 MODBUS OVER SERIAL LINE
■ MASTER/SLAVE STATE DIAGRAMS
❖ SLAVE STATE DIAGRAM
8.3 MODBUS OVER SERIAL LINE
■ MASTER/SLAVE COMMUNICATION TIME DIAGRAM
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
❖ RTU TRANSMISSION MODE
The format ( 11 bits ) for each byte in RTU(Remote Terminal Unit) mode is :
Coding System: 8–bit binary
Bits per Byte: 1 start bit
8 data bits, least significant bit sent first
1 bit for parity completion
1 stop bit
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
Frame description:
Cyclical
Redundancy
Checking
❖ MODBUS MESSAGE RTU FRAMING
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
❖ MODBUS MESSAGE RTU FRAMING
In RTU mode, message frames are separated by a silent interval of at least 3.5
character times.
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
❖ MODBUS MESSAGE RTU FRAMING
RTU transmission mode state diagram
8.3 MODBUS OVER SERIAL LINE-ASCII TRANSMISSION MODE
❖ ASCII TRANSMISSION MODE
The format ( 10 bits ) for each byte in ASCII mode is :
Coding System: Hexadecimal, ASCII characters 0–9, A–F
One hexadecimal character contains 4-bits of data within each ASCII
character of the message
Bits per Byte: 1 start bit
7 data bits, least significant bit sent first
1 bit for parity completion;
1 stop bit
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
Frame description:
Longitudinal
Redundancy
Checking
❖ MODBUS MESSAGE ASCII FRAMING
8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE
❖ MODBUS MESSAGE ASCII FRAMING
ASCII transmission mode state diagram
EXERCISE-HK1-18-19
Viết chương trình PLC S7-1200 và thực hiện giao tiếp máy tính qua cổng TCP/IP
điều khiển và giám sát hoạt động của đèn giao thông, chuẩn truyền Modbus TCP.
a. (L.O.1) (1đ)
- Nêu phần mềm lập trình PLC và giao diện máy tính để thực hiện bài toán.
- Lập bảng mapping thông số và tín hiệu điều khiển giữa PLC và giao diện máy tính.
b. (L.O.2) (1.5đ) Viết chương trình PLC thực hiện liên kết thông số từ PC và thực hiện
điều khiển đèn giao thông.
c. (L.O.4) (1.5đ) Thiết kế giao diện và viết chương trình giao diện cho PC.
- Xác định và nêu hoạt động cơ bản các hàm Modbus liên kết dữ liệu giữa PC PLC
- Viết chương trình cấu hình và kết nối giữa PLC và PC
- Giả sử các hàm Modbus có sẵn, viết chương trình cho nút nhấn “Update_Pars” cho
phép cập nhật nội dung đèn XA, VA, XB, VB xuống PLC; và chương trình cho Timer cập
nhật trạng thái PLC.
EXERCISE-HK2-18-19
Lập trình PLC và giao tiếp máy tính qua cổng TCP/IP điều khiển và giám sát hệ
thống lò nhiệt qua chuẩn Modbus TCP theo yêu cầu Hình 1.
a. (L.O.1) (1đ)
- Nêu các hãng, các dòng PLC và phần mềm lập trình PLC tương ứng mà bạn biết.
- Nêu các phần mềm cho phép lập trình kết nối và thực hiện giao diện trên máy tính.
- Xác định bảng mapping thông số Modbus giữa PLC và máy tính từ yêu cầu đề bài,
trong đó Reference là nhiệt độ đặt; Response là nhiệt độ hiện tại của lò; Sigma là độ trễ
của bộ điều khiển ON/OFF.
b. (L.O.2) (2đ) Viết chương trình PLC thực hiện liên kết thông số từ PC. Thực hiện bộ
điều khiển ON/OFF cho hệ lò trên PLC với chu kỳ lấy mẫu 0.5s. Giả sử các ngõ vào AI0
và AI1 đã được chuẩn hóa về tầm áp 0-10V với tầm nhiệt độ 0-200OC.
c. (L.O.4) (2đ) Viết chương trình giao diện cho PC.
- Xác định và nêu hoạt động cơ bản các hàm Modbus liên kết dữ liệu giữa PC và PLC.
- Viết chương trình cấu hình và kết nối giữa PLC và PC
- Giả sử các hàm Modbus có sẵn, viết chương trình điều khiển, giám sát nhiệt độ và cập
nhật thông số xuống PLC.
EXERCISE-HK2-18-19
Hình 1: Điều khiển và giám sát hệ lò nhiệt
EXERCISE-HK3-18-19
Hình 1: Điều khiển và giám sát hệ lò nhiệt
Viết chương trình PLC S7-1200, Giám sát thông số bằng HMI.
a. (L.O.2) (3đ) Viết chương trình PLC điều khiển ON/OFF cho hệ lò trên
PLC S71200 với chu kỳ lấy mẫu 0.1s. Giả sử các ngõ vào AI0 và AI1 đã
được chuẩn hóa về tầm áp 0-10V với tầm nhiệt độ 0-200OC.
b. (L.O.4) (2đ) Thực hiện giao diện HMI, mô tả kết nối dữ liệu giữa HMI và
PLC

More Related Content

Similar to lecture08_MODBUS.pdfDHBK HCMMMMMMMMMMMMMMMMM

[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)
[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)
[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)Ming-Hung Hseih
 
Using%20 modbus%20for%20process[1]
Using%20 modbus%20for%20process[1]Using%20 modbus%20for%20process[1]
Using%20 modbus%20for%20process[1]Manel Montesinos
 
Have a Simple Modbus Server
Have a Simple Modbus ServerHave a Simple Modbus Server
Have a Simple Modbus ServerJian-Hong Pan
 
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...Dhammika Vidanalage
 
I2 c devices
I2 c devicesI2 c devices
I2 c deviceshandson28
 
Modbus_over_serial_line_V1.pdf
Modbus_over_serial_line_V1.pdfModbus_over_serial_line_V1.pdf
Modbus_over_serial_line_V1.pdfbrumley
 
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdf
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdfBA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdf
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdfganiwo4602
 
Industrial Data Network-modbus-Protocol.pptx
Industrial Data Network-modbus-Protocol.pptxIndustrial Data Network-modbus-Protocol.pptx
Industrial Data Network-modbus-Protocol.pptxSeekayAlaisKaruppaia
 
Modbus Based Data Acquisition
Modbus Based Data AcquisitionModbus Based Data Acquisition
Modbus Based Data AcquisitionICP DAS USA, Inc.
 
Konfigurace sítí v Oracle Cloudu
Konfigurace sítí v Oracle ClouduKonfigurace sítí v Oracle Cloudu
Konfigurace sítí v Oracle ClouduMarketingArrowECS_CZ
 
Adam 4572 converter
Adam 4572 converterAdam 4572 converter
Adam 4572 converterAgus Setyadi
 
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution Introduction
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution IntroductionASIX AX58200 EtherCAT to Modbus TCP Gateway Solution Introduction
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution IntroductionASIX Electronics Corporation
 
Detailed description about Hubs Switches Modems and their working
Detailed description about  Hubs Switches Modems and their workingDetailed description about  Hubs Switches Modems and their working
Detailed description about Hubs Switches Modems and their workingrockingprashik
 
Vsat day-2008-idirect
Vsat day-2008-idirectVsat day-2008-idirect
Vsat day-2008-idirectSSPI Brasil
 

Similar to lecture08_MODBUS.pdfDHBK HCMMMMMMMMMMMMMMMMM (20)

Modbus
ModbusModbus
Modbus
 
[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)
[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)
[Advantech] Modbus protocol training (ModbusTCP, ModbusRTU)
 
Using%20 modbus%20for%20process[1]
Using%20 modbus%20for%20process[1]Using%20 modbus%20for%20process[1]
Using%20 modbus%20for%20process[1]
 
RTU vs TCP
RTU vs TCPRTU vs TCP
RTU vs TCP
 
Have a Simple Modbus Server
Have a Simple Modbus ServerHave a Simple Modbus Server
Have a Simple Modbus Server
 
Modbus protocol
Modbus protocolModbus protocol
Modbus protocol
 
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...
IMPROVING WORK EFFICIENCY BY REDUCING INTERFACE NOISE GENERATION EXPERIENCED ...
 
IoT Protocol Stack.pdf
IoT Protocol Stack.pdfIoT Protocol Stack.pdf
IoT Protocol Stack.pdf
 
I2 c devices
I2 c devicesI2 c devices
I2 c devices
 
smds
smdssmds
smds
 
Modbus_over_serial_line_V1.pdf
Modbus_over_serial_line_V1.pdfModbus_over_serial_line_V1.pdf
Modbus_over_serial_line_V1.pdf
 
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdf
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdfBA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdf
BA_KOSTAL-Interface-description-MODBUS_PIKO-CI (1).pdf
 
Industrial Data Network-modbus-Protocol.pptx
Industrial Data Network-modbus-Protocol.pptxIndustrial Data Network-modbus-Protocol.pptx
Industrial Data Network-modbus-Protocol.pptx
 
Modbus Based Data Acquisition
Modbus Based Data AcquisitionModbus Based Data Acquisition
Modbus Based Data Acquisition
 
Konfigurace sítí v Oracle Cloudu
Konfigurace sítí v Oracle ClouduKonfigurace sítí v Oracle Cloudu
Konfigurace sítí v Oracle Cloudu
 
Adam 4572 converter
Adam 4572 converterAdam 4572 converter
Adam 4572 converter
 
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution Introduction
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution IntroductionASIX AX58200 EtherCAT to Modbus TCP Gateway Solution Introduction
ASIX AX58200 EtherCAT to Modbus TCP Gateway Solution Introduction
 
Detailed description about Hubs Switches Modems and their working
Detailed description about  Hubs Switches Modems and their workingDetailed description about  Hubs Switches Modems and their working
Detailed description about Hubs Switches Modems and their working
 
Broadband
BroadbandBroadband
Broadband
 
Vsat day-2008-idirect
Vsat day-2008-idirectVsat day-2008-idirect
Vsat day-2008-idirect
 

Recently uploaded

UNIT-III-TRANSMISSION SYSTEMS REAR AXLES
UNIT-III-TRANSMISSION SYSTEMS REAR AXLESUNIT-III-TRANSMISSION SYSTEMS REAR AXLES
UNIT-III-TRANSMISSION SYSTEMS REAR AXLESDineshKumar4165
 
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERUNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERDineshKumar4165
 
Hyundai World Rally Team in action at 2024 WRC
Hyundai World Rally Team in action at 2024 WRCHyundai World Rally Team in action at 2024 WRC
Hyundai World Rally Team in action at 2024 WRCHyundai Motor Group
 
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfJohn Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfExcavator
 
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp NumberVip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Numberkumarajju5765
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubaikojalkojal131
 
Not Sure About VW EGR Valve Health Look For These Symptoms
Not Sure About VW EGR Valve Health Look For These SymptomsNot Sure About VW EGR Valve Health Look For These Symptoms
Not Sure About VW EGR Valve Health Look For These SymptomsFifth Gear Automotive
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsMihajloManjak
 
Crash Vehicle Emergency Rescue Slideshow.ppt
Crash Vehicle Emergency Rescue Slideshow.pptCrash Vehicle Emergency Rescue Slideshow.ppt
Crash Vehicle Emergency Rescue Slideshow.pptVlademirGebDubouzet1
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...shivangimorya083
 
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualJohn Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualExcavator
 
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...Niya Khan
 
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...shivangimorya083
 
John Deere Tractors 5515 Diagnostic Repair Manual
John Deere Tractors 5515 Diagnostic Repair ManualJohn Deere Tractors 5515 Diagnostic Repair Manual
John Deere Tractors 5515 Diagnostic Repair ManualExcavator
 
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 HybridHyundai Motor Group
 
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxUNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxDineshKumar4165
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technologyquickpartslimitlessm
 

Recently uploaded (20)

Call Girls in Shri Niwas Puri Delhi 💯Call Us 🔝9953056974🔝
Call Girls in  Shri Niwas Puri  Delhi 💯Call Us 🔝9953056974🔝Call Girls in  Shri Niwas Puri  Delhi 💯Call Us 🔝9953056974🔝
Call Girls in Shri Niwas Puri Delhi 💯Call Us 🔝9953056974🔝
 
UNIT-III-TRANSMISSION SYSTEMS REAR AXLES
UNIT-III-TRANSMISSION SYSTEMS REAR AXLESUNIT-III-TRANSMISSION SYSTEMS REAR AXLES
UNIT-III-TRANSMISSION SYSTEMS REAR AXLES
 
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERUNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
 
Hyundai World Rally Team in action at 2024 WRC
Hyundai World Rally Team in action at 2024 WRCHyundai World Rally Team in action at 2024 WRC
Hyundai World Rally Team in action at 2024 WRC
 
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfJohn Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
 
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp NumberVip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
 
Not Sure About VW EGR Valve Health Look For These Symptoms
Not Sure About VW EGR Valve Health Look For These SymptomsNot Sure About VW EGR Valve Health Look For These Symptoms
Not Sure About VW EGR Valve Health Look For These Symptoms
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and Qualifications
 
Crash Vehicle Emergency Rescue Slideshow.ppt
Crash Vehicle Emergency Rescue Slideshow.pptCrash Vehicle Emergency Rescue Slideshow.ppt
Crash Vehicle Emergency Rescue Slideshow.ppt
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
 
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
 
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualJohn Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
 
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...
Alia +91-9537192988-Experience the Unmatchable Pleasure with Model Ahmedabad ...
 
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
 
John Deere Tractors 5515 Diagnostic Repair Manual
John Deere Tractors 5515 Diagnostic Repair ManualJohn Deere Tractors 5515 Diagnostic Repair Manual
John Deere Tractors 5515 Diagnostic Repair Manual
 
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
 
Indian Downtown Call Girls # 00971528903066 # Indian Call Girls In Downtown D...
Indian Downtown Call Girls # 00971528903066 # Indian Call Girls In Downtown D...Indian Downtown Call Girls # 00971528903066 # Indian Call Girls In Downtown D...
Indian Downtown Call Girls # 00971528903066 # Indian Call Girls In Downtown D...
 
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxUNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technology
 

lecture08_MODBUS.pdfDHBK HCMMMMMMMMMMMMMMMMM

  • 1. CONTENTS PC-BASED MEASUREMENT AND CONTROL CHAPTER 8: MODBUS PhD. NGUYỄN HOÀNG GIÁP
  • 2. 8.1 INTRODUCTION • MODBUS is an application-layer messaging protocol, positioned at level 7 of the Open Systems Interconnection (OSI) model. It provides client/server communication between devices connected on different types of buses or networks. • The de facto industrial serial standard since 1979, MODBUS continues to enable millions of automation devices to communicate. Today, support for the simple and elegant structure of MODBUS continues to grow. The Internet community can access MODBUS at a reserved system port 502 on the TCP/IP stack. • MODBUS is a request/reply protocol and offers services specified by function codes. MODBUS function codes are elements of MODBUS request/reply PDUs. This protocol specification document describes the function codes used within the framework of MODBUS transactions.
  • 4. 8.1 MODBUS APPLICATION PROTOCOL(MBAP) SPECIFICATION • MODBUS is an application layer messaging protocol for client/server communication between devices connected on different types of buses or networks. It is currently implemented using: • TCP/IP over Ethernet. See MODBUS Messaging Implementation Guide V1.0a. • Asynchronous serial transmission over a variety of media (wire : EIA/TIA-232-E, EIA-422, EIA/TIA-485-A; fiber, radio, etc.) • MODBUS PLUS, a high speed token passing network.
  • 5. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • The MODBUS protocol allows an easy communication within all types of network architectures. • Every type of devices (PLC, HMI, Control Panel, Driver, Motion control, I/O Device…) can use MODBUS protocol to initiate a remote operation. The same communication can be done as well on serial line as on an Ethernet TCP/IP networks. Gateways allow a communication between several types of buses or network using the MODBUS protocol.
  • 6. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • The MODBUS protocol defines a simple protocol data unit (PDU) independent of the underlying communication layers. The mapping of MODBUS protocol on specific buses or network can introduce some additional fields on the application data unit (ADU). ■ PROTOCOL DESCRIPTION
  • 7. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION ■ PROTOCOL DESCRIPTION MODBUS transaction (error free) MODBUS transaction (exception response)
  • 8. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • The size of the MODBUS PDU is limited by the size constraint inherited from the first MODBUS implementation on Serial Line network (max. RS485 ADU = 256 bytes). • Therefore: MODBUS PDU for serial line communication = 256 - Server address (1 byte) - CRC (2 bytes) = 253 bytes. • Consequently: RS232 / RS485 ADU = 253 bytes + Server address (1 byte) + CRC (2 bytes) = 256 bytes. TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes. • The MODBUS protocol defines three PDUs. They are : MODBUS Request PDU, mb_req_pdu MODBUS Response PDU, mb_rsp_pdu MODBUS Exception Response PDU, mb_excep_rsp_pdu ■ PROTOCOL DESCRIPTION
  • 9. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • MODBUS uses a ‘big-Endian’ representation for addresses and data items. This means that when a numerical quantity larger than a single byte is transmitted, the most significant byte is sent first. • For example: Register size Value 16 - bits 0x1234 the first byte sent is 0x12 then 0x34 ■ DATA ENCODING
  • 10. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • MODBUS bases its data model on a series of tables that have distinguishing characteristics. The four primary tables are: ■ MODBUS DATA MODEL
  • 11. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION • The MODBUS application protocol defines precisely PDU addressing rules. • In a MODBUS PDU each data is addressed from 0 to 65535. In the MODBUS data Model each element within a data block is numbered from 1 to n. • The pre-mapping between the MODBUS data model and the device application is totally vendor device specific. ■ MODBUS ADDRESSING MODEL
  • 12. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION ■ DEFINE MODBUS TRANSACTION
  • 13. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION ■ FUNCTION CODES There are three categories of MODBUS Functions codes. They are : Public Function Codes, User-Defined Function Codes, Reserved Function Codes
  • 14. 8.1 MODBUS APPLICATION PROTOCOL SPECIFICATION ■ FUNCTION CODES
  • 15. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ❖ The MODBUS messaging service provides a Client/Server communication between devices connected on an Ethernet TCP/IP network. This client / server model is based on four type of messages: • MODBUS Request, • MODBUS Confirmation, • MODBUS Indication, • MODBUS Response ■ CLIENT / SERVER MODEL
  • 16. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ❖ A communicating system over MODBUS TCP/IP may include different types of device: • A MODBUS TCP/IP Client and Server devices connected to a TCP/IP network • The Interconnection devices like bridge, router or gateway for interconnection between the TCP/IP network and a serial line sub-network which permit connections of MODBUS Serial line Client and Server end devices. ■ PROTOCOL DESCRIPTION MODBUS TCP/IP communication architecture
  • 17. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ❖ MODBUS On TCP/IPApplication Data Unit • A dedicated header is used on TCP/IP to identify the MODBUS Application Data Unit. It is called the MBAP header (MODBUS Application Protocol header). ■ PROTOCOL DESCRIPTION MODBUS request/response over TCP/IP
  • 18. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ❖ MBAP Header description ■ PROTOCOL DESCRIPTION
  • 19. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ MODBUS COMPONENT ARCHITECTURE MODEL
  • 20. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS CLIENT MODBUS Client unit
  • 21. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS CLIENT DESIGN A MODBUS client can receive three events: • A new demand from the user application to send a request, in this case a MODBUS request has to be encoded and be sent on the network using the TCP management component service. The lower layer ( TCP management module) can give back an error due to a TCP connection error, or some other errors. • A response from the TCP management, in this case the client has to analyze the content of the response and send a confirmation to the user application • The expiration of a Time out due to a non-response. A new retry can be sent on the network or a negative confirmation can be sent to the User Application. Remark : These retries are initiated by the MODBUS client, some other retries can also be done by the TCP layer in case of TCP acknowledge lack.
  • 22. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS CLIENT DESIGN MODBUS Client Activity Diagram
  • 23. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ EXAMPLE: BUILD A MODBUS REQUEST MODBUS request ADU encoding for reading the register # 5 in a remote server : MODBUS Request ADU encoding :
  • 24. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS SERVER MODBUS Server unit
  • 25. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS SERVER DESIGN The MODBUS Server design depends on both : • The kind of access to the application objects (simple access to attributes or advanced access to services) • The kind of interaction between the MODBUS server and the user application (synchronous or asynchronous).
  • 26. 8.2 MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b ■ COMMUNICATION APPLICATION LAYER ❖ MODBUS SERVER DESIGN Process MODBUS Indication activity diagram
  • 27. 8.3 MODBUS OVER SERIAL LINE ■ MODBUS MASTER/SLAVE PROTOCOL PRINCIPLE • The MODBUS Serial Line protocol is a Master-Slaves protocol. • Only one master (at the same time) is connected to the bus, and one or several (247 maximum number) slaves nodes are also connected to the same serial bus. • A MODBUS communication is always initiated by the master. • The slave nodes will never transmit data without receiving a request from the master node. • The slave nodes will never communicate with each other. • The master node initiates only one MODBUS transaction at the same time.
  • 28. 8.3 MODBUS OVER SERIAL LINE ■ MODBUS MASTER/SLAVE PROTOCOL PRINCIPLE The master node issues a MODBUS request to the slave nodes in two modes: • In broadcast mode, the master can send a request to all slaves. No response is returned to broadcast requests sent by the master. The broadcast requests are necessarily writing commands. All devices must accept the broadcast for writing function. • In unicast mode, the master addresses an individual slave. After receiving and processing the request, the slave returns a message (a 'reply') to the master . In that mode, a MODBUS transaction consists of 2 messages : a request from the master, and a reply from the slave.
  • 29. 8.3 MODBUS OVER SERIAL LINE ■ MODBUS ADDRESSING RULES • The MODBUS addressing space comprises 256 different addresses. • The Address 0 is reserved as the broadcast address. All slave nodes must recognise the broadcast address. • The MODBUS Master node has no specific address, only the slave nodes must have an address. This address must be unique on a MODBUS serial bus.
  • 30. 8.3 MODBUS OVER SERIAL LINE ■ MODBUS FRAME DESCRIPTION • On MODBUS Serial Line, the Address field only contains the slave address. • The function code indicates to the server what kind of action to perform. The function code can be followed by a data field that contains request and response parameters. • Error checking field is the result of a "Redundancy Checking" calculation that is performed on the message contents. Two kinds of calculation methods are used depending on the transmission mode that is being used (RTU or ASCII).
  • 31. 8.3 MODBUS OVER SERIAL LINE ■ MASTER/SLAVE STATE DIAGRAMS The MODBUS data link layer comprises two separate sub layers : • The Master / slave protocol • The transmission mode ( RTU vs ASCII modes)
  • 32. 8.3 MODBUS OVER SERIAL LINE ■ MASTER/SLAVE STATE DIAGRAMS ❖ MASTER STATE DIAGRAM
  • 33. 8.3 MODBUS OVER SERIAL LINE ■ MASTER/SLAVE STATE DIAGRAMS ❖ SLAVE STATE DIAGRAM
  • 34. 8.3 MODBUS OVER SERIAL LINE ■ MASTER/SLAVE COMMUNICATION TIME DIAGRAM
  • 35. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE ❖ RTU TRANSMISSION MODE The format ( 11 bits ) for each byte in RTU(Remote Terminal Unit) mode is : Coding System: 8–bit binary Bits per Byte: 1 start bit 8 data bits, least significant bit sent first 1 bit for parity completion 1 stop bit
  • 36. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE Frame description: Cyclical Redundancy Checking ❖ MODBUS MESSAGE RTU FRAMING
  • 37. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE ❖ MODBUS MESSAGE RTU FRAMING In RTU mode, message frames are separated by a silent interval of at least 3.5 character times.
  • 38. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE ❖ MODBUS MESSAGE RTU FRAMING RTU transmission mode state diagram
  • 39. 8.3 MODBUS OVER SERIAL LINE-ASCII TRANSMISSION MODE ❖ ASCII TRANSMISSION MODE The format ( 10 bits ) for each byte in ASCII mode is : Coding System: Hexadecimal, ASCII characters 0–9, A–F One hexadecimal character contains 4-bits of data within each ASCII character of the message Bits per Byte: 1 start bit 7 data bits, least significant bit sent first 1 bit for parity completion; 1 stop bit
  • 40. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE Frame description: Longitudinal Redundancy Checking ❖ MODBUS MESSAGE ASCII FRAMING
  • 41. 8.3 MODBUS OVER SERIAL LINE-RTU TRANSMISSION MODE ❖ MODBUS MESSAGE ASCII FRAMING ASCII transmission mode state diagram
  • 42. EXERCISE-HK1-18-19 Viết chương trình PLC S7-1200 và thực hiện giao tiếp máy tính qua cổng TCP/IP điều khiển và giám sát hoạt động của đèn giao thông, chuẩn truyền Modbus TCP. a. (L.O.1) (1đ) - Nêu phần mềm lập trình PLC và giao diện máy tính để thực hiện bài toán. - Lập bảng mapping thông số và tín hiệu điều khiển giữa PLC và giao diện máy tính. b. (L.O.2) (1.5đ) Viết chương trình PLC thực hiện liên kết thông số từ PC và thực hiện điều khiển đèn giao thông. c. (L.O.4) (1.5đ) Thiết kế giao diện và viết chương trình giao diện cho PC. - Xác định và nêu hoạt động cơ bản các hàm Modbus liên kết dữ liệu giữa PC PLC - Viết chương trình cấu hình và kết nối giữa PLC và PC - Giả sử các hàm Modbus có sẵn, viết chương trình cho nút nhấn “Update_Pars” cho phép cập nhật nội dung đèn XA, VA, XB, VB xuống PLC; và chương trình cho Timer cập nhật trạng thái PLC.
  • 43. EXERCISE-HK2-18-19 Lập trình PLC và giao tiếp máy tính qua cổng TCP/IP điều khiển và giám sát hệ thống lò nhiệt qua chuẩn Modbus TCP theo yêu cầu Hình 1. a. (L.O.1) (1đ) - Nêu các hãng, các dòng PLC và phần mềm lập trình PLC tương ứng mà bạn biết. - Nêu các phần mềm cho phép lập trình kết nối và thực hiện giao diện trên máy tính. - Xác định bảng mapping thông số Modbus giữa PLC và máy tính từ yêu cầu đề bài, trong đó Reference là nhiệt độ đặt; Response là nhiệt độ hiện tại của lò; Sigma là độ trễ của bộ điều khiển ON/OFF. b. (L.O.2) (2đ) Viết chương trình PLC thực hiện liên kết thông số từ PC. Thực hiện bộ điều khiển ON/OFF cho hệ lò trên PLC với chu kỳ lấy mẫu 0.5s. Giả sử các ngõ vào AI0 và AI1 đã được chuẩn hóa về tầm áp 0-10V với tầm nhiệt độ 0-200OC. c. (L.O.4) (2đ) Viết chương trình giao diện cho PC. - Xác định và nêu hoạt động cơ bản các hàm Modbus liên kết dữ liệu giữa PC và PLC. - Viết chương trình cấu hình và kết nối giữa PLC và PC - Giả sử các hàm Modbus có sẵn, viết chương trình điều khiển, giám sát nhiệt độ và cập nhật thông số xuống PLC.
  • 44. EXERCISE-HK2-18-19 Hình 1: Điều khiển và giám sát hệ lò nhiệt
  • 45. EXERCISE-HK3-18-19 Hình 1: Điều khiển và giám sát hệ lò nhiệt Viết chương trình PLC S7-1200, Giám sát thông số bằng HMI. a. (L.O.2) (3đ) Viết chương trình PLC điều khiển ON/OFF cho hệ lò trên PLC S71200 với chu kỳ lấy mẫu 0.1s. Giả sử các ngõ vào AI0 và AI1 đã được chuẩn hóa về tầm áp 0-10V với tầm nhiệt độ 0-200OC. b. (L.O.4) (2đ) Thực hiện giao diện HMI, mô tả kết nối dữ liệu giữa HMI và PLC