CN116346523A - Multi-slave station communication protocol method - Google Patents

Multi-slave station communication protocol method Download PDF

Info

Publication number
CN116346523A
CN116346523A CN202111577286.6A CN202111577286A CN116346523A CN 116346523 A CN116346523 A CN 116346523A CN 202111577286 A CN202111577286 A CN 202111577286A CN 116346523 A CN116346523 A CN 116346523A
Authority
CN
China
Prior art keywords
slave
station
master
slave station
master station
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.)
Pending
Application number
CN202111577286.6A
Other languages
Chinese (zh)
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.)
Shandong Siasun Industrial Software Research Institute Co Ltd
Original Assignee
Shandong Siasun Industrial Software Research Institute 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 Shandong Siasun Industrial Software Research Institute Co Ltd filed Critical Shandong Siasun Industrial Software Research Institute Co Ltd
Priority to CN202111577286.6A priority Critical patent/CN116346523A/en
Publication of CN116346523A publication Critical patent/CN116346523A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40019Details regarding a bus master
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention belongs to the field of multi-slave station data communication, and particularly relates to a multi-slave station communication protocol method. The method comprises the following steps: the master station identifies the number of the slave stations through the physical addressing identification instruction and the physical addressing of each slave station; each slave station receives and responds to the physical addressing identification instruction sent by the master station, and further activates the slave station to communicate with the master station. The invention adopts the self resources of the master station and the slave station, and carries out networking on a communication network with one master station and multiple slaves on the basis of not adding any hardware devices. Aiming at the defect that the slave station cannot be identified in serial port networking, a multi-slave station physical addressing identification algorithm is designed; the hardware design cost of the master station and the slave station is reduced, and meanwhile, the software development difficulty is also reduced. All the slave station devices connected on the serial port bus are identified and addressed only through a designed slave station identification software algorithm, so that the host can be ensured to identify corresponding slave station identity information, and one master and multiple slave data communication control can be realized.

Description

Multi-slave station communication protocol method
Technical Field
The invention belongs to the field of multi-slave station data communication, and particularly relates to a multi-slave station communication protocol method.
Background
The programmable controller is an industrial control computer system, the control object of the programmable controller is an industrial production process, the connection between the programmable controller and the industrial production process is realized through an input/output (I/O) module, and the I/O module is a bridge for connecting the programmable controller with a production site. The input module is used for receiving and collecting input signals. The input signals are of two types: the input signals of the switching value are provided by a button switch, a travel switch, a digital dial switch, a proximity switch, a photoelectric switch, a pressure relay and the like; the other is a continuously variable analog input signal from potentiometers, thermo-electric, tacho motors, and transducers of various types. The input module also needs to convert these different level signals into digital signals that the CPU can receive and process. The output module is used for receiving the digital signal processed by the CPU and converting the digital signal into a signal which can be received by the site execution component, and is used for controlling a contactor, an electromagnetic valve, a regulating valve, a speed regulating device and the like, and the load at the other end of the control is an indicator light, a digital display, an alarm device and the like.
The existing communication protocol with one master and multiple slaves requires the slave station board card to be matched with related hardware identifiers, such as a dial switch and other devices; while matching the relevant software protocol stacks is required. The development difficulty and implementation complexity of designers are increased, both from a hardware and software design perspective. In a plurality of data communication modes, the serial communication principle is simple, the hardware resource cost is low, the programming space is small, and the serial communication method is very suitable for low-cost I/O module data communication. However, since serial communication itself cannot identify the slave station device, an additional identification algorithm and data communication protocol are required.
Disclosure of Invention
In order to realize data communication and slave station identification of an I/O module, the invention provides an I/O module slave station identification method and a data communication protocol based on serial communication by maximally utilizing the resources of the slave station and simplifying the communication protocol.
The technical scheme adopted by the invention for achieving the purpose is as follows:
a multi-slave communication protocol system, a master station and a plurality of slaves communicate based on a serial bus having a data transmission line TX and a data reception line RX, connecting the data reception lines RX of the plurality of slaves together and with the data transmission line TX of the master station; the data transmission lines TX of the plurality of slave stations are connected together and connected with the data receiving line RX of the master station so as to realize the data receiving and transmitting control of the master station to the plurality of slave stations.
The master station and the slave stations are both provided with GPIO modules, the output GPIO of the master station GPIO module is connected with the input GPIO of the adjacent slave station GPIO module through a data line, and the output GPIO of each slave station GPIO module is connected with the input GPIO of the adjacent slave station GPIO module through a data line.
And the master station and the slave station both adopt an STM32 singlechip as a master controller.
A multi-slave communication protocol method comprising the steps of:
1) The master station identifies the number of the slave stations through the physical addressing identification instruction and the physical addressing of each slave station;
2) Each slave station receives and responds to the physical addressing identification instruction sent by the master station, and further activates the slave station to communicate with the master station.
The master station performs the following steps:
an initialization stage: setting the state of a master station as an initial state, setting a GPIO module of the master station as an output mode, defining a global variable Slave_ID_Num, and recording the number of Slave stations for addressing identification;
and (3) an identification stage: the master station sends a physical addressing identification instruction to the slave station, the slave station can receive the physical addressing identification instruction only when the input GPIO is in an activated state, the addressed slave station returns a response frame to the master station after receiving the physical addressing identification instruction, and the master station indicates that the addressing is effective after receiving the response frame returned by the slave station, and the global variable is added one to continue the next addressing operation; in the set time, if the master station cannot receive the returned response frame of the slave station, confirming that the addressing identification process is finished, and switching the master station from an initial state to a data communication operation state;
master-slave data communication phase: the master station communicates data to all the identified slaves.
The secondary station performs the steps of:
an initialization stage: setting the state of the Slave station as an initial state, defining a global variable Slave_ID for recording the addressed number of the current Slave station;
and (3) a response stage: when the input GPIO is in an activated state, the slave station receives a physical addressing identification instruction sent by the master station, the slave station sends a coded return response frame to the master station, and when the slave station is identified by the master station, the output GPIO is set to be in an activated state, so that the next slave station is activated; the slave station is switched from an initial state to a data communication operation state and enters a master-slave data communication stage, and if the input GPIO state of the slave station is in an inactive state, the slave station continues to wait for addressing identification operation and cannot enter the data communication stage;
master-slave data communication phase: all the secondary stations in the data communication operation state are in data communication with the primary station.
In the initial state, the master station and the slave station can only perform physical addressing identification and cannot perform I/O data communication; in the data communication operation state, the master station and the slave station can perform I/O data communication.
The invention has the following beneficial effects and advantages:
the invention establishes a network topology structure of one master and multiple slaves aiming at an I/O module in industrial software based on serial port communication; aiming at the defect that the serial communication protocol cannot identify multi-slave station equipment, a multi-slave station physical addressing identification algorithm is designed according to the self structural resource of the slave station. The algorithm does not need any additional hardware cost, is stable and reliable, reduces the hardware design cost of the master station and the slave station, and reduces the software development difficulty. Aiming at the special data exchange type of the I/O module, a simplified and concise I/O module data communication protocol is designed, and a complex communication protocol stack is not needed; the CPU load rate is greatly reduced, and the memory space is reduced. Compared with other communication protocols, the whole system reduces hardware cost and software development complexity, and is more suitable for data communication of the I/O module.
Drawings
FIG. 1 is a diagram of a master multi-slave topology based on serial communication;
FIG. 2 is a flow chart of a master station physical addressing identification instruction;
fig. 3 is a diagram of a multi-secondary physical addressing identification algorithm.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples.
1. Serial port communication-based one-master-multiple-slave-object connection hardware scheme
As shown in fig. 1, a serial port (UART) is provided with two data lines, namely a data transmission line TX and a data reception line RX, respectively, which are schematic connection diagrams of network communication hardware of a master and multiple slaves based on serial port communication. As can be seen from fig. 1, the data reception lines RX of the plurality of secondary stations are connected together and to the data transmission line TX of the primary station; the data transmission lines TX of the plurality of secondary stations are connected together and to the data reception lines RX of the primary station. Through the physical connection, the data receiving and transmitting control of the host computer to the plurality of slaves is realized.
2. Multi-slave station physical addressing identification algorithm
Based on the physical structure of fig. 1, to realize the data transceiving control of the host to the slave, first, addressing information of each slave station needs to be determined, that is, each slave station should have its own unique identity. Because the design cancels external hardware devices such as a dial switch and the like, all the slave station devices connected on the serial port bus are identified and addressed only through a designed slave station identification software algorithm, the host can be ensured to identify the corresponding slave station identity information, and one-master multi-slave data communication control can be realized.
I/O module data communication protocol design
To reduce the complexity of software development and the program space overhead, a high-efficiency low-redundancy communication protocol is designed for the data exchange of the I/O module, and a secondary state machine is established; the master station and the plurality of slave stations are divided into an initial state (INITIALISING) and a data communication operation state (operation). In the two states, the communication application functions of the master and slave are different; in INITIALISING state, the master-slave machine can only perform physical addressing identification of the slave station and cannot perform I/O data communication; in the OPERATIONAL state, the master and slave can perform normal I/O data communication; both states have a progressive nature. After power-on reset, the master and slave are in INITIALISING state, and in INITIALISING state, the host addresses and identifies all slave stations connected to the serial bus according to the designed multi-slave physical addressing identification algorithm, and the identified effective slave is switched from INITIALISING state to OPERATIONAL state. When the host has completed physical addressing of all slaves, it will also switch to the OPERATIONAL state. When the master and slave are in the OPERATIONAL state, the master and slave can perform all function applications required by the I/O equipment.
1. Master station physical addressing identification instruction flow
The master station and the slave station all adopt STM32 series singlechip as a master controller, and the slave station physical addressing design is carried out by utilizing a GPIO module built in the STM32 and combining program variables. The master station controller configures a GPIO as an output mode; the master defines a global variable (slave_id_num) for recording the number of slaves addressed for identification. The master station initiates addressing identification and the flow is shown in figure 2.
As can be seen from fig. 2, the initial state of the master station is in INITIALISING state, the slave station sends an addressing command to the slave station, the slave station can only receive the addressing command when the input GPIO is in active state, the addressed slave station returns response frame data after receiving the correct addressing command, and the master station indicates that the addressing is valid at this time and continues the next addressing operation after receiving the return frame of the slave station; according to the overtime judgment algorithm, if the master station cannot receive the return frame of the slave station in the effective time, confirming that the addressing identification process is finished, and completing identification of the number of the slave stations and physical addressing determination of each slave station; at this time, the master station also switches from INITIALISING state to operation state, and enters the master-slave data communication phase.
2. Multi-slave station physical addressing identification algorithm
The slave stations all adopt STM32 series single-chip microcomputer as a main controller, two GPIO interfaces are selected from the slave stations, one is configured to input GPIO, and the other is configured to output GPIO. A global variable (slave_id) is defined in the Slave program for recording the number currently addressed by the Slave. The slave station receives the address identification instruction of the master station, and the flow chart is shown in figure 3.
After power-on reset, the slave station is also in INITIALISING state, when the input GPIO of the slave station is activated to be high level, the slave station can only receive the addressing instruction sent by the master station on the bus, and after correctly processing the addressing instruction of the master station, the slave station sends a coded return frame to the master station so as to respond to the addressing instruction of the master station. After the slave station is correctly recognized by the master station, setting the output GPIO to be high level, and activating the next slave station; and the secondary station will switch from INITIALISING state to OPERATIONAL state, entering the master-slave data communication phase. If the slave station's input GPIO state is detected to be low, the slave station will continue to wait for the address recognition operation and cannot enter the data communication phase.
The invention adopts the self resources of the master station and the slave station, and carries out networking on a communication network with one master station and multiple slaves on the basis of not adding any hardware devices.
Aiming at the defect that the slave station cannot be identified in serial port networking, a multi-slave station physical addressing identification algorithm is designed; the hardware design cost of the master station and the slave station is reduced, and meanwhile, the software development difficulty is also reduced. All the slave station devices connected on the serial port bus are identified and addressed only through a designed slave station identification software algorithm, so that the host can be ensured to identify corresponding slave station identity information, and one master and multiple slave data communication control can be realized.

