CN108614789B - Communication system and method of serial port bus with handshake mechanism - Google Patents

Communication system and method of serial port bus with handshake mechanism Download PDF

Info

Publication number
CN108614789B
CN108614789B CN201810304727.7A CN201810304727A CN108614789B CN 108614789 B CN108614789 B CN 108614789B CN 201810304727 A CN201810304727 A CN 201810304727A CN 108614789 B CN108614789 B CN 108614789B
Authority
CN
China
Prior art keywords
slave
data
handshake
handshake signal
master device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810304727.7A
Other languages
Chinese (zh)
Other versions
CN108614789A (en
Inventor
谢德福
王建平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Future Angel Robot Co ltd
Original Assignee
Shenzhen Future Angel Robot Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Future Angel Robot Co ltd filed Critical Shenzhen Future Angel Robot Co ltd
Priority to CN201810304727.7A priority Critical patent/CN108614789B/en
Publication of CN108614789A publication Critical patent/CN108614789A/en
Application granted granted Critical
Publication of CN108614789B publication Critical patent/CN108614789B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • G06F13/4286Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a handshaking protocol, e.g. RS232C link
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C

Abstract

The invention discloses a serial port bus communication method with a handshake mechanism, which comprises the following steps: firstly, the master device is connected with all the slave devices through data receiving and transmitting lines respectively, and each slave device is connected with other slave devices through handshake signal lines; secondly, the master device directly sends instruction data with address codes to the slave device through a data receiving and sending line; and thirdly, the slave device monitors the handshake signals on the handshake signal line and sends data to the master device through the data transceiving line according to the handshake signals. The invention overcomes the defect that the number of the serial ports of the master device is limited, the serial ports of the master device can be connected with the serial ports of a plurality of slave devices, and the slave devices are connected through handshake signal lines, thereby realizing one-to-many and many-to-one ordered communication between the master device and the plurality of slave devices. The data uploading congestion and even errors caused by directly connecting a plurality of slave devices in series on the communication line of the master device in the traditional mode are avoided, and the data transmission efficiency of the system is improved.

Description

Communication system and method of serial port bus with handshake mechanism
Technical Field
The invention relates to the technical field of industrial automation control, in particular to a communication method of an industrial control system comprising a master device and a plurality of slave devices.
Background
The high speed real time network communication protocol is a bus technology with proprietary property rights of the panasonic company. A high-speed implementation network communication protocol based on 100Mbps adopts a ring topology structure, each node including an upper main control device and a plurality of slave devices connected with the main control device is provided with an outlet (Tx) and an inlet (Rx), namely a data output port and a data input port, a data output serial port between the main device and the plurality of slave devices is connected through a Tx line, and a data input serial port between the main device and the plurality of slave devices is connected through an Rx line. The high-speed real-time network communication protocol realizes the high-precision real-time performance of servo control and has the advantages of high performance, low cost, high reliability and easy realization.
In the prior art, a serial port of a device cannot be used as a bus, and only one-to-one transmission can be performed between two devices. However, the number of serial ports of the master device is limited, and in some applications, such as the robot industry, the master device needs to connect a plurality of slave devices through serial ports, so that a plurality of slave devices have to be connected in series in a serial port channel, and the serial port channel is connected to the master device as a serial port bus application. However, cascading multiple slaves on a communication line can cause congestion and even errors in the uploaded data, and can potentially cause the entire system to crash.
Accordingly, the prior art is deficient and needs improvement.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a serial port bus communication method with a handshake mechanism.
The technical scheme of the invention is as follows: a serial port bus communication method with a handshake mechanism comprises the following steps:
s1: the master equipment is connected with all the slave equipment through data receiving and transmitting lines respectively, and each slave equipment is connected with other slave equipment through a handshake signal line;
s2: the master equipment directly sends instruction data with address codes to the slave equipment through a data receiving and sending line;
s3: the slave device monitors a handshake signal on a handshake signal line and sends data to the master device through a data transceiving line according to the handshake signal;
further, the process of the master device sending the instruction to the target slave device in step S2 includes the following steps:
s201: the master device sends data containing address codes and instructions of target slave devices to all connected slave devices;
s202: the slave equipment receives data which is sent by the master equipment and contains a target slave equipment address code and an instruction, analyzes the address code from the data and checks the address code with the self address code;
s203: the slave device whose own address code is consistent with the address code of the target slave device executes the instruction in the data, and the slave devices whose other address codes are not consistent do not execute the instruction in the data.
Further, the process of the slave device sending data to the master device in step S3 includes the following steps:
s301: each slave device monitors a handshake signal on a handshake signal line;
s302: when a slave device monitors that no handshake signal exists on a handshake signal line, the slave device firstly sends a handshake signal to the handshake signal line, and then sends data to the master device through a data transceiver, and after the data is sent, the slave device clears the handshake signal on the handshake signal line;
s303: when other slave devices monitor that there is a handshake signal on the handshake signal line, the slave device does not send data to the master device, and queues up and monitors the handshake signal on the handshake signal line until it monitors that there is no handshake signal on the handshake signal line, and the slave device sends data to the master device through step S302.
Further, the master device randomly generates an address code of a slave device connected with the master device through a master control chip; the slave device analyzes the address code from the data which is sent by the master device and contains the address code and the instruction of the target slave device through the singlechip, and checks the address code with the address code of the slave device.
Furthermore, the master device is connected with the slave device through a serial communication protocol, wherein the serial communication protocol is RS-232, RS-422, RS-485 or TTLUA RT.
Further, the data transceiving line connection between the serial ports of the master device and the slave device comprises a Tx line and an Rx line.
Further, handshake signal lines are connected between the slave devices through GPIO ports.
Furthermore, the slave device sends a handshake signal by sending a high-level signal to the handshake signal line, and after the slave device sends data to the master device through the signal transceiving line, the handshake signal is eliminated by sending a low-level signal to the handshake signal line.
By adopting the scheme, the serial port of the master device can be connected with the serial ports of the plurality of slave devices, and the slave devices are connected through the handshaking signal lines, so that one-to-many and many-to-one ordered communication between the master device and the plurality of slave devices is realized. The data uploading congestion and even errors caused by directly connecting a plurality of slave devices in series on the communication line of the master device in the traditional mode are avoided, and the data transmission efficiency of the system is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the structures shown in the drawings without creative efforts.
FIG. 1 is a schematic diagram of the system architecture of the invention;
FIG. 2 is a schematic diagram of a process for a master device to send data to a slave device;
fig. 3 is a schematic flow chart of data transmission from the slave device to the master device.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
The invention is described in detail below with reference to the figures and the specific embodiments.
Referring to fig. 1 to 3, the present invention provides a serial bus communication method with a handshake mechanism, for implementing efficient and convenient communication between a master device and a plurality of slave devices, the method includes the following steps:
s1: the master equipment is connected with all the slave equipment through data receiving and transmitting lines respectively, and each slave equipment is connected with other slave equipment through a handshake signal line;
s2: the master equipment directly sends instruction data with address codes to the slave equipment through a data receiving and sending line;
s3: the slave device monitors a handshake signal on a handshake signal line and sends data to the master device through a data transceiving line according to the handshake signal;
the process of sending the instruction from the master device to the target slave device in step S2 includes the following steps:
s201: the master device sends data containing address codes and instructions of target slave devices to all connected slave devices;
s202: the slave equipment receives data which is sent by the master equipment and contains a target slave equipment address code and an instruction, analyzes the address code from the data and checks the address code with the self address code;
s203: the slave device whose own address code is consistent with the address code of the target slave device executes the instruction in the data, and the slave devices whose other address codes are not consistent do not execute the instruction in the data.
The master device may generate an address code of the slave device in a plurality of ways, and as an embodiment, the master device randomly generates an address code of the slave device connected to the master device through the master control chip; the slave equipment also analyzes the address code from the data which is sent by the master equipment and contains the address code and the instruction of the target slave equipment through the singlechip, and checks the address code with the address code of the slave equipment. In this embodiment, the main control chip in the master device adopts a model of fully intelligent a64, and the single chip microcomputer in the slave device adopts a model of STM32F030C8T 6.
The master device and the slave device are connected through a serial communication protocol, the serial communication protocol can be RS-232, RS-422, RS-485 or TTLUA RT and the like, and a TTLUA RT communication serial port is adopted in the embodiment. The data receiving and transmitting line connection between the serial ports of the master device and the slave device comprises a Tx line and an Rx line, wherein the Tx line is a data transmitting line, and the Rx line is a signal receiving line.
The process of the slave device transmitting data to the master device in step S3 includes the steps of:
s301: each slave device monitors a handshake signal on a handshake signal line;
s302: when a slave device monitors that no handshake signal exists on a handshake signal line, the slave device firstly sends a handshake signal to the handshake signal line, and then sends data to the master device through a data transceiver, and after the data is sent, the slave device clears the handshake signal on the handshake signal line;
s303: when other slave devices monitor that there is a handshake signal on the handshake signal line, the slave device does not send data to the master device, and queues up and monitors the handshake signal on the handshake signal line until it monitors that there is no handshake signal on the handshake signal line, and the slave device sends data to the master device through step S302.
In this embodiment, the slave device sends the handshake signal by sending a high-level signal to the handshake signal line, and after the slave device sends data to the master device by the signal transceiver line, the handshake signal is eliminated by sending a low-level signal to the handshake signal line. Specifically, handshake signal lines are connected between the slave devices through GPIO ports, and the GPIO ports are respectively connected with a single chip microcomputer of the slave devices.
When a slave device needs to send data to the master device, the single chip microcomputer of the slave device monitors a level signal on a handshake signal line connected with the GPIO port. When the slave device listens that the level signal on the handshake signal line is high level, that is, the handshake signal is on the handshake signal line, the slave device does not send data to the master device. The slave device queues up for the level on the handshake signal line to transition to a low level, i.e. the handshake signal on the handshake signal line disappears.
When the slave device monitors that the level signal on the handshake signal line is low level, namely no handshake signal exists on the handshake signal line, the slave device firstly sends a handshake signal to the handshake signal line, and the slave device singlechip sends high level to the handshake signal line through the GPIO port; and secondly, the slave device sends data to the master device through the data transceiver line, and after the data is sent, the single chip microcomputer of the slave device sends low level to the handshake signal line through the GPIO port, so that the handshake signal on the handshake signal line is eliminated, and the signal transmission of the slave device is completed. And if the other slave equipment needs to send data to the master equipment, the other slave equipment sends the data to the master equipment according to the priority of the preemption speed after the handshake signals on the handshake signal lines are eliminated. Similarly, the slave device may send the handshake signals in a manner of sending a low level to the handshake signal lines, and may eliminate the handshake signals in a manner of sending a high level to the handshake signal lines.
The invention overcomes the defect that the number of the serial ports of the master device is limited, the serial ports of the master device can be connected with the serial ports of a plurality of slave devices, and the slave devices are connected through handshake signal lines, thereby realizing one-to-many and many-to-one ordered communication between the master device and the plurality of slave devices. The data uploading congestion and even errors caused by directly connecting a plurality of slave devices in series on the communication line of the master device in the traditional mode are avoided, and the data transmission efficiency of the system is improved.
The present invention is not limited to the above preferred embodiments, and any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. A serial port bus communication method with a handshake mechanism is characterized by comprising the following steps:
sl: the master equipment is connected with all the slave equipment through data receiving and transmitting lines respectively, and each slave equipment is connected with other slave equipment through a handshake signal line;
s2: the master equipment directly sends instruction data with address codes to the slave equipment through a data receiving and sending line;
s3: the slave device monitors a handshake signal on a handshake signal line and sends data to the master device through a data transceiving line according to the handshake signal;
in step S3, the process of sending data from the slave device to the master device includes the following steps:
s301: each slave device monitors a handshake signal on a handshake signal line;
s302: when a slave device monitors that no handshake signal exists on a handshake signal line, the slave device firstly sends a handshake signal to the handshake signal line, and then sends data to the master device through a data transceiver, and after the data is sent, the slave device clears the handshake signal on the handshake signal line;
s303: when other slave devices monitor that there is a handshake signal on the handshake signal line, the slave device does not send data to the master device, and queues up and monitors the handshake signal on the handshake signal line until it monitors that there is no handshake signal on the handshake signal line, and the slave device sends data to the master device through step S302.
2. The serial bus communication method with handshake mechanism according to claim 1, wherein the process of the master device sending the command to the target slave device in step S2 includes the following steps:
s201: the master device sends data containing address codes and instructions of target slave devices to all connected slave devices;
s202: the slave equipment receives data which is sent by the master equipment and contains a target slave equipment address code and an instruction, analyzes the address code from the data and checks the address code with the self address code;
s203: the slave device whose own address code is consistent with the address code of the target slave device executes the instruction in the data, and the slave devices whose other address codes are not consistent do not execute the instruction in the data.
3. The serial port bus communication method with the handshake mechanism according to claim 2, wherein the master device randomly generates an address code of a slave device connected with the master device through a master control chip; the slave device analyzes the address code from the data which is sent by the master device and contains the address code and the instruction of the target slave device through the singlechip, and checks the address code with the address code of the slave device.
4. The serial bus communication method with the handshake mechanism according to claim 1, wherein the master device and the slave device are connected through a serial communication protocol, and the serial communication protocol is RS-232, RS-422, RS-485, or TTLUA RT.
5. The serial bus communication method with handshake mechanism as claimed in claim 4, wherein the data transceiving line connection between the serial ports of the master device and the slave device includes Tx line and Rx line.
6. The serial bus communication method with the handshake mechanism according to claim 1, wherein handshake signal lines are connected between the slave devices through GPIO ports.
7. The serial bus communication method with handshake mechanism according to claim 1, wherein the slave device sends the handshake signals by sending high-level signals to the handshake signal lines, and after the slave device sends data to the master device through the signal transceiver lines, the handshake signals are eliminated by sending low-level signals to the handshake signal lines.
CN201810304727.7A 2018-04-08 2018-04-08 Communication system and method of serial port bus with handshake mechanism Active CN108614789B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810304727.7A CN108614789B (en) 2018-04-08 2018-04-08 Communication system and method of serial port bus with handshake mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810304727.7A CN108614789B (en) 2018-04-08 2018-04-08 Communication system and method of serial port bus with handshake mechanism

Publications (2)

Publication Number Publication Date
CN108614789A CN108614789A (en) 2018-10-02
CN108614789B true CN108614789B (en) 2020-06-19

Family

ID=63659674

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810304727.7A Active CN108614789B (en) 2018-04-08 2018-04-08 Communication system and method of serial port bus with handshake mechanism

Country Status (1)

Country Link
CN (1) CN108614789B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109616156B (en) * 2018-12-03 2021-07-06 郑州云海信息技术有限公司 Gene sequencing data storage method and device
CN110209617A (en) * 2019-05-10 2019-09-06 中国电力科学研究院有限公司 A kind of UART serial ports Transistor-Transistor Logic level communicates two-way physics monitoring system and method
CN112134771B (en) * 2019-06-25 2022-03-29 青岛海尔电冰箱有限公司 Half-duplex communication method for refrigerator and refrigerator
CN113127394A (en) * 2021-03-19 2021-07-16 深圳震有科技股份有限公司 Data time-sharing sending method, system and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1622069A (en) * 2004-12-31 2005-06-01 北京中星微电子有限公司 Apparatus for realizing access of driven devices on a unified bus by a plurality of active devices
CN101615169A (en) * 2008-06-26 2009-12-30 上海工程技术大学 Based on the reversible identification of SPI structural model and information exchange platform and method
CN203180949U (en) * 2013-03-27 2013-09-04 郑军 A bus communication system based on UARTs
CN103729319A (en) * 2013-12-04 2014-04-16 上海斐讯数据通信技术有限公司 Equipment system based on serial bus and data transmission method
CN107465487A (en) * 2017-08-14 2017-12-12 来邦科技股份公司 A kind of bus data sending method, system and subset

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1622069A (en) * 2004-12-31 2005-06-01 北京中星微电子有限公司 Apparatus for realizing access of driven devices on a unified bus by a plurality of active devices
CN101615169A (en) * 2008-06-26 2009-12-30 上海工程技术大学 Based on the reversible identification of SPI structural model and information exchange platform and method
CN203180949U (en) * 2013-03-27 2013-09-04 郑军 A bus communication system based on UARTs
CN103729319A (en) * 2013-12-04 2014-04-16 上海斐讯数据通信技术有限公司 Equipment system based on serial bus and data transmission method
CN107465487A (en) * 2017-08-14 2017-12-12 来邦科技股份公司 A kind of bus data sending method, system and subset

Also Published As

Publication number Publication date
CN108614789A (en) 2018-10-02

Similar Documents

Publication Publication Date Title
CN108614789B (en) Communication system and method of serial port bus with handshake mechanism
CN108733604B (en) 485 bus intelligent expansion method and device based on modbus communication protocol
CN103827760B (en) For being carried out the method and system of transmitting procedure reflection by gateway device
CN110601943B (en) Communication system based on RS485 bus and communication method thereof
CN103095538A (en) Multi-class industrial Ethernet bus integrated master station
CN205179099U (en) Realize serial ports agreement and change high -speed real -time network communication agreement circuit
KR101850175B1 (en) Expansion Module for Programmable Logic Controller using USB Communication
CN105207785A (en) PoE system
KR100732510B1 (en) Network system
CN216351920U (en) Programmable logic controller PLC and programmable logic controller PLC system
CN210518377U (en) EtherCAT, ProfiNET bus compatible system
CN103873330A (en) RS422-CAN bus converter
CN107707558B (en) Data transmission system of multi-industry bus
CN105656740A (en) RS422-CAN bus converter
CN101662405B (en) Communication circuit of CAN bus
CN202141922U (en) Distributed real time control system and main station module
CN103001839B (en) Study order is with the system of automatic configuration setting, gateway and method thereof
CN202003197U (en) Mining hydraulic bracket controller, bracket control system
CN204442400U (en) A kind of mining RS-485 isolates repeater
CN210380922U (en) Protocol conversion device and system
CN220043437U (en) Multi-path ARINC-429 bus control system
CN114002994B (en) PLC-based system and networking and communication method thereof
CN204946002U (en) The device of embedded type CPU bus extension Profibus communication bus
CN104090856A (en) Method and device for sharing serial port information
CN103763333A (en) Bridge connection communication module and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant