Communication method and device and computer readable storage medium

By setting multiple trigger modes between the master and slave, the problem of waste of bus resources and single trigger mode in MCU SPC sensor communication is solved, and efficient and reliable communication is achieved.

CN120578613APending Publication Date: 2025-09-02BYD SEMICON CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410239868.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-01
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

The existing MCU SPC sensor trigger mode design adopts ISTM, resulting in a single write access that can only trigger a single response of the SPC sensor, requiring multiple peripheral module buffer write access, wasting MCU bus resources, and the trigger mode is single and inflexible, and the communication stability is not high.

Method used

By setting multiple trigger modes, including internal automatic trigger mode and external automatic trigger mode, the host communicates between the host and the slave, avoiding single repeated write access by the bus, realizing that the host automatically sends trigger pulses, and flexibly selects the trigger mode to meet different communication needs.

Benefits of technology

It improves the utilization rate of the bus and the reliability of communication, overcomes the problem of single and inflexible trigger mode, and realizes efficient and synchronous communication between the master and slave.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120578613A_ABST
    Figure CN120578613A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and device and a computer readable storage medium, the method is used for realizing communication between a host and a slave, and the method comprises the following steps: when the host communicates with the slave, the host sends a trigger pulse to the slave to enable the slave to sample data in response to the trigger pulse, and receives data sent by the slave; wherein the host can automatically send trigger pulses to the slave through a plurality of trigger modes. According to the invention, communication between the host and the slave is realized by setting a plurality of trigger modes, single-time repeated write access of the bus is avoided, so that the utilization rate of the bus is improved, further, by setting a plurality of trigger modes, the problem that the trigger mode is single and inflexible in the communication process is solved, and the communication reliability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, and in particular to a communication method, device, and computer-readable storage medium. Background Art

[0002] With the development of intelligent automobile industry, the demand for the number of on-board sensors and measurement accuracy is increasing day by day. Traditional automotive network communication networks, such as CAN (Controller Area Network), LIN (Local Interconnect Network) and the expensive FlexRay bus, can no longer meet the needs of actual applications.

[0003] At present, in the existing technology, the SENT (Single Edge Nibble Transmission) communication protocol is usually used for communication. The SENT communication protocol adopts PWM (Pulse Width Modulation) encoding / decoding, and is usually used for point-to-point unidirectional communication between the sensor and the MCU (Micro Controller Unit). It has high precision and high reliability. In order to overcome the shortcomings of SENT unidirectional transmission, SPC (Short PWM Code) is adopted to enhance the SENT interface function.

[0004] However, since the existing MCU SPC sensor trigger mode design adopts ISTM (Internal Single Trigger Mode), that is, the trigger pulse of the SPC sensor is sent through a single write access to the MCU peripheral module buffer, a single write access can only trigger a single response of the SPC sensor. If the SPC sensor needs to be triggered multiple times, multiple write accesses to the peripheral module buffer are required, which wastes MCU bus resources. In addition, the existing trigger mode is single and not flexible, resulting in low communication stability. Summary of the Invention

[0005] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, one object of the present invention is to provide a communication method that enables communication between a master and a slave by setting multiple trigger modes, thereby avoiding repeated single write accesses to the bus and improving bus utilization. Furthermore, by setting multiple trigger modes, the problem of a single, inflexible trigger mode during communication is overcome, thereby improving communication reliability.

[0006] To this end, a second object of the present invention is to provide a communication device.

[0007] To this end, a third object of the present invention is to provide a computer-readable storage medium.

[0008] To achieve the above-mentioned objectives, an embodiment of the first aspect of the present invention discloses a communication method for realizing communication between a host and a slave, the communication method comprising: when the host and the slave communicate, the host sends a trigger pulse to the slave so that the slave samples data in response to the trigger pulse, and receives the data sent by the slave; wherein, the host can automatically send the trigger pulse to the slave through a variety of trigger modes.

[0009] According to the communication method of an embodiment of the present invention, communication between a host and a slave is achieved by setting a plurality of trigger modes, thereby avoiding a single repeated write access of the bus, thereby improving the utilization rate of the bus. Furthermore, by setting a plurality of trigger modes, the problem of a single and inflexible trigger mode during the communication process is overcome, thereby improving the reliability of communication.

[0010] In addition, the communication method according to the above embodiment of the present invention may also have the following additional technical features:

[0011] In some examples, one of the multiple trigger modes includes an internal automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the internal automatic trigger mode, including: if the host has not sent the trigger pulse before, the host performs a first timing, and when the first timing reaches a first time threshold, sends a trigger pulse to the slave; if the host receives the data sent by the slave within a first preset time, the host performs a second timing, and when the second timing reaches a second time threshold, automatically sends the next trigger pulse to the slave, and repeats this step to automatically send the trigger pulse to the slave multiple times, wherein the data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

[0012] In some examples, one of the multiple trigger modes includes an internal automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the internal automatic trigger mode, including: if the host has sent the trigger pulse before, the host performs a second timing after receiving the data sent by the slave for the last time, and when the second timing reaches a second time threshold, automatically sends the next trigger pulse to the slave, and repeats this step to automatically send the trigger pulse to the slave multiple times, and the data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

[0013] In some examples, after the host sends the trigger pulse to the slave, the method further includes: if the host does not receive the data sent by the slave within the first preset time or the host does not receive the data frame end pulse sent by the slave, the host no longer sends the trigger pulse.

[0014] In some examples, before the host performs the first timing, the method further includes: after the host receives first parameter setting information, starting the first timing, wherein the first parameter setting information includes a set first trigger parameter.

[0015] In some examples, the first trigger parameter includes the first time threshold and a length of the trigger pulse.

[0016] In some examples, the first time threshold is determined according to a model of the slave device.

[0017] In some examples, before the second timing is performed, the method further includes: starting the second timing when the host receives a data frame end pulse sent by the slave.

[0018] In some examples, the data frame end pulse includes any one of the falling edge of the end pulse of the slave response data frame, the falling edge or rising edge of the synchronization or calibration pulse of the slave response data frame, the falling edge or rising edge of the status and communication half byte of the slave response data frame, the falling edge or rising edge of the fast channel data half byte of the slave response data frame, and the falling edge or rising edge of the cyclic redundancy check half byte of the slave response data frame.

[0019] In some examples, one of the multiple modes includes an external automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the external automatic trigger mode, including: when the host detects a trigger signal, starting a third timing, and when the third timing reaches a third time threshold, sending a trigger pulse to the slave.

[0020] In some examples, before the host performs the third timing, the method further includes: after the host receives second parameter setting information, starting the third timing, wherein the second parameter setting information includes a set second trigger parameter.

[0021] In some examples, the second trigger parameter includes the third time threshold and the length of the trigger pulse.

[0022] In some examples, the third time threshold is determined according to a model of the slave device.

[0023] In some examples, the communication method further includes: inputting a trigger input signal to a trigger multiplexer through a trigger input source, so that the trigger multiplexer outputs the trigger signal.

[0024] In some examples, the trigger input source periodically or irregularly inputs a trigger input signal to the trigger multiplexer, so that the trigger multiplexer periodically or irregularly outputs the trigger signal.

[0025] In some examples, before inputting the trigger input signal to the trigger multiplexer through the trigger input source, the method further includes: selecting a target trigger input source from a plurality of trigger input sources to input the trigger input signal to the trigger multiplexer through the target trigger input source.

[0026] In some examples, the target trigger input source is selected from a plurality of trigger input sources by controlling a switch.

[0027] In some examples, there are multiple control switches, and the multiple control switches are connected to the multiple trigger input sources in a one-to-one correspondence.

[0028] In some examples, the plurality of trigger input sources include at least: a timer module, a pulse width modulation module, a general timer module, a comparator module, a successive approximation analog-to-digital converter module, and a Delta-Sigma analog-to-digital conversion module.

[0029] In some examples, the timing data is cleared after each timing is completed.

[0030] In some examples, the communication method further includes: the host selecting the corresponding trigger mode by receiving a trigger mode enable signal, wherein different trigger mode enable signals enable different trigger modes.

[0031] In some examples, the trigger pulse is a low-level trigger pulse.

[0032] In some examples, the communication method further includes: when the host receives a trigger mode switching signal, switching the current trigger mode to another trigger mode among the multiple trigger modes to automatically send the trigger pulse to the slave, wherein the trigger mode switching signal includes an enable signal of the other trigger mode to be switched.

[0033] In some examples, the communication method further includes: the host configuring a mapping relationship between a temporary receive data buffer area and a receive data buffer area to sort the data sent by the slave.

[0034] In some examples, the host sorts the data sent by the slave by configuring a mapping relationship between a temporary receive data buffer and a receive data buffer, including: the host stores the received data in the temporary receive data buffer; programming the storage pointers of each data in the temporary receive data buffer so that they are arranged in a target order; and storing each data sequentially in the receive data buffer according to the programmed storage pointers.

[0035] In some examples, the storage pointer of each data in the received data temporary buffer is programmed by a hardware programming device.

[0036] In some examples, the host includes a microcontroller unit.

[0037] In some examples, the slave includes a sensor.

[0038] In some examples, the sensor includes a sensor that communicates using an SPC protocol.

[0039] To achieve the above-mentioned purpose, an embodiment of the second aspect of the present invention discloses a communication device, comprising: a processor, a memory, and a communication program stored in the memory and executable on the processor, wherein when the communication program is executed by the processor, the communication method as described in the embodiment of the first aspect of the present invention is implemented.

[0040] According to the communication device of an embodiment of the present invention, communication between a host and a slave is achieved by setting a plurality of trigger modes, thereby avoiding a single repeated write access to the bus, thereby improving the utilization rate of the bus. Furthermore, by setting a plurality of trigger modes, the problem of a single and inflexible trigger mode during the communication process is overcome, thereby improving the reliability of communication.

[0041] To achieve the above-mentioned purpose, the third embodiment of the present invention discloses a computer-readable storage medium, on which a communication program is stored. When the communication program is executed by a processor, the communication method as described in the first embodiment of the present invention is implemented.

[0042] According to the computer-readable storage medium of an embodiment of the present invention, when the communication program stored thereon is executed by a processor, communication between the host and the slave can be achieved by setting multiple trigger modes, thereby avoiding single repeated write access to the bus and improving the utilization rate of the bus. Furthermore, by setting multiple trigger modes, the problem of a single and inflexible trigger mode is overcome, thereby improving the reliability of communication.

[0043] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments with reference to the following drawings, in which:

[0045] Figure 1 is a flow chart of a communication method according to one embodiment of the present invention;

[0046] Figure 2 is a flow chart of an internal automatic triggering mode of a communication method according to one embodiment of the present invention;

[0047] Figure 3 is a flow chart of an external automatic trigger mode of a communication method according to an embodiment of the present invention;

[0048] Figure 4 is a flowchart of trigger mode switching of a communication method according to an embodiment of the present invention;

[0049] Figure 5 FIG. 4 is a schematic diagram of a data storage principle of a communication method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0050] The embodiments of the present invention will be described in detail below. The embodiments described with reference to the accompanying drawings are exemplary. The embodiments of the present invention will be described in detail below.

[0051] Reference below Figure 1-Figure 5 A communication method, apparatus, and computer-readable storage medium according to embodiments of the present invention are described.

[0052] Figure 1 FIG. 1 is a flow chart of a communication method according to an embodiment of the present invention. The communication method is used to implement communication between a host and a slave, such as Figure 1 As shown, the communication method includes: when the host and the slave communicate, the host sends a trigger pulse to the slave so that the slave samples data in response to the trigger pulse, and receives the data sent by the slave; wherein, the host can automatically send the trigger pulse to the slave through a variety of trigger modes.

[0053] Specifically, during the communication process between the host and the slave, the host can select different trigger modes to send trigger pulses to the slave according to actual application requirements, wherein the trigger modes include but are not limited to ISTM, IATM (Internal Automatic Trigger Mode) and EATM (External Automatic Trigger Mode), and the trigger pulses include but are not limited to low-level trigger pulses. After the slave receives the trigger pulse, it can flexibly sample the data according to the preset sampling frequency or trigger condition, and after the sampling is completed, transmit the data back to the host so that the host can process, store, and perform corresponding control on the sampled data, thereby realizing efficient and synchronous communication between the host and the slave.

[0054] Therefore, the above-mentioned communication method realizes communication between the host and the slave by setting multiple trigger modes, avoids single repeated write access to the bus, and thus improves the utilization rate of the bus. Furthermore, by setting multiple trigger modes, it also overcomes the problem of single and inflexible trigger mode during communication and improves the reliability of communication.

[0055] In one embodiment of the present invention, Figure 2 As shown, one of the multiple trigger modes includes an internal automatic trigger mode, in which the host automatically sends a trigger pulse to the slave, including: if the host has not sent a trigger pulse before, the host performs a first timing, and when the first timing reaches a first time threshold, sends a trigger pulse to the slave.

[0056] Specifically, one of the multiple trigger modes includes an internal automatic trigger mode, that is, the host can automatically and continuously send trigger pulses to the slave without manual triggering each time. Specifically, in the internal automatic trigger mode, if the host has not sent a trigger pulse before, that is, it is the first time to send a trigger pulse, the host starts the first timing, that is, the time from the host entering the internal automatic trigger mode to the current moment. When the first timing reaches the preset first time threshold, the host can send a trigger pulse to the slave to instruct the slave to start data sampling.

[0057] In one embodiment of the present invention, Figure 2 As shown, if the host receives data sent by the slave within the first preset time, a second timing is performed. When the second timing reaches the second time threshold, the next trigger pulse is automatically sent to the slave, and this step is repeated to automatically send trigger pulses to the slave multiple times, wherein the data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

[0058] Specifically, after receiving the trigger pulse, the slave can sample data according to the preset sampling rate or trigger condition, and send the sampled data back to the host through the communication bus. If the host receives the data sent by the slave within the first preset time, that is, the host does not time out from receiving the sampled data, the host starts the second timing. When the second timing reaches the preset second time threshold, the host can automatically send the next trigger pulse to the slave and repeat this process. That is, the host can send trigger pulses periodically, and the slave can sample and send data to the host periodically, thereby realizing continuous data sampling and transmission, that is, realizing automatic communication between the host and the slave.

[0059] In one embodiment of the present invention, Figure 2 As shown, one of the multiple trigger modes includes an internal automatic trigger mode, and the host automatically sends a trigger pulse to the slave through the internal automatic trigger mode, including: if the host has sent a trigger pulse before, that is, the host is not sending a trigger pulse for the first time, then the host performs a second timing after receiving the data sent by the slave last time, and when the second timing reaches a second time threshold, the host automatically sends the next trigger pulse to the slave, and repeats this step to automatically send trigger pulses to the slave multiple times, and the data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

[0060] Specifically, in the internal automatic trigger mode, the host can determine whether a trigger pulse has been sent before, that is, whether the host has performed the first timing and the first timing has reached the preset first time threshold, for example, through an internal preset algorithm or other means. If it is determined that the host has sent a trigger pulse before, the host will perform a second timing after sending a trigger pulse to the slave last time and receiving the data sent by the slave. When the second timing reaches the second time threshold, the host can automatically send the next trigger pulse to the slave and repeat this process, thereby realizing that the host automatically and regularly sends trigger pulses to the slave.

[0061] In one embodiment of the present invention, Figure 2 As shown, after the host sends a trigger pulse to the slave, it also includes: if the host does not receive the data sent by the slave within the first preset time or the host does not receive the data frame end pulse sent by the slave, the host no longer sends a trigger pulse.

[0062] Specifically, in the internal automatic trigger mode, after the host sends a trigger pulse to the slave, it starts waiting for the slave's response and transmits back data. If the host does not receive the data sent by the slave or the data frame end pulse within the first preset time, that is, the host does not receive a valid sampling data frame or does not detect a valid data frame end pulse, it means that the slave does not respond normally to the trigger pulse sent by the host, the host receives the data timeout, and the host no longer sends a trigger pulse, thereby avoiding invalid communication, avoiding waste of communication resources, and ensuring the effective use of communication resources.

[0063] In one embodiment of the present invention, Figure 2 As shown, before the host performs the first timing, it also includes: after the host receives the first parameter setting information, it starts the first timing, wherein the first parameter setting information includes the first trigger parameter that has been set.

[0064] Specifically, before the master starts the internal automatic trigger mode and sends the trigger pulse, it can receive first parameter setting information output by the host's peripheral module, process and parse the first parameter setting information, and then start the first timing according to the first parameter setting information, thereby ensuring the reliability of communication between the master and the slave. The first parameter setting information includes the set first trigger parameters, that is, the parameters used to configure the first timing time and trigger mechanism.

[0065] In one embodiment of the present invention, Figure 2 As shown, the first trigger parameter includes a first time threshold and a length of a trigger pulse.

[0066] Specifically, the first trigger parameter includes a first time threshold and a trigger pulse length. The first time threshold represents the time the master must wait after entering internal automatic trigger mode before sending the first trigger pulse. The trigger pulse length represents the length of time the trigger pulse signal remains high or low, i.e., the maximum time allowed for the slave to respond after the trigger pulse signal is sent. It is understood that the first time threshold and the trigger pulse length can be pre-written to the cache of the master's peripheral module, and the trigger pulse length can be correctly set according to the parameters in the slave's manual, thereby facilitating the slave's correct response to the trigger pulse.

[0067] In one embodiment of the present invention, the first time threshold is determined according to the model of the slave device.

[0068] Specifically, when a master communicates with a slave, a first time threshold can be determined based on the slave model to ensure communication matching and synchronization between the master and slave. This ensures that the slave is ready to receive and process a trigger pulse before the master sends one. It is understood that different slave models have different characteristics and performance. For example, some high-end slave devices have faster processing speeds and shorter startup times, while some low-end slave devices may take longer to complete the same task. Therefore, determining the first time threshold based on the slave model can ensure that the sending of the trigger pulse matches the actual state of the slave.

[0069] In one embodiment of the present invention, Figure 2 As shown, before the second timing is performed, the process further includes: when the host receives a data frame end pulse sent by the slave, the second timing is started.

[0070] Specifically, during communication between the host and the slave, before the second timing begins, if the host receives a data frame end pulse sent by the slave, the second timing begins. Specifically, after the host sends a trigger pulse to the slave, the slave can output sampled data to the host in the form of a data frame according to the trigger pulse, and after sending the entire data frame, it sends an end pulse to indicate the end of the data frame transmission. When the host receives the data frame end pulse sent by the slave, it indicates that the host has completed reception of the data frame output by the current slave and can begin the second timing.

[0071] In one embodiment of the present invention, the data frame end pulse includes any one of the falling edge of the end pulse of the slave response data frame, the falling edge or rising edge of the synchronization or calibration pulse of the slave response data frame, the falling edge or rising edge of the status and communication half byte of the slave response data frame, the falling edge or rising edge of the fast channel data half byte of the slave response data frame, and the falling edge or rising edge of the cyclic redundancy check half byte of the slave response data frame.

[0072] Specifically, the end pulse of the data frame can be identified by the falling edge (change from high level to low level) of the slave's response to the end pulse of the data frame, so as to notify the host that the data frame has been transmitted; further, the data frame sent by the slave may be accompanied by a synchronization or calibration pulse, that is, the falling edge or rising edge (change from low level to high level) of the synchronization or calibration pulse can also be used as an identifier of the end pulse of the data frame; further, the data frame sent by the slave may contain status information and communication control bytes or fast channel data half bytes or cyclic redundancy check half bytes, that is, the falling edge or rising edge of the status information and communication control bytes or fast channel data half bytes or cyclic redundancy check half bytes can also be used as an identifier of the end pulse of the data frame.

[0073] In one embodiment of the present invention, Figure 3 As shown, one of the multiple modes includes an external automatic trigger mode, in which the host automatically sends a trigger pulse to the slave, including: when the host detects a trigger signal, starting the third timing, and when the third timing reaches a third time threshold, sending a trigger pulse to the slave.

[0074] Specifically, one of the multiple trigger modes includes an external automatic trigger mode, that is, the host can automatically and continuously send trigger pulses to the slave without manual triggering each time. Specifically, in the external automatic trigger mode, when the host detects the trigger signal, the host starts the third timing, that is, the time from the host entering the external automatic trigger mode to the current moment. When the third timing reaches the preset third time threshold, the host can send a trigger pulse to the slave to notify the slave to start data sampling.

[0075] In one embodiment of the present invention, Figure 3 As shown, before the host performs the third timing, it also includes: after the host receives the second parameter setting information, it starts the third timing, wherein the second parameter setting information includes the set second trigger parameter.

[0076] Specifically, before the master starts the external automatic trigger mode and sends the trigger pulse, it can receive second parameter setting information output by the host's peripheral module, process and parse the second parameter setting information, and then start the third timing according to the second parameter setting information, thereby ensuring the reliability of communication between the master and the slave. The second parameter setting information includes the set second trigger parameters, i.e., the parameters used to configure the third timing time and trigger mechanism.

[0077] In one embodiment of the present invention, Figure 3 As shown, the second trigger parameter includes a third time threshold and the length of the trigger pulse.

[0078] Specifically, the second trigger parameter includes a third time threshold and a trigger pulse length. The third time threshold represents the time the master must wait after entering external automatic trigger mode before sending a trigger pulse. The trigger pulse length represents the length of time the trigger pulse signal remains high or low, i.e., the maximum time allowed for the slave to respond after the trigger pulse signal is sent. It is understood that the third time threshold and the trigger pulse length can be pre-written by the user into the buffer area of ​​the master's peripheral module, and the trigger pulse length can be correctly set according to the parameters in the slave's manual, thereby facilitating the slave's correct response to the trigger pulse.

[0079] In one embodiment of the present invention, the third time threshold is determined according to the model of the slave device.

[0080] Specifically, when a master communicates with a slave, a third time threshold can be determined based on the slave model to ensure communication matching and synchronization between the master and slave. Specifically, this ensures that the slave is ready to receive and process a trigger pulse before the master sends one. It is understood that different slave models have different characteristics and performance. For example, some high-end slave devices have faster processing speeds and shorter startup times, while some low-end slave devices may take longer to complete the same task. Therefore, determining the third time threshold based on the slave model can ensure that the sending of the trigger pulse matches the actual state of the slave.

[0081] In one embodiment of the present invention, Figure 3 As shown, the communication method further includes: inputting a trigger input signal to the trigger multiplexer through a trigger input source, so that the trigger multiplexer outputs a trigger signal.

[0082] Specifically, in external automatic trigger mode, one or more trigger input sources can be set to input trigger input signals, including but not limited to digital or analog signals, into the trigger multiplexer, causing the trigger multiplexer to output a trigger signal. Thus, by setting multiple trigger input sources and inputting trigger input signals into the trigger multiplexer, the problem of being unable to synchronize multiple events at the system level during communication is overcome. A trigger input source is a device or component for triggering an input signal, and the trigger multiplexer is used to receive one or more trigger input signals and selectively output a trigger signal based on the trigger input signals.

[0083] In one embodiment of the present invention, a trigger input source periodically or irregularly inputs a trigger input signal to the trigger multiplexer, so that the trigger multiplexer periodically or irregularly outputs a trigger signal.

[0084] Specifically, in the external automatic trigger mode, the trigger input source can periodically input a trigger input signal to the trigger multiplexer at a preset time interval, such as once every second, every minute, or every hour, so that the trigger multiplexer periodically outputs a trigger signal. Furthermore, the trigger input source can also irregularly input a trigger input signal to the trigger multiplexer due to factors such as changes in the external environment, changes in the internal state, or user operations, so that the trigger multiplexer irregularly outputs a trigger signal. It is understood that by having the trigger input source periodically or irregularly input a trigger input signal to the trigger multiplexer, flexible and reliable trigger signal output can be achieved, thereby improving data reliability throughout the entire communication process.

[0085] In one embodiment of the present invention, before inputting the trigger input signal to the trigger multiplexer through the trigger input source, it also includes: selecting a target trigger input source from multiple trigger input sources to input the trigger input signal to the trigger multiplexer through the target trigger input source.

[0086] Specifically, before a trigger input signal is input to the trigger multiplexer via a trigger input source, a target trigger input source can be selected from multiple trigger input sources. The selection method includes, but is not limited to, determining whether the trigger input signal output by the trigger input source meets certain conditions, such as whether a preset time threshold is reached, or selecting a suitable trigger input source as the target trigger input source by determining the importance, real-time nature, or specific requirements of different trigger input sources, or setting a priority order for multiple trigger input sources, and selecting the corresponding trigger input source as the target trigger input source according to the priority order each time a trigger is triggered. Furthermore, after determining the target trigger input source, the trigger input signal can be input to the trigger multiplexer via the target trigger input source, so that the trigger multiplexer outputs a trigger signal periodically or irregularly.

[0087] In one embodiment of the present invention, a target trigger input source is selected from a plurality of trigger input sources by controlling a switch.

[0088] Specifically, during the selection process of multiple trigger input sources, the control switch can serve as a selector between the multiplexer and the multiple trigger input sources. That is, according to a preset selection rule, the control switch can switch between different trigger input sources and select a target trigger input source. Specifically, during the communication process, when it is necessary to select a target trigger input source, a corresponding control signal can be generated according to the preset selection rule and sent to the control switch, causing the control switch to perform a switching operation, including but not limited to turning the control switch on or off, to connect the target trigger input signal path, thereby inputting the trigger input signal into the trigger multiplexer.

[0089] In one embodiment of the present invention, there are multiple control switches, and the multiple control switches are connected to the multiple trigger input sources in a one-to-one correspondence.

[0090] Specifically, there are multiple control switches, each connected to a specific trigger input source. That is, each control switch independently controls the connection or disconnection of the connected trigger input source, allowing multiple trigger input sources to be independently selected and switched without interfering with each other, thereby improving the accuracy of trigger input source selection. It will be understood that when a control switch is in an open state, the corresponding trigger input source is allowed to input a trigger input signal to the trigger multiplexer, and when the control switch is in a closed state, the corresponding trigger input source is prevented from inputting a trigger input signal to the trigger multiplexer.

[0091] In one embodiment of the present invention, the multiple trigger input sources include at least: a timer module, a pulse width modulation module, a general timer module, a comparator module, a successive approximation analog-to-digital converter module, and a Delta-Sigma analog-to-digital conversion module.

[0092] Specifically, the multiple trigger input sources include at least a timer module, a pulse width modulation module, a general timer module, a comparator module, a successive approximation analog-to-digital converter module, and a Delta-Sigma analog-to-digital conversion module. The timer module is used to generate a timing signal, including but not limited to generating a trigger input signal after a preset time interval; the pulse width modulation module is used to generate and output pulse signals with different duty cycles; the general timer module is used to provide flexible timing and counting functions; the comparator module is used to compare the size of the trigger input signal or combine the trigger input signals, and output the trigger input signal based on the comparison result or the combination result; the successive approximation analog-to-digital converter module is used to convert the digital analog signal of the trigger input source into the trigger input signal by successive approximation; the Delta-Sigma analog-to-digital conversion module is similar to the successive approximation analog-to-digital converter module and is used to convert the digital analog signal of the trigger input source into the trigger input signal, and the converted trigger input signal has higher precision.

[0093] In one embodiment of the present invention, the timing data is cleared after each timing is completed.

[0094] Specifically, during the communication process between the master and slave, after each timely completion, that is, after the timer reaches the preset timing value, the timing data can be cleared to facilitate the next timing operation. Specifically, if the threshold value set for the timer is 10, the timer begins timing after the parameters are set for the first time, and after receiving a valid end pulse for the second and subsequent times, after the timer count value counts up to the set threshold of 10, the timer begins the zeroing operation, resetting the count value to 0. This ensures that the timer starts from the initial state at the next timing, thereby avoiding problems such as cumulative errors and timing overflows.

[0095] In one embodiment of the present invention, the communication method further includes: the host selects a corresponding trigger mode by receiving a trigger mode enable signal, wherein different trigger mode enable signals enable different trigger modes.

[0096] Specifically, during the communication process, the host can select the corresponding trigger mode by receiving and parsing the trigger mode enable signal, where different trigger mode enable signals correspond to enabling different trigger modes, that is, each trigger mode enable signal has its specific function and effect. By sending a specific trigger mode enable signal, the host can activate the corresponding trigger mode to adapt to the current communication environment and communication needs.

[0097] In one embodiment of the present invention, the trigger pulse is a low-level trigger pulse.

[0098] Specifically, during communication, the pulse sent by the master can be a low-level trigger pulse. That is, when the master's input signal reaches a low level, an output pulse signal is generated to notify the slave device to start data sampling. By using a low-level trigger pulse, the slave device can ensure that it receives the data acquisition signal sent by the master in a timely and accurate manner, thereby improving communication reliability.

[0099] In summary, in the external automatic trigger mode, the trigger input source can input a trigger input signal to the trigger multiplexer so that the host sends a trigger pulse to the slave, including but not limited to a low-level trigger pulse, and after the transmission is completed, the host's peripheral module can continuously detect whether a trigger signal (including but not limited to the rising edge of the trigger signal) is obtained from the multiplexer. That is, in the external automatic trigger mode, when the host sends a trigger pulse to the slave, it needs to obtain a trigger signal from the multiplexer each time. It should be noted that in the external automatic trigger mode, the host sends a trigger pulse to the slave, and the slave responds and sends data to the host within a preset time threshold. At this time, whether the host receives a timeout does not affect the host's peripheral module obtaining a trigger signal from the multiplexer and the host sending a trigger pulse to the slave.

[0100] In one embodiment of the present invention, Figure 4 As shown, the communication method also includes: when the host receives a trigger mode switching signal, it switches the current trigger mode to another trigger mode among multiple trigger modes to automatically send a trigger pulse to the slave, wherein the trigger mode switching signal includes an enable signal of another trigger mode to be switched.

[0101] Specifically, during the communication process, when the host receives a trigger mode switching signal, it can automatically adjust the host's trigger mode according to the information in the trigger mode switching signal, switch the current trigger mode to another trigger mode, and automatically send a trigger pulse to the slave. Among them, the trigger mode switching signal includes an enable signal of another trigger mode to be switched, which is used to notify the host which trigger mode it should switch to. For example, assuming that the host wants to switch the current trigger mode to another trigger mode, it can initialize by writing to the host's peripheral module buffer after receiving the enable signal of another trigger mode. After the initialization is completed, it can switch to another trigger mode to achieve the corresponding function. For example, switch from internal automatic trigger mode to external automatic trigger mode, or switch from external automatic trigger mode to internal automatic trigger mode, etc.

[0102] In one embodiment of the present invention, the communication method further includes: the host configuring a mapping relationship between the temporary buffer area for received data and the buffer area for received data to sort the data sent by the slave.

[0103] Specifically, during the communication process, the host sorts the data sent by the slave by configuring a mapping relationship between the temporary receive data buffer and the receive data buffer. The temporary receive data buffer represents a temporary storage space for temporarily storing sampled data sent by the slave, while the receive data buffer represents a long-term data storage area on the host for storing sorted and processed data. It is understood that by configuring the mapping relationship between the temporary receive data buffer and the receive data buffer, the host can sort and process the sampled data in the temporary receive data buffer and transfer the sorted and processed data from the temporary receive data buffer to the receive data buffer.

[0104] In one embodiment of the present invention, the host sorts the data sent by the slave by configuring a mapping relationship between a temporary buffer area for receiving data and a temporary buffer area for receiving data, including: the host stores the received data in the temporary buffer area for receiving data; programming the storage pointers of each data in the temporary buffer area for receiving data so that they are arranged in a target order; and storing each data in the receiving data buffer area in sequence according to the programmed storage pointers.

[0105] Specifically, after the host receives the sampled data sent by the slave, the received data can be stored in the received data temporary buffer for temporary storage, and the data sent by the slave can be sorted according to the mapping relationship between the configured received data temporary buffer and the received data buffer. During the sorting process, since the storage pointer can point to the address of each data, the storage pointer of each data in the received data temporary buffer can be programmed to facilitate access and operation of each data, so that each data is arranged in the target order, and each data is stored in the received data buffer in sequence according to the programmed storage pointer to ensure the consistency and reliability of each data.

[0106] In one embodiment of the present invention, the storage pointer of each data in the received data temporary buffer is programmed by a hardware programming device.

[0107] Specifically, in the process of sorting the data in the temporary buffer of the received data, the storage pointer of each data can be programmed by the hardware programming device, and the data can be re-sorted or numbered according to the preset rules so that the data can be arranged in the target order, for example, Figure 5 As shown, there are eight data frames 0, 0, DATA1, DATA2, DATA3, DATA4, DATA5, and DATA6 in the temporary buffer of received data, with storage pointers 1, 5, 3, 0, 4, 7, 2, and 6, respectively. Assuming that the sorting rule required by actual needs is to sort the data items from large to small according to their serial numbers, the hardware programming device can adjust the values ​​of the storage pointers so that the order becomes 7, 6, 5, 4, 3, 2, 1, 0, and the correct sorting result is DATA4, DATA6, 0, DATA3, DATA1, DATA5, 0, and DATA2. It can be understood that the use of a hardware programming device can provide a flexible data sorting method, reordering each data according to different needs and standards, thereby reducing the workload of the CPU (Central Processing Unit) during the communication process, thereby improving the CPU's work efficiency.

[0108] In one embodiment of the present invention, the host comprises a microcontroller unit MCU.

[0109] Specifically, the host includes a microcontroller unit, or MCU, also known as a single-chip microcomputer or single-chip microcomputer. The MCU integrates interfaces for various devices such as the central processing unit (CPU), memory, counters, etc., including but not limited to interfaces for multiple trigger input sources and multiplexers, forming a chip-level computer for executing various programs and performing various computing tasks. Specifically, during the communication process, the MCU can receive a trigger mode enable signal to select the corresponding trigger mode, such as ISTM, IATM, and EATM, and in different trigger modes, it can automatically and continuously send trigger pulses to the slave device regularly or irregularly to enable the slave device to sample data.

[0110] In one embodiment of the present invention, the slave includes a sensor.

[0111] Specifically, the slave is integrated with sensors for receiving instructions from the host and performing corresponding operations. It can also send data or status information to the host. For example, the sensors in the slave can convert various physical quantity data collected, including but not limited to temperature, humidity, light, pressure, speed, rotation speed, etc., into electrical signals for processing by the slave or transmission to the host for further processing.

[0112] In one embodiment of the present invention, the sensor includes a sensor that communicates using an SPC protocol.

[0113] Specifically, sensors, including those that communicate using the SPC protocol, can be used to collect, process, and transmit data, and send the data to a connected host for further analysis and processing. Specifically, sensors that communicate using the SPC protocol can select different operating modes depending on different situations. For example, in synchronous mode, the sensor can sample and transmit data at intervals set by the host; in range selection mode, the sensor can select a specific measurement range based on the host's configuration; in ID selection mode, the host can communicate via trigger pulses; and in bidirectional transmission mode, bidirectional data exchange can be achieved between the sensor and the host.

[0114] In summary, according to the communication method of the embodiment of the present invention, communication between the host and the slave is achieved by setting multiple trigger modes, which avoids single repeated write access to the bus, thereby improving the utilization rate of the bus. Furthermore, by setting multiple trigger modes, the problem of single and inflexible trigger mode in the communication process is overcome. In the external automatic trigger mode, by setting multiple trigger input sources and inputting trigger input signals to the trigger multiplexer, the problem of not being able to send multiple events synchronously at the system level during the communication process is overcome, thereby improving the reliability of communication. Furthermore, the host configures the mapping relationship between the temporary buffer area for receiving data and the buffer area for receiving data, and uses a hardware programming device to sort the data sent by the slave, thereby reducing the workload of the CPU in the communication process and thereby improving the work efficiency of the CPU.

[0115] A further embodiment of the present invention also proposes a communication device 100, comprising: a processor, a memory, and a communication program stored in the memory and executable on the processor, wherein when the communication program is executed by the processor, the communication method as described in the embodiment of the first aspect of the present invention is implemented.

[0116] It should be noted that when the communication device communicates, its specific implementation method is similar to the specific implementation method of the communication method of any one of the above-mentioned embodiments of the present invention. Therefore, for a detailed exemplary description of the process of the communication device communicating, please refer to the relevant description part of the communication method mentioned above. In order to reduce redundancy, it will not be repeated here.

[0117] According to the communication device of the embodiment of the present invention, communication between the host and the slave is achieved by setting multiple trigger modes, which avoids single repeated write access to the bus, thereby improving the utilization rate of the bus. Furthermore, by setting multiple trigger modes, the problem of single and inflexible trigger mode in the communication process is overcome. In the external automatic trigger mode, by setting multiple trigger input sources and inputting trigger input signals to the trigger multiplexer, the problem of not being able to synchronously send multiple events at the system level during the communication process is overcome, thereby improving the reliability of communication. Furthermore, the host configures the mapping relationship between the temporary buffer area for receiving data and the buffer area for receiving data, and uses a hardware programming device to sort the data sent by the slave, thereby reducing the workload of the CPU in the communication process and thereby improving the work efficiency of the CPU.

[0118] A further embodiment of the present invention further discloses a computer-readable storage medium, on which a communication program is stored. When the communication program is executed by a processor, the communication method of the embodiment of the first aspect of the present invention is implemented.

[0119] According to the computer-readable storage medium of an embodiment of the present invention, when the communication program stored thereon is executed, communication between the host and the slave can be achieved by setting a plurality of trigger modes, thereby avoiding repeated single write access of the bus and improving the utilization rate of the bus. At the same time, by setting a plurality of trigger modes, the problem of a single and inflexible trigger mode during the communication between the host and the slave is overcome. In the external automatic trigger mode, by setting a plurality of trigger input sources and inputting a trigger input signal to the trigger multiplexer, the problem of being unable to synchronously send multiple events at the system level during the communication process is overcome, thereby improving the reliability of the communication. Furthermore, after the host configures the mapping relationship between the temporary buffer area for receiving data and the buffer area for receiving data, the data sent by the slave is sorted by using a hardware programming device, thereby reducing the workload of the CPU during the communication process and thereby improving the working efficiency of the CPU.

[0120] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "illustrative embodiments," "example," "specific example," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example.

[0121] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the claims and their equivalents.

Claims

1. A communication method, characterized in that: For realizing communication between a host and a slave, the communication method includes: When the host communicates with the slave, the host sends a trigger pulse to the slave so that the slave samples data in response to the trigger pulse, and receives the data sent by the slave; The host can automatically send the trigger pulse to the slave through a variety of trigger modes.

2. The communication method according to claim 1, wherein: One of the multiple trigger modes includes an internal automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the internal automatic trigger mode, including: If the host has not sent the trigger pulse before, the host performs a first timing, and when the first timing reaches a first time threshold, sends a trigger pulse to the slave.

3. The communication method according to claim 2, wherein: After the first timing reaches the first time threshold and a trigger pulse is sent to the slave, the method further includes: If the host receives the data sent by the slave within the first preset time, a second timing is performed. When the second timing reaches a second time threshold, the next trigger pulse is automatically sent to the slave, and this step is repeated to automatically send the trigger pulse to the slave multiple times, wherein the data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

