Modicon Modbus Protocol Reference Guide

pdf
Số trang Modicon Modbus Protocol Reference Guide 121 Cỡ tệp Modicon Modbus Protocol Reference Guide 172 KB Lượt tải Modicon Modbus Protocol Reference Guide 0 Lượt đọc Modicon Modbus Protocol Reference Guide 48
Đánh giá Modicon Modbus Protocol Reference Guide
4.1 ( 4 lượt)
Nhấn vào bên dưới để tải tài liệu
Đang xem trước 10 trên tổng 121 trang, để tải xuống xem đầy đủ hãy nhấn vào bên trên
Chủ đề liên quan

Nội dung

Modicon Modbus Protocol Reference Guide PI–MBUS–300 Rev. J 1 Modicon Modbus Protocol Reference Guide PI–MBUS–300 Rev. J June 1996 MODICON, Inc., Industrial Automation Systems One High Street North Andover, Massachusetts 01845 DOK- 3 Preface This guide is written for the person who will use Modicon Modbus protocols and messages for communication in Modicon programmable controller applications. It describes how messages are constructed, and how transactions take place using Modbus protocol. This guide should be used in conjunction with Modicon user guides for the types of networks and programmable controllers present in the application. Familiarity with your network layout, and with your control application, is assumed. The data and illustrations in this book are not binding. We reserve the right to modify our products in line with our policy of continuous product improvement. Information in this document is subject to change without notice and should not be construed as a commitment by Modicon, Inc., Industrial Automation Systems. Modicon, Inc. assumes no responsibility for any errors that may appear in this document. If you have any suggestions for improvements, or have found any errors in this publication, please notify us. No part of this document may be reproduced in any form or by any means, electronic or mechanical, without the express written permission of Modicon, Inc., Industrial Automation Systems. All rights reserved. The following are trademarks of Modicon, Inc.: Modbus ModConnect Modcom 984 BM85 BP85 P190 RR85 SA85 SM85 SQ85 DEC is a registered trademark of Digital Equipment Corporation. VAX and DECNET are trademarks of Digital Equipment Corporation. IBM is a registered trademark of International Business Machines Corporation. IBM AT, IBM XT, Micro Channel, and Personal System/2 are trademarks of International Business Machines Corporation. Microsoft and MS–DOS are registered trademarks of Microsoft Corporation. Western Digital is a registered trademark of Western Digital Corporation. Ethernet is a trademark of Xerox Corporation. Copyright  1996, Modicon, Inc. Printed in U. S. A. PI-MBUS–300 Preface iii Related Publications Refer to the following publication for details about the application of Modicon 984 Programmable Controller systems: GM–0984–SYS 984 Programmable Controller Systems Manual. Modicon, Inc. Refer to the following publications for details about the application and installation of the Modbus Plus network and related communications devices: GM–MBPL–001 Modbus Plus Network Planning and Installation Guide. Modicon, Inc. GM–BM85–001 Modbus Plus Bridge/Multiplexer User’s Guide. Modicon, Inc. Refer to the following publication for details about the Modcom III Communications Software Library for host computer applications: GM–MC3A–001 iv Modcom III Communications Software Library User’s Guide. Modicon, Inc. Related Publications PI-MBUS–300 Contents Chapter 1 Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . 1 Introducing Modbus Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Transactions on Modbus Networks . . . . . . . . . . . . . . . . . . . . . . . . . Transactions on Other Kinds of Networks . . . . . . . . . . . . . . . . . . . The Query–Response Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Two Serial Transmission Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASCII Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTU Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modbus Message Framing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASCII Framing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTU Framing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How the Address Field is Handled . . . . . . . . . . . . . . . . . . . . . . . . . . How the Function Field is Handled . . . . . . . . . . . . . . . . . . . . . . . . . Contents of the Data Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contents of the Error Checking Field . . . . . . . . . . . . . . . . . . . . . . . How Characters are Transmitted Serially . . . . . . . . . . . . . . . . . . . . Error Checking Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parity Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LRC Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CRC Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4 4 5 6 6 7 8 8 9 10 10 11 12 13 14 14 15 16 PI–MBUS–300 Contents vii viii Chapter 2 Data and Control Functions . . . . . . . . . . . . . 17 Modbus Function Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How Numerical Values are Expressed . . . . . . . . . . . . . . . . . . . . . . Data Addresses in Modbus Messages . . . . . . . . . . . . . . . . . . . . . . Field Contents in Modbus Messages . . . . . . . . . . . . . . . . . . . . . . . Field Contents on Modbus Plus . . . . . . . . . . . . . . . . . . . . . . . . . . . . Function Codes Supported by Controllers . . . . . . . . . . . . . . . . . . . . . . . . . 01 Read Coil Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 02 Read Input Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 03 Read Holding Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 04 Read Input Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 05 Force Single Coil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 06 Preset Single Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 07 Read Exception Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 (0B Hex) Fetch Comm Event Ctr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 (0C Hex) Fetch Comm Event Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 (0F Hex) Force Multiple Coils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 (10 Hex) Preset Multiple Regs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 (11 Hex) Report Slave ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 (14Hex) Read General Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 (15Hex) Write General Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 (16Hex) Mask Write 4X Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 (17Hex) Read/Write 4X Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 (18Hex) Read FIFO Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 18 18 18 20 22 24 26 28 30 32 34 36 38 40 44 46 48 58 62 66 68 70 Contents PI–MBUS–300 Chapter 3 Diagnostic Subfunctions . . . . . . . . . . . . . . . . 73 Function 08 – Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Diagnostic Codes Supported by Controllers . . . . . . . . . . . . . . . . . . . . . . . . Diagnostic Subfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 00 Return Query Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 01 Restart Communications Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 02 Return Diagnostic Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 03 Change ASCII Input Delimiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 04 Force Listen Only Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 (0A Hex) Clear Counters and Diagnostic Register . . . . . . . . . . . . . . . 11 (0B Hex) Return Bus Message Count . . . . . . . . . . . . . . . . . . . . . . . . . . 12 (0C Hex) Return Bus Communication Error Count . . . . . . . . . . . . . . . 13 (0D Hex) Return Bus Exception Error Count . . . . . . . . . . . . . . . . . . . . 14 (0E Hex) Return Slave Message Count . . . . . . . . . . . . . . . . . . . . . . . . 15 (0F Hex) Return Slave No Response Count . . . . . . . . . . . . . . . . . . . . 16 (10 Hex) Return Slave NAK Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 (11 Hex) Return Slave Busy Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 (12 Hex) Return Bus Character Overrun Count . . . . . . . . . . . . . . . . . 19 (13 Hex) Return IOP Overrun Count (884) . . . . . . . . . . . . . . . . . . . . . 20 (14 Hex) Clear Overrun Counter and Flag (884) . . . . . . . . . . . . . . . . . 21 (15 Hex) Get/Clear Modbus Plus Statistics . . . . . . . . . . . . . . . . . . . . . Modbus Plus Network Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 76 77 77 77 78 81 81 81 82 82 82 83 83 83 84 84 84 85 86 87 Appendix A Exception Responses . . . . . . . . . . . . . . . . . 93 Exception Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exception Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 96 Appendix B Application Notes . . . . . . . . . . . . . . . . . . . . . 99 Maximum Query/Response Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . Estimating Serial Transaction Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Notes for the 584 and 984A/B/X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 106 108 Appendix C LRC/CRC Generation . . . . . . . . . . . . . . . . . 109 LRC Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CRC Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PI–MBUS–300 Contents 110 112 ix Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 x Overview of Modbus Protocol Application . . . . . . . . . . . . . . . Master–Slave Query–Response Cycle . . . . . . . . . . . . . . . . . . ASCII Message Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTU Message Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Order (ASCII) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Order (RTU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master Query with ASCII/RTU Framing . . . . . . . . . . . . . . . . . Slave Response with ASCII/RTU Framing . . . . . . . . . . . . . . . Field Contents on Modbus Plus . . . . . . . . . . . . . . . . . . . . . . . . 3 5 8 9 13 13 19 19 21 Figure 10 Read Coil Status – Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 11 Read Coil Status – Response . . . . . . . . . . . . . . . . . . . . . . . . 24 25 Figure 12 Figure 13 Read Input Status – Query . . . . . . . . . . . . . . . . . . . . . . . . . . . Read Input Status – Response . . . . . . . . . . . . . . . . . . . . . . . 26 27 Figure 14 Figure 15 Read Holding Registers – Query . . . . . . . . . . . . . . . . . . . . . . Read Holding Registers – Response . . . . . . . . . . . . . . . . . . 28 29 Figure 16 Figure 17 Read Input Registers – Query . . . . . . . . . . . . . . . . . . . . . . . . Read Input Registers – Response . . . . . . . . . . . . . . . . . . . . 30 31 Figure 18 Figure 19 Force Single Coil – Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . Force Single Coil – Response . . . . . . . . . . . . . . . . . . . . . . . . 32 33 Figure 20 Figure 21 Preset Single Register – Query . . . . . . . . . . . . . . . . . . . . . . . Preset Single Register – Response . . . . . . . . . . . . . . . . . . . 34 35 Figure 22 Figure 23 Read Exception Status – Query . . . . . . . . . . . . . . . . . . . . . . Read Exception Status – Response . . . . . . . . . . . . . . . . . . . 36 37 Figure 24 Figure 25 Fetch Communications Event Counter – Query . . . . . . . . . Fetch Communications Event Counter – Response . . . . . . 38 39 Figure 26 Figure 27 Fetch Communications Event Log – Query . . . . . . . . . . . . . Fetch Communications Event Log – Response . . . . . . . . . 40 41 Contents PI–MBUS–300 Figure 28 Figure 29 Force Multiple Coils – Query . . . . . . . . . . . . . . . . . . . . . . . . . Force Multiple Coils – Response . . . . . . . . . . . . . . . . . . . . . . 45 45 Figure 30 Figure 31 Preset Multiple Registers – Query . . . . . . . . . . . . . . . . . . . . . Preset Multiple Registers – Response . . . . . . . . . . . . . . . . . 46 47 Figure 32 Figure 33 Report Slave ID – Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Report Slave ID – Response . . . . . . . . . . . . . . . . . . . . . . . . . 48 49 Figure 34 Figure 35 Read General Reference – Query . . . . . . . . . . . . . . . . . . . . . Read General Reference – Response . . . . . . . . . . . . . . . . . 60 61 Figure 36 Figure 37 Write General Reference – Query . . . . . . . . . . . . . . . . . . . . . Write General Reference – Response . . . . . . . . . . . . . . . . . 64 65 Figure 38 Figure 39 Mask Write 4X Register – Query . . . . . . . . . . . . . . . . . . . . . . Mask Write 4X Register – Response . . . . . . . . . . . . . . . . . . 67 67 Figure 40 Figure 41 Read/Write 4X Registers – Query . . . . . . . . . . . . . . . . . . . . . Read/Write 4X Registers – Response . . . . . . . . . . . . . . . . . 68 69 Figure 42 Figure 43 Read FIFO Queue – Query . . . . . . . . . . . . . . . . . . . . . . . . . . Read FIFO Queue – Response . . . . . . . . . . . . . . . . . . . . . . . 70 71 Figure 44 Figure 45 Diagnostics – Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Diagnostics – Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 75 Figure 46 Master Query and Slave Exception Response . . . . . . . . . . 95 Figure 47 Figure 48 LRC Character Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 CRC Byte Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 PI–MBUS–300 Contents xi Chapter 1 Modbus Protocol Introducing Modbus Protocol The Two Serial Transmission Modes Modbus Message Framing Error Checking Methods PI–MBUS–300 Modbus Protocol 1
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.