Claims (7)

1. A multi-slave communication protocol system, wherein a master station and a plurality of slaves communicate based on a serial bus having a data transmission line TX and a data reception line RX, the data reception lines RX of the plurality of slaves being connected together and to the data transmission line TX of the master station; the data transmission lines TX of the plurality of slave stations are connected together and connected with the data receiving line RX of the master station so as to realize the data receiving and transmitting control of the master station to the plurality of slave stations.
2. A multi-slave communication protocol system according to claim 1 wherein the master and slave stations are each provided with a GPIO module, the output GPIO of the master station GPIO module being connected to the input GPIO of its adjacent slave station GPIO module by a data line, the output GPIO of each slave station GPIO module being connected to the input GPIO of its adjacent slave station GPIO module by a data line.
3. A multi-slave communication protocol system according to claim 1 wherein the master and slave each employ an STM32 single chip microcomputer as the master controller.
4. A multi-slave communication protocol method, comprising the steps of:
1) The master station identifies the number of the slave stations through the physical addressing identification instruction and the physical addressing of each slave station;
2) Each slave station receives and responds to the physical addressing identification instruction sent by the master station, and further activates the slave station to communicate with the master station.
5. The multi-slave communication protocol method according to claim 4, wherein the master station performs the steps of:
an initialization stage: setting the state of a master station as an initial state, setting a GPIO module of the master station as an output mode, defining a global variable Slave_ID_Num, and recording the number of Slave stations for addressing identification;
and (3) an identification stage: the master station sends a physical addressing identification instruction to the slave station, the slave station can receive the physical addressing identification instruction only when the input GPIO is in an activated state, the addressed slave station returns a response frame to the master station after receiving the physical addressing identification instruction, and the master station indicates that the addressing is effective after receiving the response frame returned by the slave station, and the global variable is added one to continue the next addressing operation; in the set time, if the master station cannot receive the returned response frame of the slave station, confirming that the addressing identification process is finished, and switching the master station from an initial state to a data communication operation state;
master-slave data communication phase: the master station communicates data to all the identified slaves.
6. The multi-slave communication protocol method according to claim 4, wherein the slave performs the steps of:
an initialization stage: setting the state of the Slave station as an initial state, defining a global variable Slave_ID for recording the addressed number of the current Slave station;
and (3) a response stage: when the input GPIO is in an activated state, the slave station receives a physical addressing identification instruction sent by the master station, the slave station sends a coded return response frame to the master station, and when the slave station is identified by the master station, the output GPIO is set to be in an activated state, so that the next slave station is activated; the slave station is switched from an initial state to a data communication operation state and enters a master-slave data communication stage, and if the input GPIO state of the slave station is in an inactive state, the slave station continues to wait for addressing identification operation and cannot enter the data communication stage;
master-slave data communication phase: all the secondary stations in the data communication operation state are in data communication with the primary station.
7. A multi-slave communication protocol method according to claim 5 or 6 wherein in the initial state, the master and slave stations can only perform physical addressing identification and cannot perform I/O data communication; in the data communication operation state, the master station and the slave station can perform I/O data communication.
CN202111577286.6A 2021-12-22 2021-12-22 Multi-slave station communication protocol method Pending CN116346523A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111577286.6A CN116346523A (en) 2021-12-22 2021-12-22 Multi-slave station communication protocol method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111577286.6A CN116346523A (en) 2021-12-22 2021-12-22 Multi-slave station communication protocol method