4. The communication method according to claim 1, wherein: One of the multiple trigger modes includes an internal automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the internal automatic trigger mode, including: If the host has sent the trigger pulse before, the host performs a second timing after receiving the data sent by the slave last time. When the second timing reaches a second time threshold, the host automatically sends the next trigger pulse to the slave, and repeats this step to automatically send the trigger pulse to the slave multiple times. The data is sampled by the slave in response to the trigger pulse after receiving the trigger pulse.

5. The communication method according to claim 3 or 4, characterized in that: After the host sends the trigger pulse to the slave, the method further includes: If the host does not receive the data sent by the slave within the first preset time or the host does not receive the data frame end pulse sent by the slave, the host will no longer send the trigger pulse.

6. The communication method according to claim 2 or 3, characterized in that: Before the host performs the first timing, the method further includes: After receiving the first parameter setting information, the host starts the first timing, wherein the first parameter setting information includes the first trigger parameter that has been set.

7. The communication method according to claim 6, wherein: The first trigger parameter includes the first time threshold and the length of the trigger pulse.

8. The communication method according to claim 2 or 3, characterized in that: The first time threshold is determined according to the model of the slave device.

9. The communication method according to claim 3 or 4, characterized in that: Before the second timing, the method further includes: When the host receives the data frame end pulse sent by the slave, the second timing starts.

10. The communication method according to claim 9, wherein: The data frame end pulse includes any one of the falling edge of the end pulse of the slave response data frame, the falling edge or rising edge of the synchronization or calibration pulse of the slave response data frame, the falling edge or rising edge of the status and communication half byte of the slave response data frame, the falling edge or rising edge of the fast channel data half byte of the slave response data frame, and the falling edge or rising edge of the cyclic redundancy check half byte of the slave response data frame.

11. The communication method according to claim 1, wherein: One of the multiple modes includes an external automatic trigger mode, and the host automatically sends the trigger pulse to the slave through the external automatic trigger mode, including: When the host detects the trigger signal, it starts the third timing, and when the third timing reaches a third time threshold, it sends a trigger pulse to the slave.

12. The communication method according to claim 11, wherein: Before the host performs the third timing, the method further includes: After receiving the second parameter setting information, the host starts the third timing, wherein the second parameter setting information includes the set second trigger parameter.

13. The communication method according to claim 12, wherein: The second trigger parameter includes the third time threshold and the length of the trigger pulse.

14. The communication method according to claim 11, wherein: The third time threshold is determined according to the model of the slave device.

15. The communication method according to claim 11, wherein: Also includes: A trigger input signal is input to the trigger multiplexer through a trigger input source, so that the trigger multiplexer outputs the trigger signal.

16. The communication method according to claim 15, characterized in that: The trigger input source periodically or irregularly inputs a trigger input signal to the trigger multiplexer, so that the trigger multiplexer periodically or irregularly outputs the trigger signal.

17. The communication method according to claim 15, characterized in that: Before the trigger input signal is input to the trigger multiplexer through the trigger input source, it also includes: A target trigger input source is selected from a plurality of trigger input sources to input a trigger input signal to the trigger multiplexer through the target trigger input source.

18. The communication method according to claim 17, wherein: The target trigger input source is selected from a plurality of trigger input sources by controlling a switch.

19. The communication method according to claim 18, wherein: There are multiple control switches, and the multiple control switches are connected to the multiple trigger input sources in a one-to-one correspondence.

20. The communication method according to claim 17, wherein: The multiple trigger input sources at least include: a timer module, a pulse width modulation module, a universal timer module, a comparator module, a successive approximation analog-to-digital converter module, and a Delta-Sigma analog-to-digital conversion module.

21. The communication method according to claim 4 or 11, characterized in that: After each timing is completed, the timing data is cleared.

22. The communication method according to claim 1, wherein: Also includes: The host selects the corresponding trigger mode by receiving a trigger mode enable signal, wherein different trigger mode enable signals enable different trigger modes.

23. The communication method according to claim 1, wherein: The trigger pulse is a low-level trigger pulse.

24. The communication method according to claim 1, wherein: Also includes: When the host receives the trigger mode switching signal, it switches the current trigger mode to another trigger mode among the multiple trigger modes to automatically send the trigger pulse to the slave, wherein the trigger mode switching signal includes an enable signal of the another trigger mode to be switched.

25. The communication method according to claim 1, wherein: Also includes: The host arranges the mapping relationship between the temporary buffer area for receiving data and the buffer area for receiving data so as to sort the data sent by the slave.

26. The communication method according to claim 25, characterized in that The host configures a mapping relationship between a temporary buffer area for receiving data and a buffer area for receiving data to sort the data sent by the slave, including: The host stores the received data in the received data temporary buffer area; Programming the storage pointers of the data in the temporary buffer area of ​​the received data so that the data are arranged in a target order; The data are sequentially stored in the received data buffer area according to the programmed storage pointer.

27. The communication method according to claim 26, characterized in that: The pointers of the data in the received data temporary buffer area are programmed by a hardware programming device.

28. The communication method according to claim 1, wherein: The host includes a microcontroller unit.

29. The communication method according to claim 1, wherein: The slave includes a sensor.

30. The communication method according to claim 29, wherein: The sensor includes a sensor that communicates using an SPC protocol.

31. A communication device, characterized in that: include: A processor, a memory, and a communication program stored in the memory and executable on the processor, wherein the communication program, when executed by the processor, implements the communication method according to any one of claims 1 to 30.

32. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a communication program, and when the communication program is executed by the processor, the communication method according to any one of claims 1 to 30 is implemented.