CN114201424A - Communication method, system, computer equipment and storage medium based on RS485 bus - Google Patents

Communication method, system, computer equipment and storage medium based on RS485 bus Download PDF

Info

Publication number
CN114201424A
CN114201424A CN202111525587.4A CN202111525587A CN114201424A CN 114201424 A CN114201424 A CN 114201424A CN 202111525587 A CN202111525587 A CN 202111525587A CN 114201424 A CN114201424 A CN 114201424A
Authority
CN
China
Prior art keywords
station
slave station
response message
address
current
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
CN202111525587.4A
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.)
Chongqing Delxing Measurement And Control Technology Research Institute Co ltd
Original Assignee
Chongqing Delxing Measurement And Control Technology 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 Chongqing Delxing Measurement And Control Technology Research Institute Co ltd filed Critical Chongqing Delxing Measurement And Control Technology Research Institute Co ltd
Priority to CN202111525587.4A priority Critical patent/CN114201424A/en
Publication of CN114201424A publication Critical patent/CN114201424A/en
Pending legal-status Critical Current

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/14Handling requests for interconnection or transfer
    • G06F13/16Handling requests for interconnection or transfer for access to memory bus
    • G06F13/1605Handling requests for interconnection or transfer for access to memory bus based on arbitration
    • G06F13/161Handling requests for interconnection or transfer for access to memory bus based on arbitration with latency improvement
    • G06F13/1621Handling requests for interconnection or transfer for access to memory bus based on arbitration with latency improvement by maintaining request order
    • 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
    • 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/0064Latency reduction in handling transfers

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention provides a communication method, a system, computer equipment and a storage medium based on an RS485 bus, wherein the method comprises the following steps: generating an address association table according to the address identifiers of the master station and all the slave stations; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; if the current slave station receives a response message sent by an associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus; the problem of data loss or abnormal communication in the prior art is solved, the slave station nodes are sequentially communicated and responded, communication interaction frequency is reduced, data conflict is avoided, and communication efficiency and reliability of an RS485 bus are improved.

Description

Communication method, system, computer equipment and storage medium based on RS485 bus
Technical Field
The invention relates to the technical field of communication, in particular to a communication method, a communication system, computer equipment and a storage medium based on an RS485 bus.
Background
With the development of automatic production lines, intelligent manufacturing, digital factories and the like, universal controllers are applied more and more widely, more and more modules for sampling and controlling signals need to be connected with the controllers, and higher requirements are put forward on the expandability and communication rate of the controllers. The RS-485 bus as a differential bus of a two-wire system has the characteristics of multi-node support, long communication distance and strong anti-interference performance, and the bus network topology generally adopts a bus type structure with matched terminals. Meanwhile, the RS485 communication generally adopts a half-duplex mode, and the bus can only process one-time communication at the same time. When a station requests data, the bus is occupied, other stations cannot request data (namely cannot apply for the bus to trigger new services), and if the other stations request or respond to the data, the bus is abnormal, communication data are disordered, and normal data communication cannot be performed.
Therefore, in the prior art, the communication method based on the RS485 bus has the problems of data loss or abnormal communication, and the reliability of communication cannot be guaranteed.
Disclosure of Invention
Aiming at the defects in the prior art, the communication method, the communication system, the computer equipment and the storage medium based on the RS485 bus solve the problem of data loss or abnormal communication in the prior art, realize the sequential communication response of the slave station nodes, reduce the communication interaction frequency, avoid data collision and improve the communication efficiency and reliability of the RS485 bus.
In a first aspect, the present invention provides a communication method based on an RS485 bus, applied to a communication system based on an RS485 bus, where the communication system includes a master station and a plurality of slave stations, and the master station and each slave station are connected through the RS485 bus, and the method includes: generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
Optionally, generating an address association table according to the address identifiers of the master station and all the slave stations, including: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; according to the size of the numerical identifier, taking a first target slave station smaller than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table; and the numerical identifier of the first target slave station is the maximum value of all numerical identifiers smaller than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the smallest numerical identifier.
Optionally, generating an address association table according to the address identifiers of the master station and all the slave stations, including: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; according to the size of the numerical identifier, taking a first target slave station which is larger than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table; and the numerical identifier of the first target slave station is the minimum value of all numerical identifiers larger than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the largest numerical identifier.
Optionally, if the associated station of the current slave station is the master station and the current slave station receives the broadcast data sent by the master station, the method further includes: the current slave station judges that a response message needs to be sent, and then the current slave station sends the target response message, so that a second target slave station sends a corresponding response message according to an address identifier in the target response message; and the associated station of the second target slave station is the current slave station.
Optionally, when the current slave station transmits the request data to the master station, the method further includes: the current slave station judges whether a response message sent by the master station is received in a preset time period; if the current slave station does not receive the response message sent by the master station in a preset time period, the current slave station obtains the delay time length of the current slave station according to the address identifier of the current slave station; and the current slave station obtains the next sending time according to the sending time of the request data and the delay time length, so that the current slave station repeatedly sends the request data at the next sending time.
Optionally, the obtaining, by the current slave station, the delay time length of the current slave station according to the address identifier of the current slave station includes: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; obtaining the weight of the current slave station according to the numerical identifiers of the current slave station and the numerical identifiers of all the slave stations; and calculating the delay time length of the current slave station according to the weight of the current slave station and the numerical identifier of the current slave station.
Optionally, after generating the address association table according to the address identifiers of the master station and all the slave stations, the method further includes: the current slave station receives the request data sent by the master station; and if the target address identification in the request data is consistent with the address identification of the current slave station, the current slave station sends response data corresponding to the request data.
In a second aspect, the present invention provides a communication system based on RS485 bus, the system comprising: the master station is connected with each slave station through an RS485 bus; the master station is used for generating an address association table according to the address identifiers of the master station and all the slave stations, and the address association table comprises the address identifier of each slave station and the associated station of each slave station; each slave station is used for judging whether a response message needs to be sent currently or not when receiving the broadcast data sent by the master station; each slave station is also used for judging whether the response message sent by the associated station is received or not when judging that the response message does not need to be sent currently; each slave station is further configured to send a target response message if receiving a response message sent by an associated station, so that the master station receives the target response message through the RS485 bus.
In a third aspect, the present invention provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
In a fourth aspect, the present invention provides a readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of: generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
Compared with the prior art, the invention has the beneficial effects that:
according to the invention, the address association table is generated through the address identifiers of the master station and the slave station, so that each slave station judges whether response data needs to be sent currently or not through the currently received broadcast data or response message and the association station in the address association table, and the slave station nodes sequentially perform communication response, thereby not only reducing communication interaction frequency, but also avoiding data collision, solving the problem of data loss or communication abnormity in the prior art, and improving the communication efficiency and reliability of the RS485 bus.
Drawings
Fig. 1 is a schematic flowchart illustrating a communication method based on an RS485 bus according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a communication system based on an RS485 bus according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a primary station transmitting broadcast data according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a slave station sending a response packet according to an embodiment of the present invention;
fig. 5 is a schematic flow chart of another communication method based on an RS485 bus according to an embodiment of the present invention;
fig. 6 is a schematic diagram illustrating a plurality of secondary stations simultaneously requesting data according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 1 is a schematic flowchart illustrating a communication method based on an RS485 bus according to an embodiment of the present invention; as shown in fig. 1, the communication method applied to the RS485 bus-based communication system includes a master station and a plurality of slave stations, where the master station and each slave station are connected through the RS485 bus, and the communication method based on the RS485 bus specifically includes the following steps:
and S101, generating an address association table according to the address identifications of the master station and all the slave stations.
In this embodiment, generating an address association table according to the address identifiers of the master station and all the slave stations includes: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; according to the size of the numerical identifier, taking a first target slave station smaller than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table; and the numerical identifier of the first target slave station is the maximum value of all numerical identifiers smaller than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the smallest numerical identifier.
Optionally, generating an address association table according to the address identifiers of the master station and all the slave stations, including: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; according to the size of the numerical identifier, taking a first target slave station which is larger than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table; and the numerical identifier of the first target slave station is the minimum value of all numerical identifiers larger than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the largest numerical identifier.
It should be noted that, as shown in fig. 2, the communication system based on the RS485 bus includes a master station and a plurality of slave stations, both the master station and the plurality of slave stations are connected to the RS485 bus, and when the master station transmits a broadcast message, the slave stations sequentially respond to the broadcast message through a control line; the master station connects all the slave stations in series through an RS485 bus, and the connection usually adopts a two-wire connection mode which is a bus type topological structure, and at most 32 nodes can be connected to the same bus in an attached mode.
The electrical characteristic of the RS485 is that logic '1' is represented by voltage difference between two lines + 2V- +6V, and logic '0' is represented by voltage difference between two lines-6V-2V, so that when signals are transmitted on a bus, all other stations can receive data; as shown in fig. 3 and 4, when the master station sends out request data or broadcast data, the slave station 1, the slave station 2, and the slave station N can receive the broadcast data, and similarly, when the slave station 1 requests data, broadcast data, or response message, other slave stations including the master station can also receive the same data.
In this embodiment, both the master station and the slave station have unique address identifiers for distinguishing the main bodies of message communication; after converting the address identifiers of all the slave stations into numerical values, according to the numerical value, taking the slave station with the numerical identifier smaller than that of the current slave station as the associated station of the current slave station, and taking the master station as the associated station of the slave station with the smallest numerical identifier, so as to obtain an address association table as shown in the following table:
site name Address identification Association station
Master station 03
Slave station 1 21 Master station
Slave station 2 22 Slave station 1
Slave station 3 23 Slave station 2
Slave station 4 24 Slave station 3
In another embodiment of the present invention, a slave station with a numerical identifier larger than that of the current slave station may be used as the associated station of the current slave station, and the master station may be used as the associated station of the slave station with the largest numerical identifier, so that the obtained address association table is shown in the following table:
site name Address identification Association station
Master station 03
Slave station 4 24 Master station
Slave station 3 23 Slave station 4
Slave station 2 22 Slave station 3
Slave station 1 21 Slave station 2
In this embodiment, the address association table is saved to each station by a control line or bus command.
And step S102, when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently.
In this embodiment, the master station constructs a broadcast message and broadcasts the broadcast message to each slave station through an RS485 bus, and the broadcast request message of the master station is shown in fig. 3; each slave station judges whether a response message needs to be sent or not according to an associated station in an address associated table, if the associated station of the current slave station is the master station and the current slave station judges that the response message needs to be sent when receiving the broadcast data sent by the master station, the current slave station sends the target response message, so that a second target slave station sends a corresponding response message according to an address identifier in the target response message; and the associated station of the second target slave station is the current slave station.
Step S103, if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received.
In this embodiment, if the associated station of the current slave station is not the master station, it is determined that the current slave station does not need to send a response message, so as to wait for response messages sent by other slave stations, and determine whether the current slave station is sent by the associated station according to an address identifier in the received response message.
And step S104, if the current slave station receives the response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
In this embodiment, if the response message currently received by the slave station 3 is sent by the slave station 1, and the associated station of the slave station 3 is the slave station 2, the slave station 3 discards the currently received response message and does not respond; if the response message currently received by the slave station 3 is sent by the slave station 2, the slave station 3 sends a target response message, so that the master station receives the target response message sent by the slave station 3 through the RS485 bus, and the slave station 4 sends a corresponding response message after receiving the target response message; and by analogy, each slave station completes the response of the broadcast data in turn according to the address association table, and when the master station receives the response message of the slave station with the largest address, the communication process of the broadcast data is ended.
Compared with the prior art, the invention has the beneficial effects that:
according to the invention, the address association table is generated through the address identifiers of the master station and the slave station, so that each slave station judges whether response data needs to be sent currently or not through the currently received broadcast data or response message and the association station in the address association table, and the slave station nodes sequentially perform communication response, thereby not only reducing communication interaction frequency, but also avoiding data collision, solving the problem of data loss or communication abnormity in the prior art, and improving the communication efficiency and reliability of the RS485 bus.
Fig. 5 is a schematic flow chart of another communication method based on an RS485 bus according to an embodiment of the present invention, and as shown in fig. 5, the communication method further includes the following steps:
step S201, when a current slave station sends request data to a master station, the current slave station judges whether a response message sent by the master station is received in a preset time period;
step S202, if the current slave station does not receive the response message sent by the master station in a preset time period, the current slave station obtains the delay time length of the current slave station according to the address identifier of the current slave station;
and step S203, the current slave station obtains the next sending time according to the sending time of the request data and the delay time length, so that the current slave station repeatedly sends the request data at the next sending time.
When a plurality of slave stations simultaneously transmit request data, as shown in fig. 6, when the slave station 1 and the slave station 2 simultaneously request data, the message is discarded if the other station receives an abnormal data, and further, the slave station 1 and the slave station 2 cannot receive response data, and a message retry mechanism needs to be started.
In this embodiment, since the address identifier of each slave station is unique, the calculated delay time is also unique; the method for acquiring the delay time length of the current slave station by the current slave station according to the address identifier of the current slave station comprises the following steps: converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations; obtaining the weight of the current slave station according to the numerical identifiers of the current slave station and the numerical identifiers of all the slave stations; and calculating the delay time length of the current slave station according to the weight of the current slave station and the numerical identifier of the current slave station.
In this embodiment, the current station transmits the request data after delaying the transmission time of the previous request data by a corresponding time length, for example, the station 1 retries the request message after delaying the time length 1, and the station 2 retries the message after delaying the time length 2, so that the collision of the contention bus is not generated, and the complete processing of the message is ensured.
In this embodiment, after generating the address association table according to the address identifiers of the master station and all the slave stations, the method further includes: the current slave station receives the request data sent by the master station; and if the target address identification in the request data is consistent with the address identification of the current slave station, the current slave station sends response data corresponding to the request data.
In one embodiment, the present invention provides an RS485 bus based communication system, the system comprising: the master station is connected with each slave station through an RS485 bus; the master station is used for generating an address association table according to the address identifiers of the master station and all the slave stations, and the address association table comprises the address identifier of each slave station and the associated station of each slave station; each slave station is used for judging whether a response message needs to be sent currently or not when receiving the broadcast data sent by the master station; each slave station is also used for judging whether the response message sent by the associated station is received or not when judging that the response message does not need to be sent currently; each slave station is further configured to send a target response message if receiving a response message sent by an associated station, so that the master station receives the target response message through the RS485 bus.
In one embodiment, the invention provides a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
In one embodiment, the invention provides a readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of: generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station; when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently; if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received; and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A communication method based on an RS485 bus is applied to a communication system based on the RS485 bus, the communication system comprises a master station and a plurality of slave stations, the master station and each slave station are connected through the RS485 bus, and the method comprises the following steps:
generating an address association table according to the address identifications of the master station and all the slave stations, wherein the address association table comprises the address identification of each slave station and the association station of each slave station;
when each slave station receives the broadcast data sent by the master station, judging whether a response message needs to be sent currently;
if the current slave station judges that the response message does not need to be sent currently, the current slave station judges whether the response message sent by the associated station is received;
and if the current slave station receives a response message sent by the associated station, the current slave station sends a target response message, so that the master station receives the target response message sent by the current slave station through the RS485 bus.
2. The RS485 bus based communication method of claim 1, wherein generating the address association table according to the address identifications of the master station and all slave stations comprises:
converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations;
according to the size of the numerical identifier, taking a first target slave station smaller than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table;
and the numerical identifier of the first target slave station is the maximum value of all numerical identifiers smaller than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the smallest numerical identifier.
3. The RS485 bus based communication method of claim 1, wherein generating the address association table according to the address identifications of the master station and all slave stations comprises:
converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations;
according to the size of the numerical identifier, taking a first target slave station which is larger than the numerical identifier of the current slave station as an associated station of the current slave station to obtain the address associated table;
and the numerical identifier of the first target slave station is the minimum value of all numerical identifiers larger than the numerical identifier of the current slave station, and the master station is taken as the associated station of the slave station with the largest numerical identifier.
4. The RS485 bus based communication method of claim 2 or 3, wherein if the station associated with the current slave station is the master station and the current slave station receives the broadcast data transmitted by the master station, the method further comprises:
the current slave station judges that a response message needs to be sent, and then the current slave station sends the target response message, so that a second target slave station sends a corresponding response message according to an address identifier in the target response message;
and the associated station of the second target slave station is the current slave station.
5. The RS485 bus based communication method of claim 1, wherein when a current slave station transmits a request data to the master station, the method further comprises:
the current slave station judges whether a response message sent by the master station is received in a preset time period;
if the current slave station does not receive the response message sent by the master station in a preset time period, the current slave station obtains the delay time length of the current slave station according to the address identifier of the current slave station;
and the current slave station obtains the next sending time according to the sending time of the request data and the delay time length, so that the current slave station repeatedly sends the request data at the next sending time.
6. The RS485 bus-based communication method of claim 5, wherein the acquiring, by the current slave station, the delay time duration of the current slave station according to the address identifier of the current slave station comprises:
converting the address identifiers of all the slave stations into numerical types to obtain the numerical identifiers of all the slave stations;
obtaining the weight of the current slave station according to the numerical identifiers of the current slave station and the numerical identifiers of all the slave stations;
and calculating the delay time length of the current slave station according to the weight of the current slave station and the numerical identifier of the current slave station.
7. The RS485 bus based communication method of claim 1, wherein after generating the address association table based on the address identifications of the master station and all slave stations, the method further comprises:
the current slave station receives the request data sent by the master station;
and if the target address identification in the request data is consistent with the address identification of the current slave station, the current slave station sends response data corresponding to the request data.
8. A communication system based on an RS485 bus, the system comprising:
the master station is connected with each slave station through an RS485 bus;
the master station is used for generating an address association table according to the address identifiers of the master station and all the slave stations, and the address association table comprises the address identifier of each slave station and the associated station of each slave station;
each slave station is used for judging whether a response message needs to be sent currently or not when receiving the broadcast data sent by the master station;
each slave station is also used for judging whether the response message sent by the associated station is received or not when judging that the response message does not need to be sent currently; each slave station is further configured to send a target response message if receiving a response message sent by an associated station, so that the master station receives the target response message through the RS485 bus.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 7 are implemented by the processor when executing the computer program.
10. A readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202111525587.4A 2021-12-14 2021-12-14 Communication method, system, computer equipment and storage medium based on RS485 bus Pending CN114201424A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111525587.4A CN114201424A (en) 2021-12-14 2021-12-14 Communication method, system, computer equipment and storage medium based on RS485 bus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111525587.4A CN114201424A (en) 2021-12-14 2021-12-14 Communication method, system, computer equipment and storage medium based on RS485 bus