Publications (1)

Publication Number Publication Date
CN116346523A true CN116346523A (en) 2023-06-27

Family

ID=86879204

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111577286.6A Pending CN116346523A (en) 2021-12-22 2021-12-22 Multi-slave station communication protocol method

Country Status (1)

Country Link
CN (1) CN116346523A (en)

Similar Documents

Publication Publication Date Title
US6862643B2 (en) USB compound device operates a plurality of devices by using the same USB logic circuit and the method for implementation thereof
CN103248526A (en) Communication equipment and method for achieving out-of-band monitoring and management, and master-slave switching method
CN102023954A (en) Device with multiple I2C buses, processor, system main board and industrial controlled computer
CN112147927B (en) Multi-axis motion control system for two-channel bus communication
CN106657115B (en) Frequency converter control system and protocol conversion card thereof
CN102445981B (en) Data transmission system and data transmission method
CN102129228B (en) Monitoring system and configuration method thereof
CN210954663U (en) Cluster type lock control system
CN116346523A (en) Multi-slave station communication protocol method
CN111385169B (en) Master-slave question-answer polling communication method and system
CN116074397A (en) Data sharing system
CN201820120U (en) Self-adapting multibus execution mechanism controller
CN109873741B (en) System and working method of single-wire shared bus protocol
CN201773394U (en) Bus interface device of PROFIBUS
CN110224911B (en) Rapid communication method based on MODBUS-RS485 multi-path integrated system
CN114461554A (en) Redundant communication control system, redundant communication control method, and integrated device
CN110391823B (en) Communication circuit, control method thereof, and device having communication function
CN113726580A (en) 6U-VPX gigabit network module with dual-redundancy switching function for localization
CN113253652A (en) Unit communication control device, method and unit
CN111813732A (en) Multi-machine communication method based on serial port communication of single chip microcomputer
CN220603881U (en) Controller based on TSN and EtherCAT communication and application structure thereof
CN114785828B (en) Data communication method, special device, electric apparatus and storage medium
CN105656740A (en) RS422-CAN bus converter
CN219802593U (en) Wireless sensor and wireless sensor network system
CN220067457U (en) Sensor terminal node upgrading device applied to Modbus TCP network

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