Ranging method, apparatus, system, and readable storage medium
By acquiring the system clock offset time and correcting the receiving time, and using the high-precision system clock to calculate the distance, the problem of insufficient accuracy in the one-way ranging scheme is solved, and higher ranging accuracy is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2022-02-28
- Publication Date
- 2026-07-07
AI Technical Summary
Existing one-way ranging schemes have insufficient accuracy in calculating distances, resulting in significant errors.
By acquiring the system clock offset time of the first and second devices and the transmission and reception times of the ranging signal, the distance is calculated using a high-precision system clock, including synchronization time and correction of the reception time, to improve ranging accuracy.
It improves the accuracy of distance measurement and reduces errors.
Smart Images

Figure CN116699513B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminals, and more particularly to a ranging method, apparatus, system, and readable storage medium. Background Technology
[0002] One-way ranging is a widely used technology. It allows a master device to determine the distance between itself and a slave device. For example, it can be used to determine the distance between a mobile phone and a paired Bluetooth headset.
[0003] Currently, the main solution for one-way ranging is to read the signal strength of the slave device from the master device and then use the signal strength to calculate the distance between the master and slave devices.
[0004] However, the distance calculated by existing one-way ranging schemes is not accurate enough and has a large error. Summary of the Invention
[0005] This application provides a ranging method, apparatus, system, and readable storage medium, which can solve the problems of insufficient accuracy and large error in distance calculation obtained by existing one-way ranging schemes.
[0006] In a first aspect, embodiments of this application provide a ranging method applied to a first device, comprising:
[0007] The first offset time and the first moment are obtained. The first offset time is the time difference between the system clocks of the first device and the second device. The first moment is the moment when the second device sends the ranging signal, and it is obtained based on the system clock of the second device. The second moment when the ranging signal is received is obtained. The second moment is obtained based on the third moment when the first device starts receiving the ranging signal and the receiving interval. The third moment is obtained based on the fourth moment when the ranging signal receiving chip starts receiving the ranging signal, the system clock of the first device, and the chip clock conversion of the ranging signal receiving chip. The receiving interval is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal. The distance between the first device and the second device is obtained based on the first offset time, the first moment, and the second moment.
[0008] In one possible implementation of the first aspect, the first device can be a mobile phone, tablet computer, augmented reality (AR) / virtual reality (VR) device, large-screen device, laptop computer, netbook, personal digital assistant (PDA), etc. The first device needs to have the ability to receive ranging signals. This application embodiment does not impose any restrictions on the specific type of the first device. The second device can be a terminal device including a ranging signal transmission function, or the first device having a ranging signal transmission function. For example, a terminal device including a ranging signal transmission function can be an electronic tag, a smart key fob including an electronic tag, Bluetooth headset, etc.
[0009] In the first aspect, the first device acquires a first offset time from the system clock of the second device and synchronizes the system time of the first device with that of the second device. Then, it acquires the second moment when it receives the ranging signal sent by the second device and the first moment when the second device sends the ranging signal. Finally, the distance between the first device and the second device can be calculated based on the first offset time, the first moment, and the second moment. Because the system clock has high precision, the distance calculated based on the moments acquired from the system clock is more accurate and has less error.
[0010] In some implementations, obtaining the second time when the ranging signal is received includes: the ranging signal receiving chip obtaining a fourth time and sending the fourth time to its driver program. The driver program then modifies the fourth time to a third time based on the system clock. Finally, the driver program sends the third time to the application layer, where the application layer adds the receiving interval to the third time to obtain the second time.
[0011] In some implementations, the driver for the ranging signal receiving chip corrects the fourth time to a third time based on the system clock, including: the driver for the ranging signal receiving chip corrects the fourth time to a third time based on the system clock when it receives the fourth time. Alternatively, the driver for the ranging signal receiving chip corrects the fourth time to a third time based on the system clock in response to a parameter acquisition instruction from the application layer.
[0012] In some implementations, obtaining the second time when the ranging signal is received includes: the ranging signal receiving chip obtaining a fourth time. The driver program of the ranging signal receiving chip responds to a parameter acquisition instruction, obtains the fourth time from the ranging signal receiving chip, and corrects the fourth time to a third time based on the system clock. The driver program of the ranging signal receiving chip sends the third time to the application layer, where an interval time is added to the third time to obtain the second time.
[0013] In some implementations, the fourth time point is corrected to a third time point based on the system clock, including: simultaneously acquiring a fifth time point based on the system clock and a sixth time point based on the chip clock through the driver program of the ranging signal receiving chip, wherein the time difference between the fourth time point and the sixth time point is a second offset time. The third time point is then obtained based on the fifth time point and the second offset time.
[0014] In some implementations, obtaining the distance between the first device and the second device based on a first offset time, a first moment, and a second moment includes: obtaining the flight time of the ranging signal based on the first offset time, the first moment, and the second moment; and obtaining the distance between the first device and the second device based on the propagation speed and flight time of the ranging signal in the medium.
[0015] In some implementations, obtaining the flight time of the ranging signal based on a first offset time, a first moment, and a second moment includes: correcting the first moment to a seventh moment based on the first device system clock based on the first offset time; and subtracting the seventh moment from the second moment to obtain the flight time of the ranging signal. Alternatively, correcting the second moment to an eighth moment based on the second device system clock based on the first offset time; and subtracting the first moment from the eighth moment to obtain the flight time of the ranging signal.
[0016] In some implementations, obtaining the first offset time includes: the first device sequentially sending at least one synchronization command to the second device, and recording the ninth time when each synchronization command is sent based on the first device's system clock. A synchronization feedback identifier is received from the second device, and the tenth time when each synchronization feedback identifier is received is recorded based on the first device's system clock. The synchronization feedback identifier includes the eleventh time when the second device receives the synchronization command and the twelfth time when the second device sends the synchronization feedback identifier, the eleventh and twelfth times being obtained based on the second device's system clock. The first offset time is obtained based on the ninth, tenth, eleventh, and twelfth times.
[0017] In some implementations, obtaining the first moment includes: sending a first moment query command to a second device; and receiving at least one first moment sent by the second device.
[0018] In some implementations, obtaining the first moment includes: sending a first moment query command to a second device; receiving device identification information sent by the second device; and obtaining at least one pre-set first moment based on the device identification information.
[0019] Secondly, embodiments of this application provide a ranging method applied to a second device, comprising: acquiring a first moment for transmitting a ranging signal; transmitting the first moment to a first device; and transmitting the ranging signal at the first moment based on the system clock of the second device.
[0020] In some implementations, before sending the ranging signal at a first time based on the system clock of the second device, the method further includes: receiving at least one synchronization command from the first device, and recording an eleventh time when each synchronization command is received based on the system clock of the second device. In response to each synchronization command, a synchronization feedback identifier is sent to the first device, the synchronization feedback identifier including the eleventh time and a twelfth time when the synchronization feedback identifier is sent, the twelfth time being obtained based on the system clock of the second device.
[0021] In some implementations, acquiring the first moment of transmitting the ranging signal includes: confirming synchronization with the first device. The first moment is defined as the time elapsed after confirming synchronization.
[0022] In some implementations, obtaining the first moment of transmitting the ranging signal includes: receiving a ranging signal transmission command and obtaining at least one first moment included in the ranging signal transmission command. Alternatively, obtaining at least one preset first moment based on the device identification information of the second device.
[0023] In some implementations, sending a first moment to a first device includes: after acquiring the first moment, sending the first moment to the first device; or, in response to a first moment query command from the first device, sending at least one first moment to the first device.
[0024] In some implementations, sending the first moment to the first device further includes: responding to a first moment query command from the first device and sending the device identification information of the second device to the first device.
[0025] Thirdly, embodiments of this application provide a ranging system, including a first device and a second device. The system includes: the first device acquiring a first offset time and a first moment, where the first offset time is the time difference between the system clocks of the first and second devices, and the first moment is the moment the second device sends a ranging signal, obtained based on the system clock of the second device. The second device sends the ranging signal at the first moment, based on its system clock. The first device acquires a second moment when it receives the ranging signal, obtained based on a third moment when it begins receiving the ranging signal and a receiving interval. The third moment is obtained based on a fourth moment when the ranging signal receiving chip begins receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal. The first device obtains the distance between the first device and the second device based on the first offset time, the first moment, and the second moment.
[0026] Fourthly, embodiments of this application provide a ranging device applied to a first device, comprising:
[0027] The acquisition module is used to acquire the first offset time and the first moment. The first offset time is the time difference between the system clock of the first device and the system clock of the second device. The first moment is the moment when the second device sends the ranging signal. The first moment is obtained based on the system clock of the second device.
[0028] The acquisition module is also used to acquire the second moment when the ranging signal is received. The second moment is obtained based on the third moment when the first device starts receiving the ranging signal and the receiving interval time. The third moment is obtained based on the fourth moment when the ranging signal receiving chip starts receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval time is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal.
[0029] The calculation module is used to obtain the distance between the first device and the second device based on the first offset time, the first moment, and the second moment.
[0030] In some implementations, the acquisition module is specifically used by the ranging signal receiving chip to acquire a fourth time and send the fourth time to the driver program of the ranging signal receiving chip. The driver program of the ranging signal receiving chip corrects the fourth time to a third time based on the system clock. The driver program of the ranging signal receiving chip sends the third time to the application layer, where the application layer adds the receiving interval time to the third time to obtain the second time.
[0031] In some implementations, the acquisition module, specifically the driver of the ranging signal receiving chip, corrects the fourth time to a third time based on the system clock upon receiving the fourth time. Alternatively, the driver of the ranging signal receiving chip responds to a parameter acquisition command from the application layer and corrects the fourth time to a third time based on the system clock.
[0032] In some implementations, the acquisition module is specifically used by the ranging signal receiving chip to acquire the fourth time. The driver program for the ranging signal receiving chip responds to a parameter acquisition instruction, acquires the fourth time from the ranging signal receiving chip, and corrects the fourth time to a third time based on the system clock. The driver program for the ranging signal receiving chip sends the third time to the application layer, where an interval time is added to the third time to obtain the second time.
[0033] In some implementations, the acquisition module is specifically used to acquire a fifth time point based on the system clock and a sixth time point based on the chip clock via the driver program of the ranging signal receiving chip. The time difference between the fourth and sixth times points is a second offset time. The third time point is obtained based on the fifth time point and the second offset time.
[0034] In some implementations, the calculation module is specifically used to obtain the flight time of the ranging signal based on a first offset time, a first moment, and a second moment. The distance between the first device and the second device is obtained based on the propagation speed and flight time of the ranging signal in the medium.
[0035] In some implementations, the calculation module is specifically used to correct the first time point to a seventh time point based on the first device system clock according to the first offset time; and subtract the seventh time point from the second time point to obtain the flight time of the ranging signal. Alternatively, the second time point is corrected to an eighth time point based on the second device system clock according to the first offset time; and the first time point is subtracted from the eighth time point to obtain the flight time of the ranging signal.
[0036] In some implementations, the acquisition module is specifically configured to sequentially send at least one synchronization command to the second device, and record the ninth time when each synchronization command is sent based on the system clock of the first device. It receives a synchronization feedback identifier from the second device, and records the tenth time when each synchronization feedback identifier is received based on the system clock of the first device. The synchronization feedback identifier includes the eleventh time when the second device receives the synchronization command and the twelfth time when the second device sends the synchronization feedback identifier, the eleventh and twelfth times being obtained based on the system clock of the second device. A first offset time is obtained based on the ninth, tenth, eleventh, and twelfth times.
[0037] In some implementations, the acquisition module is specifically used to send a first-time query command to the second device. It also receives at least one first-time value sent by the second device.
[0038] In some implementations, the acquisition module is specifically used to send a first-time query command to the second device. It receives device identification information sent by the second device. Based on the device identification information, it acquires at least one pre-set first time.
[0039] Fifthly, embodiments of this application provide a ranging device applied to a second device, comprising: an acquisition module for acquiring a first moment for transmitting a ranging signal; a transmission module for transmitting the first moment to a first device; and a transmission module for transmitting the ranging signal at the first moment based on the system clock of the second device.
[0040] In some embodiments, the device further includes a receiving module for receiving at least one synchronization command from a first device, and recording an eleventh time when each synchronization command is received based on the system clock of a second device. In response to each synchronization command, a synchronization feedback identifier is sent to the first device, the synchronization feedback identifier including the eleventh time and a twelfth time when the synchronization feedback identifier is sent, the twelfth time being obtained based on the system clock of the second device.
[0041] In some implementations, the acquisition module is specifically used to confirm that synchronization with the first device is complete. The time elapsed after a preset period following the confirmation of successful synchronization is taken as the first moment.
[0042] In some implementations, the acquisition module is specifically configured to receive a ranging signal transmission command and acquire at least one first moment included in the ranging signal transmission command. Alternatively, it may acquire at least one pre-set first moment based on the device identification information of the second device.
[0043] In some embodiments, the sending module is further configured to send the first time to the first device after acquiring the first time. Alternatively, the apparatus may further include a response module configured to send at least one first time to the first device in response to a first time query command from the first device.
[0044] In some implementations, the response module is also used to respond to a first-moment query command from the first device and send the device identification information of the second device to the first device.
[0045] In a sixth aspect, embodiments of this application provide an electronic device, including a memory, a processor, a ranging signal receiving component, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method provided in the first aspect.
[0046] In a seventh aspect, embodiments of this application provide an electronic device, including a memory, a processor, a ranging signal transmitting component, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method provided in the second aspect.
[0047] Eighthly, embodiments of this application provide a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method provided in the first aspect.
[0048] In a ninth aspect, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in the second aspect.
[0049] In a tenth aspect, embodiments of this application provide a computer program product that, when run on a first device, causes a terminal device to execute the method provided in the first aspect.
[0050] In the eleventh aspect, embodiments of this application provide a computer program product that, when run on a second device, causes a terminal device to execute the method provided in the second aspect described above.
[0051] In a twelfth aspect, embodiments of this application provide a chip system including a memory and a processor, wherein the processor executes a computer program stored in the memory to implement the method provided in the first aspect.
[0052] In a thirteenth aspect, embodiments of this application provide a chip system including a memory and a processor, the processor executing a computer program stored in the memory to implement the method provided in the second aspect.
[0053] In a fourteenth aspect, embodiments of this application provide a chip system including a processor coupled to a computer-readable storage medium provided in the eighth aspect. The processor executes a computer program stored in the computer-readable storage medium to implement the method provided in the first aspect.
[0054] In a fifteenth aspect, embodiments of this application provide a chip system including a processor coupled to a computer-readable storage medium provided in the ninth aspect. The processor executes a computer program stored in the computer-readable storage medium to implement the method provided in the second aspect.
[0055] It is understood that the beneficial effects of aspects two through fifteen above can be found in the relevant descriptions in aspect one above, and will not be repeated here. Attached Figure Description
[0056] Figure 1 This illustration shows an application scenario diagram of a ranging method provided in an embodiment of this application;
[0057] Figure 2 This illustration shows a schematic diagram of the structure of a first device in a ranging method provided in an embodiment of this application;
[0058] Figure 3 This paper shows a schematic diagram of the software structure of the first device in a ranging method provided in an embodiment of this application;
[0059] Figure 4 A schematic flowchart of a ranging method provided in an embodiment of this application is shown;
[0060] Figure 5 This paper shows a schematic diagram of the system structure of the first device in a ranging method provided in an embodiment of this application;
[0061] Figure 6 A schematic diagram of a process for obtaining T2 in a ranging method provided in an embodiment of this application is shown;
[0062] Figure 7 This paper illustrates another flowchart for obtaining T2 in the ranging method provided in an embodiment of this application.
[0063] Figure 8 This paper shows a structural block diagram of a ranging device applied to a first device according to an embodiment of the present application;
[0064] Figure 9 This paper shows a structural block diagram of a ranging device applied to a second device according to an embodiment of the present application;
[0065] Figure 10 A structural block diagram of a first device provided in an embodiment of this application;
[0066] Figure 11 This is a structural block diagram of a second device provided in an embodiment of this application. Detailed Implementation
[0067] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0068] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0069] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0070] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection."
[0071] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0072] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0073] In existing technologies, unidirectional ranging often involves acquiring the signal strength of the first device when connected to the second device, and then using the functional relationship between signal strength and distance to inversely calculate the distance between the first and second devices. However, due to the low accuracy of signal strength and the potential for signal interference that can cause signal strength changes, the ranging results are not accurate and have a large error.
[0074] This application provides a ranging method applied to a first device, comprising: acquiring a first offset time and a first moment, wherein the first offset time is the time difference between the system clock of the first device and the system clock of the second device, and the first moment is the moment when the second device sends a ranging signal, and the first moment is obtained based on the system clock of the second device; acquiring a second moment when the ranging signal is received, wherein the second moment is obtained based on a third moment when the first device starts receiving the ranging signal and a receiving interval time, wherein the third moment is obtained based on a fourth moment when the ranging signal receiving chip starts receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip; and the receiving interval time is the interval between the fourth moment and the moment when the ranging signal receiving chip receives the ranging signal; and acquiring the distance between the first device and the second device based on the first offset time, the first moment, and the second moment. Furthermore, a ranging method applied to a second device is provided, comprising: acquiring a first moment when the ranging signal is sent; and sending the ranging signal at the first moment based on the system clock of the second device.
[0075] In this application, the first device acquires a first offset time from the system clock of the second device and synchronizes the system time of the first device with that of the second device. Then, it acquires the second moment when it receives the ranging signal sent by the second device and the first moment when the second device sends the ranging signal. Finally, the distance between the first device and the second device can be calculated based on the first offset time, the first moment, and the second moment. Because the system clock has high precision, the distance calculated based on the moments acquired from the system clock is more accurate and has less error.
[0076] In this application, ultrasonic ranging between the first and second devices is used as an example for illustration. It should be noted that in other cases, ranging between the first and second devices can also be achieved through laser ranging, infrared ranging, etc. This application does not limit the medium used for ranging.
[0077] Figure 1 The illustration shows an application scenario diagram of a ranging method provided in an embodiment of this application.
[0078] refer to Figure 1 This includes at least one first device 100 and at least one second device 200. The first device 100 can be a mobile phone, tablet computer, augmented reality (AR) / virtual reality (VR) device, large-screen device, laptop computer, netbook, personal digital assistant (PDA), etc. The first device 100 needs to have the ability to receive ranging signals. This application embodiment does not impose any restrictions on the specific type of the first device 100. For ultrasonic ranging, the first device 100 needs to have a recording device capable of receiving ultrasonic waves, such as a microphone capable of receiving ultrasonic waves and a corresponding audio chip. For example, the audio chip can be a high-fidelity (HiFi) chip.
[0079] The second device 200 can be a terminal device that includes a ranging signal transmission function, or a first device 100 that has a ranging signal transmission function. For example, a terminal device that includes a ranging signal transmission function can be an electronic tag, a smart key fob containing an electronic tag, a Bluetooth headset, etc. For ultrasonic ranging, the second device 200 needs to have a device capable of emitting ultrasonic waves.
[0080] The first device 100 can record ultrasonic signals using an audio chip and a microphone. The second device 200 can transmit ranging signals using an ultrasonic transmitter; the ranging signals can be ultrasonic pulse signals of a specific frequency or square wave signals, etc.
[0081] Figure 2 A schematic diagram of the structure of a first device in a ranging method provided in an embodiment of this application is shown.
[0082] exist Figure 2In this context, the first device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0083] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the first device 100. In other embodiments of this application, the first device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0084] For example, when the first device 100 is a mobile phone, tablet computer or large-screen device, it may include all the components shown in the figure, or it may include only some of the components shown in the figure.
[0085] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0086] The controller can serve as the central nervous system and command center of the first device 100. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0087] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0088] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0089] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the first device 100.
[0090] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface.
[0091] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via the PCM bus interface.
[0092] In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface. Both the I2S interface and the PCM interface can be used for audio communication.
[0093] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus, converting the data to be transmitted between parallel and non-parallel communication.
[0094] In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality.
[0095] In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface to enable the function of playing music through Bluetooth headphones.
[0096] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the shooting function of the first device 100. The processor 110 and the display screen 194 communicate via the DSI interface to enable the display function of the first device 100.
[0097] The GPIO interface can be configured via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to a camera 193, a display screen 194, a wireless communication module 160, an audio module 170, a sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0098] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge the first device 100, and can also be used for data transfer between the first device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0099] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the first device 100. In other embodiments of this application, the first device 100 may also adopt different interface connection methods or a combination of multiple interface connection methods as described in the above embodiments.
[0100] The charging management module 140 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130.
[0101] In some wireless charging embodiments, the charging management module 140 can receive wireless charging input through the wireless charging coil of the first device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device through the power management module 141.
[0102] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance).
[0103] In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be located in the same device.
[0104] The wireless communication function of the first device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.
[0105] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the first device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0106] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the first device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1.
[0107] In some embodiments, at least some functional modules of the mobile communication module 150 may be located in the processor 110.
[0108] In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the same device as at least some modules of the processor 110.
[0109] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194.
[0110] In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0111] The wireless communication module 160 can provide solutions for wireless communication applications on the first device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0112] In some embodiments, antenna 1 of the first device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that the first device 100 can communicate with networks and other devices through wireless communication technology.
[0113] Wireless communication technologies can include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BitTorrent, GNSS, WLAN, NFC, FM, and / or IR technologies. GNSS can include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).
[0114] The first device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0115] The display screen 194 is used to display images, videos, etc. For example, the teaching videos and user action video in the embodiments of this application. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc.
[0116] In some embodiments, the first device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0117] The first device 100 can perform shooting functions through an ISP, camera 193, video codec, GPU, display 194, and application processor.
[0118] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0119] Camera 193 is used to capture still images or videos. An object passes through the lens, generating an optical image that is projected onto a photosensitive element. The focal length of the lens indicates the camera's field of view; a smaller focal length indicates a larger field of view. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts light signals into electrical signals, which are then transmitted to the ISP (Image Signal Processor) for conversion into digital image signals. The ISP outputs the digital image signals to the DSP (Digital Signal Processor) for processing. The DSP converts the digital image signals into standard RGB, YUV, or other image signal formats.
[0120] In this application, the first device 100 may include two or more cameras 193 with different focal lengths.
[0121] A digital signal processor (DSP) is used to process digital signals. Besides digital image signals, it can also process other digital signals. For example, when the first device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0122] Video codecs are used to compress or decompress digital video. The first device 100 may support one or more video codecs. Thus, the first device 100 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0123] NPU stands for Neural Network (NN) Computing Processor. By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs can enable intelligent cognitive applications in devices such as image recognition, facial recognition, speech recognition, and text understanding.
[0124] In this embodiment, the NPU or other processor can be used to perform operations such as analysis and processing of images in the video stored in the first device 100.
[0125] The external storage interface 120 can be used to connect an external storage card, such as a Micro SD card, to expand the storage capacity of the first device 100. The external storage card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external storage card.
[0126] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of the first device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function (such as sound playback, image playback, etc.). The data storage area may store data created during the use of the first device 100 (such as audio data, phonebook, etc.).
[0127] In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0128] The first device 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, and an application processor.
[0129] The audio module 170 is used to convert digital audio signals into analog audio signals for output, and also to convert analog audio inputs into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0130] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The first device 100 can listen to music or hands-free calls through the speaker 170A. For example, the speaker can play the comparison analysis results provided in the embodiments of this application.
[0131] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the first device 100 is receiving a telephone call or voice message, the receiver 170B can be brought close to the listener's ear to receive the voice message.
[0132] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. The first device 100 may include at least one microphone 170C. In some embodiments, the first device 100 may include two microphones 170C, which, in addition to acquiring sound signals, can also perform noise reduction. When using ultrasonic ranging, the selected microphone 170C needs to be able to record ultrasonic audio signals.
[0133] In other embodiments, the first device 100 may also be equipped with three, four or more microphones 170C to collect sound signals, reduce noise, identify the source of sound, and perform directional recording, etc.
[0134] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0135] The pressure sensor 180A is used to sense pressure signals and can convert pressure signals into electrical signals.
[0136] In some embodiments, pressure sensor 180A may be disposed on display screen 194. Pressure sensor 180A can be of many types, such as resistive pressure sensor, inductive pressure sensor, capacitive pressure sensor, etc. A capacitive pressure sensor may include at least two parallel plates with conductive material. When force is applied to pressure sensor 180A, the capacitance between the electrodes changes. First device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 194, first device 100 detects the touch operation intensity based on pressure sensor 180A. First device 100 may also calculate the touch position based on the detection signal from pressure sensor 180A.
[0137] In some embodiments, touch operations applied to the same touch location but with different touch intensity can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.
[0138] The gyroscope sensor 180B can be used to determine the motion attitude of the first device 100. In some embodiments, the gyroscope sensor 180B can determine the angular velocity of the first device 100 about three axes (i.e., the x, y, and z axes). The gyroscope sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the shake of the first device 100, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the first device 100 by moving in the opposite direction, thus achieving image stabilization. The gyroscope sensor 180B can also be used in navigation and motion-sensing game scenarios.
[0139] The barometric pressure sensor 180C is used to measure air pressure. In some embodiments, the first device 100 calculates altitude using the air pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.
[0140] The magnetic sensor 180D includes a Hall sensor. The first device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. In some embodiments, when the first device 100 is a flip phone, the first device 100 can detect the opening and closing of the flip cover using the magnetic sensor 180D. Then, based on the detected opening and closing state of the cover or the flip cover, features such as automatic flip unlocking can be set.
[0141] The accelerometer 180E can detect the magnitude of acceleration of the first device 100 in various directions (typically three axes). When the first device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic devices, and can be applied to applications such as screen orientation switching and pedometers.
[0142] A distance sensor 180F is used to measure distance. The first device 100 can measure distance via ultrasound, infrared, or laser. In some embodiments, during a shooting scene, the first device 100 can utilize the distance sensor 180F to measure distance for rapid focusing.
[0143] The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The first device 100 emits infrared light outward through the LED. The first device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the first device 100. When insufficient reflected light is detected, the first device 100 can determine that there is no object near the first device 100. The first device 100 may use the proximity sensor 180G to detect when a user holds the first device 100 close to their ear for a phone call, so as to automatically turn off the screen to save power. The proximity sensor 180G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.
[0144] The ambient light sensor 180L is used to sense the ambient light intensity. The first device 100 can adaptively adjust the brightness of the display screen 194 based on the sensed ambient light intensity. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also work with the proximity sensor 180G to detect whether the first device 100 is in a pocket to prevent accidental touches.
[0145] The fingerprint sensor 180H is used to collect fingerprints. The first device 100 can use the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.
[0146] Temperature sensor 180J is used to detect temperature. In some embodiments, the first device 100 uses the temperature detected by temperature sensor 180J to execute a temperature handling strategy. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, the first device 100 performs thermal protection by reducing the performance of a processor located near temperature sensor 180J to reduce power consumption. In other embodiments, when the temperature is below another threshold, the first device 100 heats battery 142 to prevent abnormal shutdown of the first device 100 due to low temperature. In still other embodiments, when the temperature is below yet another threshold, the first device 100 boosts the output voltage of battery 142 to prevent abnormal shutdown due to low temperature.
[0147] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of the first device 100, in a different position than display screen 194.
[0148] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals from vibrating bone fragments in the human vocal cords. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals.
[0149] In some embodiments, the bone conduction sensor 180M can also be integrated into the headphones to form bone conduction headphones. The audio module 170 can analyze the vibration signal of the sound-vibrating bone block acquired by the bone conduction sensor 180M to extract the voice signal and realize the voice function. The application processor can analyze the heart rate information based on the blood pressure fluctuation signal acquired by the bone conduction sensor 180M to realize the heart rate detection function.
[0150] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. The first device 100 can receive button input and generate key signal inputs related to user settings and function control of the first device 100.
[0151] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0152] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0153] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the first device 100. The first device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The first device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the first device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the first device 100 and cannot be separated from the first device 100.
[0154] It should be noted that the structure of the second device 200 can be similar to that of the first device 100, or it can be simplified based on the structure of the first device 100. However, the second device 200 also needs to include a ranging signal transmitting module, such as an ultrasonic transmitter, an infrared transmitter, or a laser transmitter.
[0155] Figure 3 This paper shows a schematic diagram of the software structure of the first device in a ranging method provided in an embodiment of this application.
[0156] The operating system in the first device can be Android, Microsoft Windows, Apple iOS, or Harmony OS, etc. Here, we will use Harmony OS as an example.
[0157] In some embodiments, the HarmonyOS system can be divided into four layers, including the kernel layer, system service layer, framework layer, and application layer, with the layers communicating with each other through software interfaces.
[0158] like Figure 3 As shown, the kernel layer includes the Kernel Abstraction Layer (KAL) and the driver subsystem. The KAL contains multiple kernels, such as the Linux Kernel for the Linux system and the LiteOS kernel for lightweight IoT systems. The driver subsystem can include a Hardware Driver Foundation (HDF). The HDF provides unified peripheral access capabilities and a framework for driver development and management. A multi-kernel kernel layer can select the appropriate kernel for processing based on system requirements.
[0159] The system service layer is the core capability set of the HarmonyOS system. It provides services to applications through the framework layer. This layer may include:
[0160] The system's basic capability subsystems provide foundational capabilities for the operation, scheduling, and migration of distributed applications across multiple devices within the HarmonyOS system. These may include subsystems such as distributed soft bus, distributed data management, distributed task scheduling, multi-language runtime, common basic libraries, multi-modal input, graphics, security, artificial intelligence (AI), and user program frameworks. Among these, the multi-language runtime provides runtime environments in C, C++, or JavaScript (JS) and basic system class libraries. It can also provide runtime environments for statically compiled Java programs (i.e., the parts of the application or framework layer developed using the Java language).
[0161] Basic Software Service Subsystem Set: Provides common and general software services for the HarmonyOS system. This may include subsystems such as event notification, telephony, multimedia, Design For X (DFX), MSDP & DV, etc.
[0162] Enhanced Software Service Subsystem Set: Provides HarmonyOS with differentiated enhanced software services for different devices. This may include dedicated subsystems for smart screens, wearables, and the Internet of Things (IoT).
[0163] Hardware service subsystem set: Provides hardware services for the HarmonyOS system. This may include subsystems such as location services, biometric recognition, wearable hardware services, and IoT hardware services.
[0164] The framework layer provides HarmonyOS application development with user program frameworks and capability frameworks in multiple languages, including Java, C, C++, and JS; two user interface (UI) frameworks (JavaUI framework for Java and JS UI framework for JS); and multi-language framework application programming interfaces (APIs) for various software and hardware services. The APIs supported by HarmonyOS devices will vary depending on the degree of system componentization.
[0165] The application layer includes system applications and third-party non-system applications. System applications can include applications that are installed by default on electronic devices, such as the desktop, control bar, settings, and phone. Extended applications can be non-essential applications developed and designed by the electronic device manufacturer, such as electronic device managers, device migration tools, note-taking apps, and weather apps. Third-party non-system applications can be applications developed by other manufacturers that can run on the HarmonyOS system, such as games, navigation, social networking, or shopping apps.
[0166] Applications in the HarmonyOS system consist of one or more meta-applications (Feature Ability, FA) or meta-services (Particle Ability, PA). FAs have a user interface (UI) and provide the ability to interact with the user. PAs, on the other hand, do not have a UI but provide the ability to run background tasks and a unified data access abstraction. PAs primarily support FAs, for example, by providing computing power as a background service or providing data access capabilities as a data warehouse. Applications developed based on FAs or PAs can implement specific business functions, support cross-device scheduling and distribution, and provide users with a consistent and efficient application experience.
[0167] Multiple electronic devices running the HarmonyOS system can achieve hardware cooperation and resource sharing through distributed soft bus, distributed device virtualization, distributed data management, and distributed task scheduling.
[0168] It should be noted that the operating system of the second device can be the same as or different from that of the first device. Alternatively, the first and second devices can use the same operating system but different kernels. For example, when both the first and second devices use HarmonyOS, the first device can use the Linux kernel, while the second device can use the LiteOS kernel.
[0169] Figure 4 A schematic flowchart of a ranging method provided in an embodiment of this application is shown. It is provided as an example and not as a limitation. The method can be applied to the first device 100 and the second device 200 described above.
[0170] S310. The first device synchronizes the system clock with the second device to obtain the first offset time.
[0171] In some implementations, the first device and the second device can synchronize their system clocks using the same wireless communication module. For example, both the first device and the second device can have a Bluetooth module or a Wireless Fidelity (Wi-Fi) module.
[0172] The first device can sequentially send at least one synchronization command to the second device via a wireless communication module, and record the ninth moment when each synchronization command is sent based on the system clock of the first device.
[0173] Then, the synchronization feedback flags sent from the wireless communication module of the second device are received, and the tenth moment when each synchronization feedback flag is received is recorded based on the system clock of the first device.
[0174] The synchronization feedback identifier includes the eleventh moment when the wireless communication module of the second device receives the synchronization command and the twelfth moment when the wireless communication module of the second device sends the synchronization feedback identifier. The eleventh and twelfth moments are obtained based on the system clock of the second device. The first offset time is obtained based on the ninth, tenth, eleventh, and twelfth moments.
[0175] As an example, suppose the ninth time is T9 and the tenth time is T. 10 The eleventh moment is T 11 The twelfth moment is T. 12 The first offset time is δ1, and the bidirectional transmission delay between the first and second devices is the same, T. d Then we can obtain the following formula:
[0176] T 10 -T9=T d +δ1
[0177] T 12 -T 11 =T d -δ1
[0178] The above formula can be used to calculate:
[0179]
[0180] It should be noted that the bidirectional transmission delay between the first and second devices was set to be the same during the calculation. However, in actual applications, the processing time for different instructions and messages may vary, and the transmission delay may also change. Therefore, the first offset time δ1 can be calculated multiple times, and the average of the multiple first offset times δ1 can be obtained as the final first offset time δ1 to reduce potential errors.
[0181] S320, the second device acquires the first moment of transmitting the ranging signal.
[0182] In some implementations, the first moment can be the time elapsed after a preset duration following the confirmation of synchronization completion by the second device. This confirmation can be achieved by the second device receiving a synchronization completion command from the first device or by sending a preset number of synchronization feedback flags. For example, if the preset duration is 10ms, referring to S310, after the second device sends 200 synchronization feedback flags to the first device, it can confirm that synchronization has been completed. Then, 10ms after sending the 200th synchronization feedback flag, a ranging signal is sent to the first device; that is, the first moment is the time of sending the 200th synchronization feedback flag plus 10ms.
[0183] In some implementations, the first moment can be set at the factory of the second device. For example, the second device can be set at the factory to send a ranging signal once every minute, so a first moment can be obtained every minute after the system clock of the second device starts counting. When obtaining the factory settings of the second device, the device identification information of the second device can be obtained first, and then the factory settings of the second device can be obtained from the server based on the device identification information of the second device.
[0184] In other embodiments, the first moment can be set according to an instruction. For example, the second device can receive a ranging signal transmission instruction and acquire at least one first moment included in the ranging signal transmission instruction. The ranging signal transmission instruction can be transmitted by the first device through a wireless communication module. Alternatively, it can be transmitted by other electronic devices communicating with the second device, for example, a ranging signal transmission instruction forwarded by other second devices in the scenario. If the scenario includes a gateway device that communicates with the second device wirelessly, the ranging signal transmission instruction can also be transmitted from the gateway device to the second device.
[0185] As an example, the first device can send a ranging signal transmission command to the Bluetooth module of the second device via its Bluetooth module. The ranging signal transmission command may include an instruction for the second device to send a ranging signal once after 5 seconds. In this case, the first moment is the moment when the second device receives the ranging signal transmission command plus 5 seconds.
[0186] In some implementations, the ranging signal transmission command can instruct the transmission of multiple ranging signals. For example, it can instruct the transmission of the first ranging signal after 5 seconds, followed by transmission of a ranging signal every 5 seconds, stopping after 10 transmissions. Thus, there are multiple first moments, with a 5-second interval between adjacent first moments.
[0187] S330, the first device acquires the first moment.
[0188] In some implementations, after determining the first time, the second device sends the first time to the first device. Upon receiving the first time from the second device, the first device acquires the first time. For example, the second device may carry the first time information in Bluetooth or Wi-Fi information and send it to the first device. Alternatively, as in S320, after confirming synchronization with the first device, the second device may add 10ms to the synchronization completion time and send it as the first time to the first device, so that the first device can acquire this first time.
[0189] In other embodiments, the first device can obtain the first time by first sending a first time query command to the second device via a wireless communication module. Referring to S320, if the first time of the second device is set at the factory, the second device, after receiving the first time query command, sends its device identification information to the first device. The first device then queries and obtains the first time based on the received device identification information. For example, if the first device stores the factory settings data of the second device, it can search for the corresponding second device in the stored factory settings data based on the received device identification information, obtain the factory settings of the corresponding second device, and thus obtain the first time.
[0190] As an example, if the first device receives the device model of the second device and determines that the second device sends a ranging signal once every whole minute based on the device model, then multiple first moments based on the system clock of the second device can be obtained according to the system clock of the first device and the first offset time. For example, if the first offset time is 0.1 seconds and the current moment of the system clock of the first device is T′1, then T′1 can be corrected to the system clock of the second device according to the first offset time, and then the moment of the next whole minute can be determined as the first moment.
[0191] In other embodiments, referring to S320, if the first time of the second device is set according to an instruction, the second device can send at least one first time to the first device after receiving the first time query instruction. The first device uses the first time among the received multiple first times that is closest to the current time to calculate the distance.
[0192] S340, The first device begins to receive ranging signals and acquires the fourth time point.
[0193] S350, the second device sends a ranging signal at the first moment.
[0194] S360, The first device acquires the second moment when it receives the ranging signal.
[0195] Figure 5 A schematic diagram of the system structure of the first device in a ranging method provided in an embodiment of this application is shown.
[0196] In some implementations, reference is made to Figure 5 , Figure 5 The system architecture shown can be applied to Android or HarmonyOS systems using ultrasonic ranging. It includes an application layer, a hardware virtualization layer (Android), a framework layer, a system service layer (HarmonyOS), a kernel layer, and a hardware layer. The application layer runs applications that can receive and respond to ranging commands from the user, instructing the first device to begin ranging. The hardware virtualization layer, framework layer, and system service layer pass commands from the application layer to the kernel layer. The kernel layer includes hardware drivers, which can control the corresponding hardware or obtain its parameters based on the commands from the application layer.
[0197] For example, in this application, ranging is performed using ultrasound. The hardware layer includes a ranging signal receiving chip that can be a HiFi chip. This HiFi chip includes a 32-bit counter (32K Counter) for timing, i.e., the chip clock. The kernel layer can include a HiFi chip driver. The HiFi chip can respond to instructions from the upper layer, start receiving ranging signals, and record the fourth moment T4 when it begins receiving ranging signals using the 32-bit counter.
[0198] In this embodiment, the ranging signal is received by the HiFi chip, which can be achieved by starting recording through the HiFi chip. The moment when the HiFi chip starts recording is the moment when the HiFi chip starts receiving the ranging signal (the fourth moment T4).
[0199] Since T4 is based on the chip clock, in order to obtain the second time point T2 based on the system clock, T4 can be modified to a third time point T3 based on the system time. Then, by adding the receiving interval time to T3, the second time point T2 based on the system clock can be obtained.
[0200] In some implementations, after recording begins, the first device performs correlation calculations based on a locally pre-stored ranging signal sequence and the received recording signal to obtain a correlation value between the ranging signal sequence and the received recording signal. Then, recording signals whose correlation values meet preset conditions are determined. For example, the preset condition could be the maximum value among the correlation values of the recording signals, or it could be that the correlation value of the recording signal is closest to a preset correlation threshold. The duration of the moment corresponding to the recording signal that meets the preset conditions is used as the receiving interval.
[0201] It should be noted that the receiving interval is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal. This receiving interval can be obtained at the chip level (i.e., based on T4) or at the software level (i.e., based on T3), and this application does not impose any limitation on this.
[0202] Figure 6 A schematic diagram of a process for obtaining T2 in a ranging method provided in an embodiment of this application is shown.
[0203] refer to Figure 5 and Figure 6 The process includes:
[0204] S410: The application layer application receives and responds to the ranging command and begins receiving ranging signals.
[0205] In some implementations, the ranging command may originate from a user's operation on the first device. For example, when a ranging application is installed on the first device, the ranging application can be launched when a user clicks on the area displaying the ranging application icon.
[0206] In some examples, the receipt of a ranging command can be determined once the ranging application is started.
[0207] Alternatively, in other examples, once the ranging application is launched, at least one available second device can be displayed on the screen of the first device. This display can be in the form of text or icons. A ranging instruction can be determined when a click is received on an area displaying one of the second devices.
[0208] It should be noted that the first device can also receive ranging commands through voice control, gestures, or other operation methods. This application does not restrict the method of receiving ranging commands.
[0209] S420: The application sends a command to the HiFi chip at the hardware layer, instructing the HiFi chip to start recording.
[0210] The S430 HiFi chip started recording, recording the fourth moment after recording began.
[0211] In some implementations, the HiFi chip's chip clock is based on a 32-bit counter. When the HiFi chip responds to a command to start recording, the fourth time step can be obtained by reading the value of a register in the 32-bit counter. As an example, the address of this register could be "cnf_msg->kernel_stamp=DSP_STAMP".
[0212] The S440 and HiFi chips will send the fourth time signal to the HiFi chip's driver.
[0213] In some implementations, the HiFi chip can proactively send the fourth time value to its driver after acquiring it. Alternatively, it can wait to receive a fourth time value query command from the HiFi chip's driver. Upon receiving the fourth time value query command, it then sends the fourth time value to the HiFi chip's driver.
[0214] In some implementations, the HiFi chip can send the fourth time signal to the HiFi chip driver via a mailbox mechanism. The mailbox mechanism is a method of data transfer and communication between different cores, allowing data to be exchanged between different processors through the mailbox register.
[0215] In some implementations, the driver for the ranging signal receiver chip corrects the fourth time to a third time based on the system clock upon receiving the fourth time. Alternatively, the driver for the ranging signal receiver chip corrects the fourth time to a third time based on the system clock in response to a parameter acquisition command from the application layer.
[0216] For example, the HiFi chip driver can immediately execute S450-S490 upon receiving the fourth time step to obtain the third time step. Alternatively, the HiFi chip driver can wait for a response to a parameter acquisition instruction (such as the getParameter instruction) from the application layer after receiving the fourth time step, and then execute S450-S490 to obtain the third time step upon receiving the parameter acquisition instruction.
[0217] The drivers for the S450 and HiFi chips simultaneously acquire the fifth time point based on the system clock and the sixth time point based on the chip clock. The time difference between the fourth and sixth time points is the second offset time.
[0218] In some implementations, the driver can obtain the fifth time point based on the system clock by reading instructions from the system clock; for example, the fifth time point can be obtained through the "do_gettimeofday" instruction. When obtaining the sixth time point based on the chip clock, the driver can refer to the example in S430 and obtain the sixth time point by reading the value of the register in the 32-bit counter in the HiFi chip.
[0219] In some implementations, the second offset time is δ2, representing the duration from the start of recording to the acquisition of the fifth time point based on the system clock and the sixth time point based on the chip clock. If the fourth time point is T4 and the sixth time point is T6, then:
[0220] δ2 = T6 - T4 (T6 > T4)
[0221] δ2=(T6+2 32 )-T4(T6 <T4)
[0222] When T6 is less than T4, it indicates that the 32-bit counter may overflow. Therefore, T6 should be corrected before calculation to obtain the accurate δ2.
[0223] It should be noted that "simultaneously acquiring the fifth moment based on the system clock and the sixth moment based on the chip clock" means acquiring the fifth moment and the sixth moment separately at the same absolute time. Due to unavoidable factors such as delays and errors inherent in the device itself, the "simultaneous acquisition" action may not be able to be executed precisely at the same absolute time. When the time difference between acquiring the fifth moment and the sixth moment is less than a preset threshold, it can be considered as "simultaneously acquiring the fifth moment based on the system clock and the sixth moment based on the chip clock". This preset threshold can be determined based on factors such as the performance and accuracy of the devices in different first devices.
[0224] The driver for the S460 HiFi chip obtains the third time based on the fifth time and the second offset time.
[0225] In some implementations, the third time point is T3, and the second offset time is δ2, then:
[0226]
[0227] Subtracting the second offset time from the fifth time and dividing by 32767 yields the system clock time at the start of recording (the third time).
[0228] S470, the application layer sends third-moment query commands to the HiFi chip driver through the hardware virtualization layer, framework layer and system service layer.
[0229] The S480 and HiFi chip drivers send the data to the application layer in a third-moment manner.
[0230] In some implementations, the application layer can send a query command, such as "getParameter('Nearby_RecordTime')", to the AudioHardware Abstraction Layer (Audiohal) in the Hardware Virtualization Layer / Framework Layer and System Services Layer. The Audiohal then responds to the query command by instructing the core layer driver to transmit the third time to the application layer via Input / Output Control (IOCtrl).
[0231] S490, the application layer application adds the receiving interval time to the third time to obtain the second time.
[0232] In some implementations, if the third time point is T3 and the receiving interval is ΔT, then the second time point T2 is:
[0233] T2 = T3 + ΔT
[0234] In this embodiment, the HiFi driver simultaneously acquires the fifth time point based on the system clock and the sixth time point based on the chip clock. Then, the fourth time point, acquired based on the chip clock, at the start of receiving the ranging signal (i.e., the start of recording), is corrected to the third time point based on the system clock. This achieves the conversion of the underlying chip clock to the upper-layer system clock, thereby supporting the ultrasonic ranging function and resulting in more accurate ranging with lower errors.
[0235] Figure 7 This paper illustrates another flowchart for obtaining T2 in the ranging method provided in the embodiments of this application.
[0236] refer to Figure 5 and Figure 7 The process includes:
[0237] S510: The application layer receives and responds to the ranging command and begins receiving ranging signals.
[0238] S520: The application sends a command to the HiFi chip at the hardware layer, instructing the HiFi chip to start recording.
[0239] The S530 HiFi chip started recording, recording the fourth moment after recording began.
[0240] In this embodiment, the implementation methods in S510 to S530 are the same as those in S410 to S430, and will not be described again here.
[0241] The S540 application layer sends third-moment query commands to the HiFi chip through the hardware virtualization layer, framework layer, and system service layer.
[0242] In some implementations, the application layer can send a query command, such as "getParameter('Nearby_RecordTime')", to the Audiohal in the hardware virtualization layer / framework layer and system service layer. Then, after responding to the query command, the Audiohal can instruct the HiFi chip to obtain the third time frame via IOCtrl and send it to the application layer application once obtained.
[0243] The S550 and HiFi chips simultaneously acquire the fifth moment based on the system clock and the sixth moment based on the chip clock. The time difference between the fourth and sixth moments is the second offset time.
[0244] In some implementations, the HiFi chip can obtain the fifth time based on the system clock by reading instructions from the system clock. For example, the fifth time can be obtained through the "do_gettimeofday" instruction. When obtaining the sixth time based on the chip clock, the HiFi chip can refer to the example in S430 and obtain the sixth time by reading the value of the register in the 32-bit counter in the HiFi chip.
[0245] In some implementations, the second offset time is δ2, representing the duration from the start of recording to the acquisition of the fifth time point based on the system clock and the sixth time point based on the chip clock. If the fourth time point is T4 and the sixth time point is T6, then:
[0246] δ2 = T6 - T4 (T6 > T4)
[0247] δ2=(T6+2 32 )-T4(T6 <T4)
[0248] When T6 is less than T4, it indicates that the 32-bit counter may overflow. Therefore, T6 should be corrected before calculation to obtain the accurate δ2.
[0249] It should be noted that "simultaneously acquiring the fifth moment based on the system clock and the sixth moment based on the chip clock" means acquiring the fifth moment and the sixth moment separately at the same absolute time. Due to unavoidable factors such as delays and errors inherent in the device itself, the "simultaneous acquisition" action may not be able to be executed precisely at the same absolute time. When the time difference between acquiring the fifth moment and the sixth moment is less than a preset threshold, it can be considered as "simultaneously acquiring the fifth moment based on the system clock and the sixth moment based on the chip clock". This preset threshold can be determined based on factors such as the performance and accuracy of the devices in different first devices.
[0250] The S560 and HiFi chips obtain the third time based on the fifth time and the second offset time.
[0251] In some implementations, the third time point is T3, and the second offset time is δ2, then:
[0252]
[0253] Subtracting the second offset time from the fifth time and dividing by 32767 yields the system clock time at the start of recording (the third time).
[0254] The S570 and HiFi chips send the third-time data to the application layer.
[0255] In some implementations, the HiFi chip can pass the obtained third moment to the application layer via IOCtrl.
[0256] S580, the application layer application adds the receiving interval time to the third time to obtain the second time.
[0257] In some implementations, if the third time point is T3 and the receiving interval is ΔT, then the second time point T2 is:
[0258] T2 = T3 + ΔT
[0259] In this embodiment, the HiFi chip simultaneously acquires the fifth moment based on the system clock and the sixth moment based on the chip clock. Then, the fourth moment, acquired based on the chip clock, when the ranging signal reception begins (i.e., recording begins), is corrected to the third moment based on the system clock. This achieves the conversion of the underlying chip clock to the upper-layer system clock, thereby supporting the ultrasonic ranging function and resulting in more accurate ranging with lower errors.
[0260] S370, the first device obtains the distance between the first device and the second device based on the first offset time, the first moment, and the second moment.
[0261] In some implementations, the time of flight (tof) of the ranging signal can be obtained first based on the first offset time, the first moment, and the second moment.
[0262] As an example, the first time point T1 can be corrected to the seventh time point T7 based on the first device system clock, according to the first offset time δ1, that is:
[0263] T7 = T1 + δ1
[0264] Then, subtract the seventh time T7 from the second time T2 to obtain the flight time T of the ranging signal.tof ,Right now:
[0265] T tof =R2-R7=T2-T1-δ1
[0266] In other examples, the second time T2 is corrected to the eighth time T8 based on the second device system clock, according to the first offset time δ1, that is:
[0267] T8 = T2 - δ1
[0268] Then, subtract the first time T1 from the eighth time T8 to obtain the flight time T of the ranging signal. tof ,Right now:
[0269] T tof =T8-T1=T2-δ1-T1
[0270] Finally, based on the propagation speed V of the ranging signal in the medium and the flight time T... tof Obtain the distance D between the first device and the second device, that is:
[0271] D = V * T tof
[0272] As an example, this application uses ultrasonic ranging, where the propagation speed V is the speed of sound in the air. For example, in an environment of 1 standard atmosphere and 15°C, V = 340 m / s.
[0273] However, the speed of sound in air is also affected by atmospheric pressure, humidity, and temperature. Therefore, in some implementations, the first device can also acquire the atmospheric pressure P, relative humidity RH, and temperature T of the current scene. Then, the propagation speed V is calculated based on the atmospheric pressure P, relative humidity RH, and temperature T.
[0274]
[0275] P w =p*RH
[0276] Where V is measured in meters per second, P is measured in kilopascals (kPa), and T is measured in degrees Celsius. w ρ is the partial pressure of water vapor in the air, measured in kilopascals (kPa), and p is the saturated vapor pressure of water vapor at temperature T, also measured in kilopascals (kPa).
[0277] In other implementations, if the effects of humidity and pressure are disregarded and only the effect of temperature is considered, the propagation speed V can also be calculated using the following formula:
[0278]
[0279] Where V is measured in meters per second and T is measured in degrees Celsius.
[0280] In some implementations, the first device can obtain atmospheric pressure P, relative humidity RH, and temperature T from sensors set up in the current scene. If no corresponding sensors are set up in the current scene, the device can obtain the location information of the current scene and then obtain the atmospheric pressure P, relative humidity RH, and temperature T at the current location from the server based on the location information.
[0281] It should be understood that the sequence numbers of the steps in the above embodiments do not imply the order of execution. For example, in Figure 4 In the diagram, S340 is shown to occur after S310, but S340 can also occur before S310. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0282] Corresponding to the ranging method applied to the first device provided in the above embodiments, Figure 8 This diagram illustrates a structural block diagram of a ranging device applied to a first device according to an embodiment of this application. For ease of explanation, only the parts related to the embodiment of this application are shown.
[0283] Reference Figure 8 A ranging device applied to the first device, comprising:
[0284] The acquisition module 61 is used to acquire the first offset time and the first moment. The first offset time is the time difference between the system clock of the first device and the system clock of the second device. The first moment is the moment when the second device sends the ranging signal. The first moment is obtained based on the system clock of the second device.
[0285] The acquisition module 61 is also used to acquire the second moment when the ranging signal is received. The second moment is obtained based on the third moment when the first device starts receiving the ranging signal and the receiving interval time. The third moment is obtained based on the fourth moment when the ranging signal receiving chip starts receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval time is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal.
[0286] The calculation module 62 is used to obtain the distance between the first device and the second device based on the first offset time, the first moment, and the second moment.
[0287] In some implementations, the acquisition module 61 is specifically used by the ranging signal receiving chip to acquire the fourth time and send the fourth time to the driver program of the ranging signal receiving chip. The driver program of the ranging signal receiving chip corrects the fourth time to a third time based on the system clock. The driver program of the ranging signal receiving chip sends the third time to the application layer, where the application layer adds the receiving interval time to the third time to obtain the second time.
[0288] In some implementations, the acquisition module 61 is specifically used by the driver of the ranging signal receiving chip to correct the fourth time to a third time based on the system clock when the fourth time is received. Alternatively, the driver of the ranging signal receiving chip may correct the fourth time to a third time based on the system clock in response to a parameter acquisition instruction from the application layer.
[0289] In some implementations, the acquisition module 61 is specifically used by the ranging signal receiving chip to acquire the fourth time. The driver program of the ranging signal receiving chip responds to a parameter acquisition instruction, acquires the fourth time from the ranging signal receiving chip, and corrects the fourth time to a third time based on the system clock. The driver program of the ranging signal receiving chip sends the third time to the application layer, where an interval time is added to the third time to obtain the second time.
[0290] In some implementations, the acquisition module 61 is specifically used to acquire, via the driver program of the ranging signal receiving chip, a fifth time point based on the system clock and a sixth time point based on the chip clock, wherein the time difference between the fourth and sixth times points is a second offset time. The third time point is then obtained based on the fifth time point and the second offset time.
[0291] In some embodiments, the calculation module 62 is specifically used to obtain the flight time of the ranging signal based on the first offset time, the first moment, and the second moment. The distance between the first device and the second device is obtained based on the propagation speed and flight time of the ranging signal in the medium.
[0292] In some implementations, the calculation module 62 is specifically configured to correct the first time to a seventh time based on the first device system clock according to the first offset time; and subtract the seventh time from the second time to obtain the flight time of the ranging signal. Alternatively, it may correct the second time to an eighth time based on the second device system clock according to the first offset time; and subtract the first time from the eighth time to obtain the flight time of the ranging signal.
[0293] In some implementations, the acquisition module 61 is specifically configured to sequentially send at least one synchronization command to the second device, and record the ninth time when each synchronization command is sent based on the system clock of the first device. It receives a synchronization feedback identifier from the second device, and records the tenth time when each synchronization feedback identifier is received based on the system clock of the first device. The synchronization feedback identifier includes the eleventh time when the second device receives the synchronization command and the twelfth time when the second device sends the synchronization feedback identifier, the eleventh and twelfth times being obtained based on the system clock of the second device. A first offset time is obtained based on the ninth, tenth, eleventh, and twelfth times.
[0294] In some implementations, the acquisition module 61 is specifically used to send a first-time query command to the second device. It also receives at least one first-time value sent by the second device.
[0295] In some implementations, the acquisition module 61 is specifically used to send a first-time query command to the second device. It receives device identification information sent by the second device. Based on the device identification information, it acquires at least one pre-set first time.
[0296] Corresponding to the ranging method applied to the second device provided in the above embodiments, Figure 9 This diagram illustrates a structural block diagram of a ranging device applied to a second device according to an embodiment of this application. For ease of explanation, only the parts related to the embodiment of this application are shown.
[0297] Reference Figure 9 A ranging device applied to a second device, comprising:
[0298] The acquisition module 71 is used to acquire the first moment of sending the ranging signal.
[0299] The sending module 72 is used to send the first moment to the first device.
[0300] The transmitting module 72 is also used to transmit a ranging signal at a first moment based on the system clock of the second device.
[0301] In some embodiments, the device further includes a receiving module 73 for receiving at least one synchronization command from a first device, and recording an eleventh time when each synchronization command is received based on the system clock of a second device. In response to each synchronization command, a synchronization feedback identifier is sent to the first device, the synchronization feedback identifier including the eleventh time and a twelfth time when the synchronization feedback identifier is sent, the twelfth time being obtained based on the system clock of the second device.
[0302] In some implementations, the acquisition module 71 is specifically used to confirm that synchronization with the first device is complete. The time elapsed after a preset period of time following the confirmation of successful synchronization is taken as the first moment.
[0303] In some implementations, the acquisition module 71 is specifically used to receive a ranging signal transmission command and acquire at least one first moment included in the ranging signal transmission command. Alternatively, it can acquire at least one preset first moment based on the device identification information of the second device.
[0304] In some embodiments, the sending module 72 is further configured to send the first time to the first device after acquiring the first time. Alternatively, the apparatus may further include a response module 74 configured to send at least one first time to the first device in response to a first time query command from the first device.
[0305] In some implementations, the response module 74 is also configured to respond to a first-moment query command from the first device and send the device identification information of the second device to the first device.
[0306] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0307] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0308] Figure 10 This is a structural block diagram of a first device provided in an embodiment of this application. Figure 10 As shown, the first device 8 in this embodiment includes:
[0309] At least one processor 801 ( Figure 10 (Only one is shown) a processor, a memory 802, a ranging signal receiving component 804, and a computer program 803 stored in the memory 802 and capable of running on at least one processor 801. When the processor 801 executes the computer program 803, it implements the steps in the above control method embodiment through the ranging signal receiving component 804.
[0310] The first device 8 can be a mobile phone, tablet computer, augmented reality (AR) / virtual reality (VR) device, large-screen device, laptop computer, netbook, personal digital assistant (PDA), etc. Those skilled in the art will understand that... Figure 10 The first device 8 is merely an example and does not constitute a limitation on the first device 8. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0311] The processor 801 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), system-on-a-chip (SoCs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0312] In some embodiments, memory 802 may be an internal storage unit of the first device 8, such as a hard disk or memory of the first device 8. In other embodiments, memory 802 may also be an external storage device of the first device 8, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the first device 8.
[0313] Furthermore, the memory 802 may include both internal storage units of the first device 8 and external storage devices. The memory 802 is used to store the operating system, application programs, bootloader, data, and other programs, such as program code for computer programs. The memory 802 can also be used to temporarily store data that has been output or will be output.
[0314] Figure 11 This is a structural block diagram of a second device provided in an embodiment of this application. Figure 11 As shown, the second device 9 in this embodiment includes:
[0315] At least one processor 901 ( Figure 11 (Only one is shown in the image), memory 902, ranging signal transmitting component 904, and computer program 903 stored in memory 902 and executable on at least one processor 901. When processor 901 executes computer program 903, it implements the steps in the above control method embodiment through ranging signal transmitting component 904.
[0316] The second device 9 can be a terminal device that includes a ranging signal transmission function, or a first device that has a ranging signal transmission function. For example, a terminal device that includes a ranging signal transmission function can be an electronic tag, a smart key fob including an electronic tag, a Bluetooth headset, etc. Those skilled in the art will understand that... Figure 11 This is merely an example of the second device 9 and does not constitute a limitation on the second device 9. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0317] The processor 901 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), system-on-a-chip (SoCs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0318] In some embodiments, memory 902 may be an internal storage unit of the second device 9, such as a hard disk or memory of the second device 9. In other embodiments, memory 902 may also be an external storage device of the second device 9, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the second device 9.
[0319] Furthermore, the memory 902 may include both internal storage units of the second device 9 and external storage devices. The memory 902 is used to store the operating system, application programs, bootloader, data, and other programs, such as program code for computer programs. The memory 902 can also be used to temporarily store data that has been output or will be output.
[0320] This application provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements a method applied to a first device.
[0321] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a method applied to a second device.
[0322] This application provides a computer program product that, when run on a first device, causes a terminal device to execute the method applied to the first device.
[0323] This application provides a computer program product that, when run on a second device, causes a terminal device to execute the method applied to the second device.
[0324] This application provides a chip system including a memory and a processor. The processor executes a computer program stored in the memory to implement a method applied to a first device.
[0325] This application provides a chip system including a memory and a processor, wherein the processor executes a computer program stored in the memory to implement a method applied to a second device.
[0326] This application provides a chip system including a processor coupled to a computer-readable storage medium provided in the eighth aspect. The processor executes a computer program stored in the computer-readable storage medium to implement a method applied to a first device.
[0327] This application provides a chip system including a processor coupled to a computer-readable storage medium provided in the ninth aspect. The processor executes a computer program stored in the computer-readable storage medium to implement a method applied to a second device.
[0328] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a first or second device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0329] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0330] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0331] In the embodiments provided in this application, it should be understood that the disclosed methods, apparatus, systems, first devices, or second devices can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0332] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0333] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A distance measurement method, characterized in that, Applied to the first device, including: The first offset time and the first moment are obtained. The first offset time is the time difference between the system clock of the first device and the system clock of the second device. The first moment is the moment when the second device sends the ranging signal. The first moment is obtained based on the system clock of the second device. The second moment when the ranging signal is received is obtained based on the third moment when the first device starts receiving the ranging signal and the receiving interval time. The third moment is obtained based on the fourth moment when the application program instructs the ranging signal receiving chip to start receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval time is the time interval between starting to receive the ranging signal and receiving the ranging signal. The distance between the first device and the second device is obtained based on the first offset time, the first moment, and the second moment. The step of obtaining the second moment when the ranging signal is received includes: The ranging signal receiving chip acquires the fourth time and sends the fourth time to the driver program of the ranging signal receiving chip; The driver program of the ranging signal receiving chip corrects the fourth time to the third time based on the system clock; The driver program of the ranging signal receiving chip sends the third time to the application layer, where the application layer adds the receiving interval time to the third time to obtain the second time.
2. The method according to claim 1, characterized in that, The driver program for the ranging signal receiving chip corrects the fourth time to the third time based on the system clock, including: When the driver program of the ranging signal receiving chip receives the fourth time, it corrects the fourth time to a third time based on the system clock; or, The driver program of the ranging signal receiving chip responds to the parameter acquisition instruction from the application layer and corrects the fourth time to the third time based on the system clock.
3. The method according to claim 1, characterized in that, The step of obtaining the second moment when the ranging signal is received includes: The ranging signal receiving chip acquires the fourth time point; The driver program of the ranging signal receiving chip responds to the parameter acquisition instruction, acquires the fourth time from the ranging signal receiving chip, and corrects the fourth time to the third time based on the system clock; The driver program of the ranging signal receiving chip sends the third time to the application layer, where the application layer adds the receiving interval time to the third time to obtain the second time.
4. The method according to any one of claims 1-3, characterized in that, The step of correcting the fourth time point to the third time point based on the system clock includes: The driver program of the ranging signal receiving chip simultaneously acquires a fifth time based on the system clock and a sixth time based on the chip clock, wherein the time difference between the fourth time and the sixth time is the second offset time. The third time is obtained based on the fifth time and the second offset time.
5. The method according to any one of claims 1-4, characterized in that, The step of obtaining the distance between the first device and the second device based on the first offset time, the first time, and the second time includes: The flight time of the ranging signal is obtained based on the first offset time, the first moment, and the second moment; The distance between the first device and the second device is obtained based on the propagation speed of the ranging signal in the medium and the flight time.
6. The method according to claim 5, characterized in that, The step of obtaining the flight time of the ranging signal based on the first offset time, the first moment, and the second moment includes: Based on the first offset time, the first moment is corrected to the seventh moment based on the first device system clock; Subtracting the seventh time from the second time point yields the flight time of the ranging signal; or, Based on the first offset time, the second time is corrected to the eighth time based on the second device system clock; Subtracting the first time from the eighth time point yields the flight time of the ranging signal.
7. The method according to any one of claims 1-6, characterized in that, The process of obtaining the first offset time includes: The first device sequentially sends at least one synchronization command to the second device, and records the ninth moment when each synchronization command is sent based on the system clock of the first device; The system receives a synchronization feedback identifier from the second device, and records the tenth time when each synchronization feedback identifier is received based on the system clock of the first device. The synchronization feedback identifier includes the eleventh time when the second device receives the synchronization instruction and the twelfth time when the second device sends the synchronization feedback identifier. The eleventh time and the twelfth time are obtained based on the system clock of the second device. The first offset time is obtained based on the ninth time, the tenth time, the eleventh time, and the twelfth time.
8. The method according to any one of claims 1-7, characterized in that, The acquisition of the first moment includes: Send a first-moment query command to the second device; Receive at least one of the first moments sent by the second device.
9. The method according to any one of claims 1-8, characterized in that, The acquisition of the first moment includes: Send a first-moment query command to the second device; Receive device identification information sent by the second device; Based on the device identification information, at least one of the first moments is obtained in advance.
10. A distance measurement method, characterized in that, Applied to a second device, including: Acquire the first moment when the ranging signal is transmitted; Send the first moment to the first device; Based on the system clock of the second device, the ranging signal is sent to the first device at the first moment; the ranging signal is used by the first device to obtain the distance between the first device and the second device; the distance is obtained by the first device based on a first offset time, the first moment, and a second moment; the first offset time is the time difference between the system clock of the first device and the system clock of the second device; the second moment is obtained when the first device receives the ranging signal; the second moment is obtained based on a third moment when the first device starts receiving the ranging signal and a receiving interval time, the third moment being determined by the application layer's instruction to the ranging signal receiving chip to start... The receiving interval is obtained by converting the fourth time when the ranging signal is received, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal. The second time is obtained by the driver of the ranging signal receiving chip sending the third time to the application layer, and the application layer adding the receiving interval to the third time. The third time is obtained by the driver of the ranging signal receiving chip correcting the fourth time to a time based on the system clock. The fourth time is obtained by the ranging signal receiving chip and sent to the ranging signal receiving chip.
11. The method according to claim 10, characterized in that, Before transmitting the ranging signal at the first moment based on the system clock of the second device, the method further includes: Receive at least one synchronization command from the first device, and record the eleventh moment when each synchronization command is received based on the system clock of the second device; In response to each of the synchronization commands, a synchronization feedback identifier is sent to the first device. The synchronization feedback identifier includes the eleventh time and the twelfth time when the synchronization feedback identifier is sent. The twelfth time is obtained based on the system clock record of the second device.
12. The method according to claim 11, characterized in that, Acquire the first moment of transmitting the ranging signal, including: Confirm that synchronization with the first device is complete; The first moment is defined as the time elapsed after a preset period following the confirmation of synchronization completion.
13. The method according to any one of claims 10-12, characterized in that, The first moment of acquiring the transmitted ranging signal includes: Receive a ranging signal transmission command, and acquire at least one of the first moments included in the ranging signal transmission command; or, Based on the device identification information of the second device, at least one of the first moments is obtained in advance.
14. The method according to claim 12 or 13, characterized in that, Sending the first moment to the first device includes: After obtaining the first moment, send the first moment to the first device; or, In response to a first time query command from a first device, send at least one first time to the first device.
15. The method according to claim 13 or 14, characterized in that, The step of sending the first moment to the first device further includes: In response to a first-moment query command from the first device, the device identification information of the second device is sent to the first device.
16. A ranging system, comprising a first device and a second device, characterized in that, include: The first device acquires a first offset time and a first moment, where the first offset time is the time difference between the system clock of the first device and the system clock of the second device, and the first moment is the moment when the second device sends the ranging signal, which is obtained based on the system clock of the second device. The second device sends the ranging signal at the first moment based on the system clock of the second device; The first device acquires a second moment when it receives the ranging signal. The second moment is obtained based on a third moment when the first device starts receiving the ranging signal and a receiving interval. The third moment is obtained based on a fourth moment when the application program instructs the ranging signal receiving chip to start receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval is the time interval between starting to receive the ranging signal and receiving the ranging signal. The first device obtains the distance between the first device and the second device based on the first offset time, the first time, and the second time. The ranging signal receiving chip of the first device acquires the fourth time and sends the fourth time to the driver program of the ranging signal receiving chip; The driver program of the ranging signal receiving chip of the first device corrects the fourth time to the third time based on the system clock; The driver program of the ranging signal receiving chip of the first device sends the third time to the application layer, where the application layer adds the receiving interval time to the third time to obtain the second time.
17. A ranging device, characterized in that, Applied to the first device, including: The acquisition module is used to acquire a first offset time and a first moment, wherein the first offset time is the time difference between the system clock of the first device and the system clock of the second device, and the first moment is the moment when the second device sends the ranging signal, and the first moment is obtained based on the system clock of the second device. The acquisition module is further configured to acquire a second moment when the ranging signal is received. The second moment is obtained based on a third moment when the first device starts receiving the ranging signal and a receiving interval. The third moment is obtained based on a fourth moment when the application program instructs the ranging signal receiving chip to start receiving the ranging signal, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval is the interval between the fourth moment and when the ranging signal receiving chip receives the ranging signal. The calculation module is used to obtain the distance between the first device and the second device based on the first offset time, the first time, and the second time. The acquisition module is further configured to have the ranging signal receiving chip acquire the fourth time and send the fourth time to the driver program of the ranging signal receiving chip; the driver program of the ranging signal receiving chip corrects the fourth time to a third time based on the system clock; the driver program of the ranging signal receiving chip sends the third time to the application layer, and the application layer adds the receiving interval time to the third time to obtain the second time.
18. A ranging device, characterized in that, Applied to a second device, including: The acquisition module is used to acquire the first moment when the ranging signal is sent. The sending module is used to send the first moment to the first device; The transmitting module is further configured to transmit the ranging signal to the first device at the first moment based on the system clock of the second device; the ranging signal is used by the first device to obtain the distance between the first device and the second device; the distance is obtained by the first device based on a first offset time, the first moment, and a second moment; the first offset time is the time difference between the system clock of the first device and the system clock of the second device; the second moment is obtained when the first device receives the ranging signal; the second moment is obtained based on a third moment when the first device starts receiving the ranging signal and a receiving interval time, the third moment being determined based on the start time of the ranging signal receiving chip. The receiving interval is obtained by converting the fourth time when the ranging signal is received, the system clock of the first device, and the chip clock of the ranging signal receiving chip. The receiving interval is the time interval between the start of receiving the ranging signal and the receipt of the ranging signal. The second time is obtained by the driver of the ranging signal receiving chip sending the third time to the application layer, and the application layer adding the receiving interval to the third time. The third time is obtained by the driver of the ranging signal receiving chip correcting the fourth time to a time based on the system clock. The fourth time is obtained by the ranging signal receiving chip and sent to the ranging signal receiving chip.
19. An electronic device comprising a memory, a processor, a ranging signal receiving component, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 9.
20. An electronic device comprising a memory, a processor, a ranging signal transmitting component, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 10 to 15.
21. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 9.
22. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 10 to 15.