Publications (1)

Publication Number Publication Date
CN114201424A true CN114201424A (en) 2022-03-18

Family

ID=80653537

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111525587.4A Pending CN114201424A (en) 2021-12-14 2021-12-14 Communication method, system, computer equipment and storage medium based on RS485 bus

Country Status (1)

Country Link
CN (1) CN114201424A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114800492A (en) * 2022-04-11 2022-07-29 深圳市大族机器人有限公司 Method, system, computer device and storage medium for controlling slave station terminal

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114800492A (en) * 2022-04-11 2022-07-29 深圳市大族机器人有限公司 Method, system, computer device and storage medium for controlling slave station terminal

Similar Documents

Publication Publication Date Title
US10952143B2 (en) Sleeping and wake-up methods and apparatuses of master-slave network, and power saving system of master-slave network
WO2018218976A1 (en) Message sending method, apparatus and device
CN114201424A (en) Communication method, system, computer equipment and storage medium based on RS485 bus
CN103716420A (en) Automatic station address obtaining method of Modbus ASCII slave station and slave station
EP3244665B1 (en) Power control method and device
US8443110B2 (en) Approach for discovering devices on a common bus without direct communication
CN103856578A (en) Automatic slave station address acquisition method through Modbus RTU and slave station
CN111683354A (en) One-master multi-slave event scheduling method and device in low-power-consumption Bluetooth connection
CN106302032A (en) A kind of point-to-multipoint poll means of communication
CN108684030B (en) Method and device for detecting network identification conflict
CN113411868A (en) Interphone networking method and device, computer equipment and storage medium
CN112073276B (en) Power Internet of things communication method and system based on intelligent socket
CN112911520B (en) Method, device and storage medium for determining master node in ad hoc network
CN110493338B (en) Equipment mutual control method, system and computer readable storage medium
US20190132238A1 (en) Data transmission method, device, and system
CN116015419A (en) Unmanned aerial vehicle ad hoc network device and method based on relative positions
CN113473620A (en) Dynamic time slot allocation method, device, computer equipment and readable storage medium
CN115426393A (en) Method and device for realizing wireless control information interaction
CN115134354A (en) Method for rapidly upgrading by using TDMA time slot
EP3496363A1 (en) Devices and methods for data propagation in a distributed network
CN117177101B (en) CCO state processing method and system based on ammeter reading system
CN110138683B (en) QoS-supported Internet of things data transmission method and system
CN116033365B (en) Communication method, device, electronic equipment and storage medium
CN117156598B (en) Communication link setting method and system of 5G MIMO frequency shift system
CN115442182B (en) Polling method, device, equipment and storage medium

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