Master-slave communication method for conveyor based on POWERBUS
By adopting the POWERBUS-based master-slave communication method for conveyors in the field of integrated belt drive protection, combined with broadcast and polling communication mechanisms, the problems of high hardware cost, poor anti-interference capability and slow alarm response speed in the prior art are solved, and a cheaper and more reliable hardware solution and faster alarm response speed are achieved.
Patent Information
- Application Number
- CN202510241070.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-05-30
AI Technical Summary
The long-distance communication in the field of integrated protection of the existing belt drives uses the RS485-based communication protocol, resulting in high hardware wiring costs, poor anti-interference capabilities, and slow alarm response speed.
Using the POWERBUS-based conveyor using the master-slave communication method, through the communication mechanism combining broadcasting and polling between the master and slave stations, all slaves are mounted to the same bus through POWERBUS technology. When the master station sends instructions, all slaves receive them at the same time, and form a small loop through the broadcasting and polling links. The generated alarm is uploaded to the master station in each small loop.
It reduces the hardware cost of long-distance communication, improves the alarm response speed, and ensures the correctness and real-timeness of alarm information under extreme conditions.
Smart Images

Figure CN120074976A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of master-slave communication applications, and particularly relates to a master-slave communication method for a conveyor based on POWERBUS. Background Art
[0002] At present, in the field of comprehensive protection of belt conveyors for realizing long-distance communication, a communication protocol based on RS485 is usually used, and the polling method is used to detect slave station alarms. The response speed is slow, the hardware wiring cost is high, and the anti-interference ability is poor. Therefore, it is an urgent problem to be solved at present to find a cheaper and more reliable hardware technical solution and design a new communication protocol to improve the alarm response speed. Summary of the Invention
[0003] The technical problem to be solved by the present invention is: to provide a master-slave communication method for a conveyor based on POWERBUS, which can reduce the hardware cost of long-distance communication and effectively improve the alarm response speed.
[0004] To solve the above technical problem, the technical solution of the present invention is:
[0005] A master-slave communication method for a conveyor based on POWERBUS, including a master station and several slave stations. The master station and the slave stations communicate with each other by using two data frame transmission formats, namely broadcast and polling. All the slave stations are mounted on the same bus through POWERBUS technology. When the master station sends an instruction, all the slave stations receive it simultaneously.
[0006] The broadcast transmission format is: the master station sends a broadcast instruction. After receiving the broadcast instruction, the slave station detects it as a broadcast instruction and judges whether an external alarm is triggered. If the alarm is triggered, a preemption instruction is replied; if there is no alarm, no reply is made.
[0007] The polling transmission format is: the master station sends a polling instruction, and different polling instructions respectively correspond to the addresses of each slave station. After receiving the polling instruction, the slave station judges whether the polling instruction is the same as its own address. If it is the same, a non-preemption instruction is replied; if it is different, no reply is made.
[0008] Further, the broadcast link and the polling link form a small loop, and the generated alarm will be uploaded to the master station within each small loop; when the first small loop ends, the second small loop is immediately carried out. At this time, the polling instruction sent by the master station is changed to the address of another slave station until the small loops corresponding to all the slave stations are completed. At this time, all the small loops form a large loop, and after each large loop is executed once, the large loop is immediately restarted.
[0009] Further, in the master station broadcast process, if no response is received after the master station broadcasts for 13 ms, the timeout is skipped.
[0010] Further, in the polling process, the instruction data replied by the slave station is consistent with its own address. The master station compares the received data with the sent polling instruction. If they are the same, the current polling process ends. If they are different, a communication error indication is output and the current polling process ends.
[0011] Further, the slave station includes a slave station single-chip microcomputer and a slave station communication chip. The slave station single-chip microcomputer controls whether the instruction sent by the slave station communication chip is in the preemptive format through the level of an IO pin.
[0012] Further, when the number of slave stations does not exceed 255, the data frame sent by the master station is set to one byte
[0013] Further, the master station single-chip microcomputer and the master station communication chip, as well as the slave station single-chip microcomputer and the slave station communication chip, are respectively connected through USART transceiver modules, and the communication baud rate is 9600 bps.
[0014] Further, when the number of slave stations exceeds 255, the data frame sent by the master station is set to two bytes.
[0015] Further, the master station and the slave station are connected in a non-polar two-bus form, and data is transmitted in the way of serial port transparent transmission. The slave station receives the master station's instruction through serial port interruption and sends data in the interrupt callback function.
[0016] After adopting the above technical solutions, the beneficial effects of the present invention are:
[0017] In the master-slave communication method for conveyors based on POWERBUS disclosed by the present invention, based on the POWERBUS hardware solution, it can reduce the hardware cost of long-distance communication, especially in the field of belt conveyor comprehensive protection. Moreover, a communication mechanism combining broadcast and polling is adopted between the master station and the slave station, and the alarm response speed is faster than that of the traditional polling mechanism.
[0018] In the present invention, in the broadcast process, the conclusion that the master station ends this process after a 13 ms delay is obtained through actual tests, fully considering the actual application situation. Under the condition of meeting the application requirements, the fastest alarm response speed is achieved, and at the same time, it is ensured that the alarm information will not be incorrect under extreme conditions.
[0019] In the present invention, the master station will compare the received and sent data, with the function of detecting whether it is normal. Each small loop will detect, and at the macroscopic level, the accuracy of the sent and received data can be detected in real time.
[0020] In the present invention, the reply preemption instruction is controlled by a pin. When the data length is set to 1 byte and the serial communication baud rate is 9600 bps, continuous alarms can be sent as long as the alarm time interval between two slave stations is greater than 20 ms. According to the actual application in the belt conveyor field, this time interval fully meets the application requirements. And usually, when one alarm system appears, the machine will stop. In theory, multiple alarms are not allowed. Even if multiple alarms appear and the time interval is within 20 ms, due to the use of the preemption function, the alarm with a lower address will be sent preferentially, and there will be no situation of disordered uploaded data, ensuring the correctness of communication.
[0021] In the present invention, the data reception of the slave station is triggered in the form of an interruption, and data is sent in the interruption callback function, which can minimize the communication response time and reduce the overall time delay. Brief Description of the Drawings
[0022] Figure 1 It is a schematic flowchart of the master and slave stations in the broadcast link of the master-slave communication method of the present invention;
[0023] Figure 2 It is a schematic flowchart of the master and slave stations in the polling link of the master-slave communication method of the present invention. Detailed Embodiments
[0024] The present invention will be further described below in conjunction with the drawings and embodiments. The preferred embodiments of the present invention are shown in the drawings. The function of the drawings is to supplement the description of the text part of the specification, enabling people to intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it cannot be understood as a limitation on the protection scope of the present invention.
[0025] A master-slave communication method for a conveyor based on POWERBUS includes a master station and several slave stations. The master station is composed of a master station single-chip microcomputer stm32f103c8t6 and a master station communication chip PB621. The slave station is composed of a slave station single-chip microcomputer stm32f030k6t6 and a slave station communication chip PB332. The master station communication chip PB621 and the slave station communication chip PB332 are a set of chips with preemption functions. Whether the instruction sent by the slave station communication chip PB332 is in the preemption format can be controlled by the level of an IO pin of the slave station single-chip microcomputer stm32f030k6t6.
[0026] The master station and slave stations communicate using two data frame transmission formats, broadcast and polling. All slave stations are mounted on the same bus through POWERBUS technology. When the master station sends an instruction, all slave stations receive it simultaneously. After receiving the instruction, the slave stations reply with corresponding instructions according to the alarm requirements. Specifically, the master station and slave stations are connected in the form of a non-polarized two-wire bus and transmit data in the way of serial port transparent transmission. The slave stations receive the instructions from the master station through serial port interrupts and send data in the interrupt callback function.
[0027] The master station microcontroller and the master station communication chip, as well as the slave station microcontroller and the slave station communication chip, are respectively connected through USART transceiver modules. The communication baud rates can be selected from 2400bps and 9600bps. 9600bps is selected as the upper limit communication rate of POWERBUS. The programs of the master station microcontroller stm32f103c8t6 and the slave station microcontroller stm32f030k6t6 are written based on 9600bps.
[0028] As Figure 1 and Figure 2 As shown jointly, the broadcast transmission format is: the master station sends a broadcast instruction. After receiving the broadcast instruction, the slave station detects it as a broadcast instruction and judges whether the external alarm is triggered. If the alarm is triggered, it replies with a preemption instruction, which includes two kinds of information, address information and alarm status information. If there is no alarm, it does not reply.
[0029] The polling transmission format is: the master station sends a polling instruction, and different polling instructions respectively correspond to the addresses of each slave station. After receiving the polling instruction, the slave station judges whether the polling instruction is the same as its own address. If it is the same, it replies with a non-preemption instruction. If it is different, it does not reply.
[0030] To improve the alarm response speed, the broadcast link and the polling link form a small loop, and the generated alarms will be uploaded to the master station within each small loop; immediately after the first small loop ends, the second small loop is carried out. At this time, the polling instruction sent by the master station changes to the address of another slave station until all the small loops corresponding to all slave stations are completed. At this time, all the small loops form a large loop, and the large loop starts to execute again immediately after each execution.
[0031] In the broadcast link, if the master station does not receive a reply after broadcasting for 13ms, it will skip the timeout. The 13ms delay is the conclusion drawn through actual tests. By continuously adjusting the delay time and detecting the waveforms of the received and transmitted signals, it is concluded that a delay less than 13ms will cause garbled codes, and the system response speed has reached the level limited by the hardware.
[0032] In the polling session, the command data replied by the slave station is the same as its own address. The master station compares the received data with the sent polling command. If they are the same, the current polling session ends. If they are different, a communication error indication is output and the current polling session ends.
[0033] Depending on the different numbers of slave stations required, the data length of the data frame sent by the master station may also be different. When the data frame is set to 1 byte, the maximum number of slave stations is 255. When it is set to 2 bytes, the maximum theoretical number of connected slave stations at this time is 2 to the 16th power minus one, that is, 65,535. That is, when the number of slave stations does not exceed 255, the data frame sent by the master station is set to 1 byte; when the number of slave stations exceeds 255, the data frame sent by the master station is set to 2 bytes. Its working principle remains the same and can be achieved by adjusting the code. However, compared with when the data frame only contains 1 byte, the time for each loop will double accordingly.
[0034] The following takes the data frame set to 1 byte as an example to describe the specific implementation steps of the master-slave communication method of the present invention:
[0035] (1) Set the master station to send a data frame, which only contains 1 byte, based on serial communication, 1 start bit, 8 data bits, and 1 stop bit; the master station data frame is divided into two types. The first type only contains 0x00 as a broadcast command, and the second type contains 255 commands from 0x01 to 0xFF as polling commands;
[0036] (2) Set the slave station to send a data frame. Each slave station corresponds to only one data frame. The slave station's reply commands have two formats. The first is the preemptive format, and the second is the non-preemptive format. The difference is that the slave station controls whether to send a preemptive signal through the single-chip microcomputer IO PB332. The command replied by each slave station is the same as its own address. For example, the reply command of the second slave station is 0x02. The preemptive command includes two types of information, address information and alarm status information;
[0037] (3) Set the master-slave station data receiving arrays to temporarily store the received data;
[0038] (4) The master station sends the first broadcast command 0x00. All slave stations are mounted to the same bus through the POWERBUS hardware solution. At this time, all slave stations will receive the broadcast command;
[0039] (5) The slave station receives the master station command through the serial port interrupt, detects it as a broadcast command and judges whether the external alarm is triggered. If the alarm is triggered, it replies with the preemptive command data content as its own address. If there is no alarm, it does not send;
[0040] (6) If the master station receives the preemptive command replied by the slave station after the broadcast, it outputs an alarm indication. If there is no reply after waiting for 13 ms, it skips due to timeout;
[0041] (7) The master station sends the first polling instruction 0x01;
[0042] (8) All slave stations receive the polling instruction through the serial port interrupt, and judge whether the instruction is the same as its own address. If it is the same, then reply with the non-preemption instruction data content as its own address. At this time, the No. 1 slave station replies, and other slave stations do not reply;
[0043] (9) The master station receives the replied non-preemption instruction, and judges whether it is the same as the sent polling instruction content. If it is the same, the communication is normal and skipped. If it is different, an error indication is output;
[0044] (10) Then, the second broadcast instruction 0x00 and the second polling instruction 0x02 are sent in sequence. The slave stations with alarms reply with the preemption instruction or the non-preemption instruction corresponding to their own addresses, and those without alarms do not reply; Repeat the master-slave broadcast, polling, sending and receiving responses, and the polling address increases sequentially until the final address, and then start over.
[0045] In the above steps, the implementation steps of the master station single-chip microcomputer based on the hal library are as follows:
[0046] ① Define a polling instruction array with 255 elements in total, and assign values to the elements through a loop structure, from 0x01 to 0xFF.
[0047] ② Define a broadcast instruction array whose elements only include 0x00.
[0048] ③ Define a broadcast reply instruction array containing one element.
[0049] ④ In the main loop while, use a for loop structure. The loop self-increment i is initialized to 0, and the loop end condition is i > 254: Inside the for loop structure, initialize the broadcast reply instruction array; Send the broadcast instruction until the current data sending is completed; Wait to receive the slave station broadcast reply instruction and skip if it times out after 13ms; Judge whether the element in the broadcast reply instruction is the initial value. If it is not the initial value, it means an alarm is received and an alarm signal is output, otherwise skip; Send the first polling instruction until the current data sending is completed; Finish receiving the polling response instruction; Judge whether the received polling instruction is the same as the sent polling. If it is the same, the operation is normal. If it is different, the communication goes wrong and an error signal is output; Loop self-increment i + 1; Run the second for loop, the polling instruction data value is incremented by one, and the others remain unchanged; Run until the last loop, and the for loop ends and jumps out; Repeat the main loop while.
[0050] The implementation steps of the slave station single-chip microcomputer based on the hal library are as follows:
[0051] ① Define a received data array, which contains one element for storing the received instruction.
[0052] ② Define its own address, with a data length of one byte.
[0053] ③ Define the alarm trigger function and return the alarm flag bit.
[0054] ④ Modify the serial port interrupt callback function: when receiving data, trigger an interrupt, call the alarm trigger function, determine whether the received data is a master station broadcast instruction and check the alarm flag bit. If the received instruction is a broadcast instruction and the alarm flag bit is triggered, pull up the gpio port used to connect to the PB332 preemption control pin, send its own address, and after waiting for the data to be sent, pull down the gpio port used to connect to the PB332 preemption control pin. The instruction sent by this function is a preemption reply instruction.
[0055] ⑤ The main program calls the serial port interrupt reception function and stores the received data in an array.
[0056] The master-slave communication method for conveyors based on POWERBUS of the present invention is based on the POWERBUS hardware solution, which can reduce the hardware cost of long-distance communication. It communicates through a communication method combining broadcast and polling between the master station and the slave station. The alarm response speed is fast, and it only takes a few to more than ten milliseconds to realize the alarm being sent back to the master station, and the slowest is about 13 ms, achieving the fastest alarm response speed, and at the same time ensuring that the alarm information will not be incorrect under extreme conditions.
[0057] The above embodiments are only used to illustrate the present invention. The implementation forms of each step can be changed. Based on the technical solution of the present invention, any improvements and equivalent changes made to individual steps according to the principle of the present invention should not be excluded from the protection scope of the present invention.
Claims
1. A master-slave communication method for a conveyor based on POWERBUS, characterized in that: It includes a master station and multiple slave stations. The master station and the slave stations communicate with each other using two data frame transmission formats, namely broadcast and polling. All the slave stations are mounted on the same bus through POWERBUS technology. When the master station sends an instruction, all the slave stations receive it at the same time. The broadcast transmission format is: the master station sends a broadcast instruction, and after the slave station receives the broadcast instruction, it detects it as a broadcast instruction and determines whether an external alarm is triggered. If an alarm is triggered, it replies with a preemption instruction, and if there is no alarm, it does not reply; The polling transmission format is: the master station sends a polling instruction, and different polling instructions correspond to the addresses of each slave station respectively. After receiving the polling instruction, the slave station determines whether the polling instruction is the same as its own address. If they are the same, it replies with a non-preemptive instruction, otherwise it does not reply.
2. The master-slave communication method for a conveyor based on POWERBUS according to claim 1, characterized in that: The broadcast link and the polling link form a small loop, and the generated alarm will be uploaded to the master station in each small loop; when the first small loop ends, the second small loop will be immediately carried out, and the polling instruction sent by the master station will be changed to another slave station address until all the small loops corresponding to the slave stations are completed. At this time, all the small loops are a large loop, and each large loop will be restarted immediately after it is executed once.
3. The master-slave communication method for a conveyor based on POWERBUS according to claim 2, characterized in that: In the master station broadcast link, if the master station does not receive a reply after waiting for 13ms after broadcasting, it will time out and skip.
4. The master-slave communication method for a conveyor based on POWERBUS according to claim 2, characterized in that: In the polling phase, the instruction data replied by the slave station is consistent with its own address. The master station compares the received reply data with the sent polling instruction. If they are the same, the polling phase ends. If they are different, a communication error indication is output and the polling phase ends.
5. The master-slave communication method for a conveyor based on POWERBUS according to claim 1, characterized in that: The slave station includes a slave station single chip microcomputer and a slave station communication chip. The slave station single chip microcomputer controls whether the instruction issued by the slave station communication chip is in a preemptive format through the level of an IO pin.
6. The master-slave communication method for a conveyor based on POWERBUS according to claim 1, characterized in that: When the number of the slave stations does not exceed 255, the data frame sent by the master station is set to one byte.
7. The master-slave communication method for a conveyor based on POWERBUS according to claim 6, characterized in that: The master station single chip microcomputer and the master station communication chip as well as the slave station single chip microcomputer and the slave station communication chip are connected through USART transceiver modules respectively, and the communication baud rate is 9600bps.
8. The master-slave communication method for a conveyor based on POWERBUS according to claim 1, characterized in that: When the number of the slave stations exceeds 255, the data frame sent by the master station is set to two bytes.
9. The master-slave communication method for a conveyor based on POWERBUS according to any one of claims 1 to 8, characterized in that: The master station and the slave station are connected in the form of a non-polarity two-bus, and data is transmitted in a serial port transparent transmission mode. The slave station receives instructions from the master station through a serial port interrupt and sends data in an interrupt callback function.