A method for identifying the type of accessory and adapting the protocol of a magnetically attached peripheral device

CN122654692BActive Publication Date: 2026-10-09HUALU YIYUN TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202611122128.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-09
Estimated Expiration
2046-07-28

AI Technical Summary

Technical Problem

[0007]本发明旨在提供一种磁吸外设挂载的配件类型识别与协议自适应方法,以解决现有技术中外设识别数据处理方法单一、识别结果与协议配置之间缺乏数据映射与自动决策机制、外设特征数据库缺乏动态更新机制以及热插拔场景下动态管理能力不足的技术问题

Benefits of technology

本发明提供了一种磁吸外设挂载的配件类型识别与协议自适应方法,通过磁场数据通道和电气编码数据通道并行采集,分别进行加权欧氏距离匹配和汉明距离匹配,并通过交叉验证与融合决策进行综合判定,相比单一数据源的处理方法,识别准确率显著提高,可选的光学识别通道进一步增强了系统的冗余能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122654692B_ABST
    Figure CN122654692B_ABST
Patent Text Reader

Abstract

The application discloses a kind of magnetic attraction peripheral mounting accessory type identification and protocol adaptive method, it is related to the technical field of electric digital data processing, the method includes: when accessory is adsorbed to magnetic attraction docking structure, three-dimensional magnetic field data and electrical coding data of accessory are collected in parallel, respectively execute filtering processing and binary processing, generate magnetic field characteristic vector and electrical coding vector;Magnetic field characteristic vector is matched with accessory feature library to execute weighted Euclidean distance, electrical coding vector is matched with accessory feature library to execute hamming distance, and the identification result is output by cross validation and fusion decision;With identification result as index, configuration data in protocol dynamic mapping table is retrieved, and communication protocol switching, power supply parameter adaptation and drive loading are automatically completed;Magnetic field amplitude is continuously monitored to support hot plug dynamic reconfiguration.The application realizes the complete data processing closed loop of accessory identification to protocol adaptation, and identification reliability is high, supports plug and play.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic digital data processing technology, and in particular to a method for identifying accessory types and adapting protocols for magnetically attached peripherals. Background Technology

[0002] With the rapid development of smart terminal devices and IoT technology, more and more devices need to support the expansion of various functional accessories. How to achieve rapid identification, adaptive protocol configuration, and plug-and-play functionality of peripheral accessories has become a key technical issue in the field of smart device peripheral management.

[0003] Currently, there are existing technologies that use magnetic attraction to connect functional modules and perform type identification. For example, Chinese patent application CN117961896A proposes a scheme to connect and fix functional modules to robots using magnetic attraction. However, its identification method relies on detecting the continuity status of the pin connector and contacts, as well as the status detection of non-latch Hall switches. The identification method is relatively simple, and its reliability is greatly affected by the contact status.

[0004] Furthermore, existing technologies generally stop at outputting identification results, that is, only completing the determination of the peripheral type. However, the identification results fail to drive subsequent protocol configuration decisions. They cannot automatically perform a series of data processing operations such as switching communication protocol parameters, setting data transmission format, adjusting power supply parameters, and loading function drivers based on the identification results. There is a lack of automated data mapping and decision-making links between the identification results and device configuration. Function switching or protocol configuration still needs to be completed manually, and true plug-and-play functionality is not achieved.

[0005] Existing accessory feature databases are typically static. When a new type of peripheral is introduced, the device firmware needs to be manually upgraded to update the feature data and protocol configuration data, limiting scalability. Furthermore, existing solutions do not support dynamic identification and reconfiguration in hot-swappable scenarios. When accessories are replaced while the peripheral is running, the removal and connection of accessories cannot be automatically detected, requiring a device restart or manual refresh.

[0006] To address the aforementioned issues, this invention proposes a method for identifying accessory types and adapting protocols for magnetically attached peripherals. By parallel acquisition and fusion processing of multi-source sensor data, accessory identification based on data matching, and protocol adaptive configuration driven by the identification results, a complete data processing process is achieved for peripheral accessories from physical attachment to functional readiness. Summary of the Invention

[0007] This invention aims to provide a method for identifying accessory types and adapting protocols for magnetically attached peripherals, in order to solve the technical problems in the prior art, such as the single data processing method for peripheral identification, the lack of data mapping and automatic decision-making mechanism between identification results and protocol configuration, the lack of dynamic update mechanism for peripheral feature database, and insufficient dynamic management capabilities in hot-swappable scenarios.

[0008] To achieve the above-mentioned objectives, this invention provides a method for identifying accessory types and adapting protocols for magnetically attached peripherals, the method comprising:

[0009] Step S10: When the accessory is magnetically attached to the magnetic docking structure on the robot, the three-dimensional magnetic field data of the accessory is collected by the three-axis magnetic field sensor, and the electrical coding data of the accessory is collected by the multi-contact pin array. The three-dimensional magnetic field data is subjected to arithmetic mean filtering to generate magnetic field feature vector, and the electrical coding data is subjected to analog-to-digital conversion and binarization to generate electrical coding vector. Step S20: Perform magnetic field fingerprint matching calculation with the magnetic field feature vector and the standard magnetic field fingerprint vector in the pre-stored parts feature library; perform electrical code matching calculation with the standard electrical code vector in the parts feature library; perform cross-validation and fusion decision based on the two matching calculation results; and output the parts identifier as the identification result. Step S30: Using the identification result as the index key, retrieve the corresponding configuration data from the protocol dynamic mapping table, and automatically complete the configuration of communication protocol parameters, power supply parameters, and function driver loading based on the configuration data; Step S40: Continuously collect three-dimensional magnetic field data of the accessory, calculate the magnetic field amplitude in real time and compare it with a preset threshold. When it is determined that the accessory has been removed, execute drive unloading and power supply shutdown. When it is determined that a new accessory has been adsorbed, repeat steps S10 to S30.

[0010] Furthermore, step S10 includes the following detailed steps: The original magnetic field strength data sequences of the component in the X, Y, and Z axes were collected by a triaxial magnetic field sensor. The arithmetic mean of a predetermined number of consecutive sampling points in the sequence was calculated to obtain the filtered three-dimensional magnetic field feature vector. ,in , and These represent the magnetic field strength values ​​in the X, Y, and Z axes after filtering, respectively. Analog voltage values ​​are acquired through the coded pins of the multi-contact pin array. The analog voltage values ​​of each coded pin are converted into digital values ​​by an analog-to-digital converter. The digital values ​​are then compared with a preset voltage threshold. When the digital value is greater than or equal to the voltage threshold, a binary bit of 1 is output; when the digital value is less than the voltage threshold, a binary bit of 0 is output. The binary bits output by all encoding pins are arranged in a preset order to form an electrical encoding vector. in It is the first in the electrical coding vector Each encoding pin has a binary bit, which can be either 0 or 1, representing the encoding state corresponding to that pin. This refers to the number of encoding pins; The data acquisition of the triaxial magnetic field sensor and the multi-contact pin array is controlled by the data acquisition module and executed in parallel. The completion time of the two-channel data acquisition and preprocessing does not exceed the predetermined time threshold.

[0011] Furthermore, step S10 also collects optical identification image data of accessories through optical sensors, performs grayscale processing and adaptive threshold binarization processing on the optical identification image data to generate a binarized image, performs error correction decoding processing on the binarized image to generate an optical feature vector as auxiliary identification data; the optical feature vector is used as the sole identification basis for accessory type identification and performs redundancy verification when the magnetic field feature vector or electrical coding vector cannot be collected due to interference.

[0012] Furthermore, in step S20, the magnetic field fingerprint matching calculation includes the following detailed steps: Each record is read sequentially from the accessory feature database. Each record contains an accessory identifier and its corresponding standard magnetic field fingerprint vector. , The standard magnetic field characteristics representing a certain type of accessory, among which , and These represent the standard magnetic field strength reference values ​​for the corresponding type of accessory in the X, Y, and Z axes, respectively. The magnetic field feature vector The distance value is calculated by substituting the standard magnetic field fingerprint vector into the weighted Euclidean distance formula. : ,in , and The weighting coefficients for the X, Y, and Z axes are set according to the accuracy specifications of the triaxial magnetic field sensor in each axis. , and These represent the filtered magnetic field strength values ​​of the component in the X, Y, and Z axes, respectively. The distance value Matching threshold with preset magnetic field When comparing, Less than If the record is found to be a successful match, the corresponding part identifier will be output. When all records All are greater than or equal to If no magnetic field fingerprint match is found, an empty value is output.

[0013] The electrical code matching calculation includes the following detailed steps: Each record is read sequentially from the accessory feature library. Each record contains an accessory identifier and its corresponding standard electrical code vector. ,in For the first in the standard electrical coding vector The binary bit values ​​of each encoding pin, with subscript 0 indicating the standard reference, correspond to the measured electrical encoding vector. Location; This refers to the number of encoding pins; The electrical coding vector and standard electrical coding vector Substitute into the Hamming distance formula to calculate the degree of difference : ,in Represents the XOR operation, when and The XOR result is 1 when the values ​​are different and 0 when they are the same. The Hamming distance is obtained by summing the XOR results of each encoding pin. ; This refers to the number of encoding pins; when When the value is 0, the electrical code of the record is considered to be a complete match, and the corresponding part identifier is output. ;when If the value is greater than 0, the record is considered a mismatch, and the search continues to the next record; when all records are... If all values ​​are greater than 0, the electrical code verification is considered to have no result, and an empty value is output.

[0014] The cross-validation and fusion decision specifically includes: Obtain the first matching result from the magnetic field fingerprint matching calculation. The second matching result is calculated and output by the electrical coding matching. ; when and Neither empty nor empty = At that time, or As the final identification result Output; when and Neither empty nor empty If a matching result is found to be conflicting, a re-check process is triggered: Return to step S10 to re-execute data acquisition and preprocessing, and repeat step S20's magnetic field fingerprint matching calculation, electrical code matching calculation, and cross-validation and fusion decision based on the re-acquired data; If the number of re-checks has not reached the preset maximum number of re-checks and a matching result conflict occurs again, the re-check process continues; if the number of re-checks reaches the preset maximum number of re-checks... and If they still don't match, output the following separately. and The system will generate two results and mark the accessory as being in a conflict state. It will then output a conflict warning message containing the two candidate recognition results through the output interface.

[0015] when Non-empty and When empty, with As the final identification result And, according to the preset confidence rule, the final recognition result is labeled with a first confidence value; when empty and When not empty, with As the final identification result And, according to the confidence rule, label the final identification result with a second confidence value; when and If all values ​​are empty, the current accessory is determined to be an unknown accessory.

[0016] Furthermore, in step S30, the protocol dynamic mapping table is stored in the memory as a hash table data structure, with the accessory identifier as the key field of the hash table and the configuration data as the value field of the hash table. The configuration data includes communication protocol type identifier, bus speed parameter, data frame format definition, power supply voltage value, power supply current value, function driver storage address pointer, and interaction logic configuration parameters. The specific steps of retrieving and extracting the corresponding configuration data from the protocol dynamic mapping table include: using the identification results... Using the query key, a hash table lookup function is invoked to locate and extract the configuration data record associated with the key from the protocol dynamic mapping table.

[0017] The automatic completion of communication protocol parameter configuration, power supply parameter configuration, and function driver loading based on configuration data specifically includes: Communication protocol parameter configuration: Extract the communication protocol type identifier and bus rate parameter from the configuration data, call the communication interface configuration function provided by the operating system, switch the communication bus to the bus protocol specified by the communication protocol type identifier, and configure the communication timing parameters according to the bus rate parameter; Power supply parameter configuration: Extract the power supply voltage and current values ​​from the configuration data, convert them into digital control signals, and write the digital control signals to the digital control interface of the adjustable power supply module through a digital-to-analog converter, so that the adjustable power supply module outputs voltage and current that match the power supply voltage and current values; Function driver loading: Extract the function driver storage address pointer from the configuration data, read the binary code of the function driver from the corresponding address in the memory, load the binary code into the running memory through the operating system's dynamic loading mechanism, execute the function driver's initialization function, and register the accessory's interrupt service function pointer and callback function pointer to the operating system kernel.

[0018] Furthermore, step S40 includes the following detailed steps: The output data of the triaxial magnetic field sensor is continuously collected at a predetermined sampling frequency to obtain real-time three-dimensional magnetic field data of the accessory. Calculate the magnetic field amplitude : ,in , and These are the current magnetic field strength values ​​of the accessory in the X, Y, and Z axes, respectively. magnetic field amplitude Adsorption determination threshold and removal threshold Compare; when the magnetic field amplitude From below the removal determination threshold The state change is greater than the adsorption determination threshold. When the electrical coding vector changes from all zeros to non-all zeros, it is determined that a new accessory has been attracted, triggering the execution of steps S10 to S30. When the magnetic field amplitude From above the adsorption determination threshold The state change is less than the removal determination threshold. When the electrical coding vector changes from non-all zeros to all zeros, it is determined that the accessory has been removed, and accessory removal data processing is performed: Based on the currently loaded accessory identifier, the corresponding function driver storage address pointer is retrieved from the protocol dynamic mapping table. The driver unloading interface of the operating system is called to release the resources occupied by the driver. A power-off control signal is written to the digital control interface of the adjustable power module through the digital-to-analog converter, and the system status flag is updated to idle state.

[0019] The present invention discloses the following technical effects: This invention provides a method for identifying accessory types and adapting protocols for magnetically attached peripherals. It collects data in parallel through a magnetic field data channel and an electrical coding data channel, performs weighted Euclidean distance matching and Hamming distance matching respectively, and makes a comprehensive judgment through cross-validation and fusion decision. Compared with the processing method of a single data source, the recognition accuracy is significantly improved, and the optional optical recognition channel further enhances the redundancy of the system.

[0020] This invention achieves automatic mapping from identification results to protocol configuration data through the design of a hash table data structure for a dynamic protocol mapping table. It also automatically completes communication protocol parameter configuration, power supply parameter setting, and function driver loading through operating system interface calls, forming a complete data processing closed loop without the need for manual user intervention.

[0021] This invention can automatically sense the adsorption and removal of accessories by continuously monitoring the magnetic field amplitude and comparing it with a preset threshold; when it is determined that an accessory has been removed, it automatically executes drive unloading and power shutdown; when it is determined that a new accessory has been adsorbed, it automatically triggers the identification and configuration process, realizing plug-and-play functionality for peripheral accessories.

[0022] This invention employs a dual-engine parallel processing approach combining magnetic field fingerprint matching and electrical coding verification. When the outputs of the two engines are consistent, the identification result is confirmed. When a single engine fails to output a result, the other engine can still independently complete the identification and mark the confidence level. When the results of the two engines conflict, the re-examination process eliminates occasional errors, thereby improving the robustness of accessory type identification. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating a method for identifying accessory types and adapting protocols for magnetically attached peripherals, as provided in an embodiment of this application. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description of this application will be provided in conjunction with the accompanying drawings. The described embodiments should not be considered as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0025] Example 1: This application provides a method for identifying accessory types and adapting protocols for magnetically attached peripherals. Taking the magnetic docking structure of a medicine box accessory attached to a robot as an example, for instance... Figure 1 As shown, the method includes: Step S10: When the accessory is magnetically attached to the robot by the magnetic docking structure, the three-dimensional magnetic field data of the accessory is collected by the three-axis magnetic field sensor, and the electrical coding data of the accessory is collected by the multi-contact pin array. The three-dimensional magnetic field data is subjected to arithmetic mean filtering to generate magnetic field feature vector, and the electrical coding data is subjected to analog-to-digital conversion and binarization to generate electrical coding vector.

[0026] In this embodiment, when the medicine box accessory is magnetically attached to the magnetic docking structure on the robot, the permanent magnet built into the magnetic docking structure attracts the magnet at the accessory end, causing the accessory to automatically position and fit against the docking surface; after the data acquisition module detects the successful attachment of the accessory, it starts multi-channel parallel data acquisition.

[0027] In the magnetic field data acquisition channel, the triaxial magnetic field sensor (preferably a triaxial magnetic field sensor using TMR tunneling magnetoresistive effect technology) is activated to acquire three-dimensional magnetic field data in real time at a preset sampling frequency; the triaxial magnetic field sensor acquires the raw magnetic field strength data sequences of the accessory in the X-axis, Y-axis, and Z-axis directions respectively: The medicine box contains three embedded magnets arranged in an alternating N-S triangle pattern, generating a specific magnetic field distribution in space. For the X-axis direction, the sensor continuously collects 10 sampling points to obtain the raw data sequence. The arithmetic mean of the raw data sequence is then calculated as the filtered X-axis magnetic field strength value. Similarly, the arithmetic mean of 10 consecutive sampling points along the Y and Z axes is used to obtain the filtered Y-axis magnetic field strength value. and Z-axis magnetic field strength value Generate three-dimensional magnetic field feature vectors .

[0028] The sensor has a sampling frequency of 1000Hz, and 10 sampling points correspond to a data acquisition window of 10ms. This window duration is much shorter than the total time requirement for steps S10 to S30 (100ms). Furthermore, the arithmetic mean of the 10 sampling points can effectively suppress the high-frequency random noise of the sensor, achieving a good balance between noise suppression and response speed. The number of sampling points can be preset or dynamically adjusted according to the actual noise level of the sensor and the system response time requirements.

[0029] In the electrical data acquisition channel, the multi-contact pin array contains multiple coded pins; when the accessory is attracted, the coded resistor network on the contact surface of the accessory end forms electrical contact with the pin array on the robot end, and each coded pin acquires the analog voltage value.

[0030] In this embodiment, the resistor network of the medicine box accessory is configured as follows: pins 1 to 3 are shorted to ground, pin 4 is connected to a reference voltage through a pull-up resistor, and the remaining pins are open. The analog voltage values ​​of each encoding pin are converted into digital values ​​by an analog-to-digital converter. The digital values ​​are compared with a preset voltage threshold: when the digital value is greater than or equal to the voltage threshold, the pin is determined to be at a high level, and a binary bit 1 is output; when the digital value is less than the voltage threshold, the pin is determined to be at a low level, and a binary bit 0 is output. The binary bits output by all encoding pins are arranged in a predetermined order to form an electrical encoding vector. ,in, It is the first in the electrical coding vector The binary bits of each encoding pin represent the encoding state corresponding to that pin; This represents the number of encoding pins. For medicine box accessories, the electrical encoding vector is represented as a binary sequence, corresponding to a hexadecimal encoding value of 0x08.

[0031] The magnetic field data acquisition channel and the electrical data acquisition channel are controlled by the data acquisition module and executed in parallel. The completion time of data acquisition and preprocessing does not exceed a predetermined time threshold of 15ms. This time threshold takes into account the sampling setup time of the triaxial magnetic field sensor (approximately 5ms), the conversion time of the analog-to-digital converter (approximately 2ms), the calculation time of the arithmetic mean filter (approximately 1ms), and the time margin for synchronous aggregation of data from each channel. This ensures that the data acquisition and preprocessing stages occupy a reasonable proportion (not exceeding 15%) of the total time budget (100ms), reserving sufficient processing time for subsequent identification matching and protocol adaptive configuration stages.

[0032] Step S20: Perform magnetic field fingerprint matching calculation between the magnetic field feature vector and the standard magnetic field fingerprint vector in the pre-stored parts feature library; perform electrical code matching calculation between the electrical code vector and the standard electrical code vector in the parts feature library; perform cross-validation and fusion decision based on the two matching calculation results; and output the parts identifier as the identification result.

[0033] After completing the data acquisition and preprocessing in step S10, this step performs recognition processing based on the generated multi-source feature dataset. The recognition processing is performed in parallel by two independent recognition data processing engines, including magnetic field fingerprint matching calculation and electrical code matching calculation. During the magnetic field fingerprint matching calculation process, a pre-stored accessory feature library is first read from the memory. This feature library is stored in a data table structure, with each record containing an accessory identifier and its corresponding standard magnetic field fingerprint vector. Taking a medicine box accessory as an example, the accessory feature library stores the standard magnetic field fingerprint vector of the medicine box. =(12.50, -8.30, 15.20) The corresponding accessory identifier is 0x01; the standard magnetic field fingerprint vector is pre-written after each accessory is measured by a high-precision calibration device before leaving the factory.

[0034] The measured magnetic field feature vector generated in step S10 The standard magnetic field fingerprint vectors of each record in the parts feature database are matched sequentially. The matching calculation uses a weighted Euclidean distance algorithm to obtain the distance value. The calculation formula is expressed as:

[0035] Among them, , and The weighting coefficients for the X, Y, and Z axes are set according to the accuracy indicators of the triaxial magnetic field sensor in each axis. The setting is based on the principle that the weighting coefficients are inversely proportional to the measurement accuracy of each axis; that is, the higher the measurement accuracy of an axis (the smaller the percentage error), the greater its decision weight in the matching calculation. In this embodiment, the sensor's X-axis accuracy is ±2%, Y-axis accuracy is ±3%, and Z-axis accuracy is ±3%. Therefore, the reliability weighting base for each axis is the reciprocal of the absolute value of its accuracy percentage, which are 1 / 2, 1 / 3, and 1 / 3 respectively. Normalizing these weighting bases (each weighting base divided by the sum of the three) yields... 0.43 0.285 0.285, further approximating the engineering value, is set as follows: =0.4, =0.3, =0.3. The purpose of the weighting coefficient is to give greater weight to the more accurate axis in distance calculation, thereby improving matching accuracy; the weighting coefficient can also be preset or dynamically adjusted online for different sensor models or different environmental noise levels.

[0036] In this embodiment, the measured magnetic field characteristic vector of the medicine box accessory = (12.57, -8.28, 15.24) The measured values ​​were compared with the standard magnetic field fingerprint vector of the medicine box in the feature library (12.50, -8.30, 15.20). Substituting into the above formula, we can calculate the result. = 0.0506 The calculated Matching threshold with preset magnetic field A comparison is made. In this embodiment, the magnetic field matching threshold is... =2.0 The threshold is set based on the following: this threshold is greater than the sensor's measurement error range in each axis (estimated at ±3% accuracy, the error is approximately 0.4~0.5). ) and short-term fluctuations in the environmental magnetic field (usually less than 0.5). The synthesis uncertainty is smaller than the minimum magnetic field fingerprint difference between different components (typically greater than 5). This allows for reliable differentiation between different components while tolerating normal measurement deviations. The matching threshold can be preset or calibrated online based on the electromagnetic noise level and sensor performance parameters of the actual application scenario.

[0037] Due to 0.0506 <2.0 If the record is found to be a match, output the accessory identifier corresponding to the medicine box. =0x01. For other accessory records in the accessory feature library, since the measured magnetic field vector differs significantly from their standard magnetic field fingerprint vector, the calculated... The values ​​are all much greater than the magnetic field matching threshold. Match failed.

[0038] Electrical code matching calculation and magnetic field fingerprint matching calculation are performed in parallel. Standard electrical code vectors for each record are read from the parts feature database. The measured electrical code vectors are then precisely compared with each standard electrical code vector. The matching calculation uses the Hamming distance algorithm, and the calculation formula is as follows:

[0039] in, For the first in the standard electrical coding vector The binary bit values ​​of each encoding pin, with subscript 0 indicating the standard reference, correspond to the measured electrical encoding vector. Location; Represents the XOR operation, when and The XOR result is 1 when the values ​​are different and 0 when they are the same. The Hamming distance is obtained by summing the XOR results of each encoding pin. , = 0 indicates that the actual code is exactly the same as the standard code.

[0040] In this embodiment, the hexadecimal value corresponding to the measured electrical code vector of the medicine box accessory is 0x08, and the standard electrical code of the medicine box accessory in the accessory feature library is also 0x08. They are identical, and the Hamming distance is... = 0, indicating a successful match, output the accessory identifier. = 0x01. For other accessory records in the feature library, their standard electrical codes differ from 0x08, Hamming distance. >0, match failed.

[0041] Based on the parallel matching process described above, the first matching result of the magnetic field fingerprint matching calculation is obtained. The second matching result calculated by matching =0x01 with electrical codes is the output of the calculation. = 0x01; due to and If both are non-empty and equal, then the accessory identifier is confirmed as the final identification result. = 0x01.

[0042] During the identification of medicine box accessories, two independent identification engines corroborate each other, resulting in the highest confidence level for the final result; if an error occurs during the identification of a certain accessory... Not empty In cases where the connection is empty (e.g., electrical contacts are not making good contact due to oxidation), then... As the final identification result, the confidence level is labeled according to the preset confidence rules. = 0.80. The confidence level is set based on the following: when a single channel outputs results independently, the reliability statistics of the sensor under normal operating conditions are used (e.g., the historical recognition accuracy of the magnetic field channel after eliminating interference is about 95%). At the same time, the systematic deviation risk that a single channel may have (about 15%~20% uncertainty) is comprehensively considered. 80% is taken as a conservative confidence level estimate to indicate that there is a certain degree of uncertainty in the upper layer application of the recognition result.

[0043] If the results from the two engines conflict ( ≠ In the event of an error, a re-examination process is triggered, returning to step S10 to re-collect data and repeat the matching calculation to eliminate occasional errors. If the conflict is still not resolved after a preset number of re-examinations, a conflict prompt message is output for manual confirmation. In this embodiment, the preset number of re-examinations is set to 3, based on the system's tolerance for recognition delay (a single re-examination takes about 50ms, and 3 re-examinations add an extra 150ms, still within the user's acceptable waiting range) and the probability of occasional errors (usually caused by transient electromagnetic interference or contact jitter; the probability of such errors recurring in continuous repeated detection is extremely low, and 3 re-examinations are sufficient to eliminate the vast majority of occasional errors).

[0044] Step S30: Using the identification result as the index key, retrieve the corresponding configuration data from the protocol dynamic mapping table, and automatically complete the configuration of communication protocol parameters, power supply parameters, and function driver loading based on the configuration data.

[0045] In this embodiment, based on the final recognition result output in step S20 = 0x01, execute protocol adaptive configuration. = 0x01 is used as the query key to retrieve the corresponding configuration data from the protocol dynamic mapping table. The protocol dynamic mapping table is stored in memory using a hash table data structure, with the accessory identifier as the key field and the configuration data as the value field; the average lookup time complexity of the hash table is O(1), which enables fast retrieval.

[0046] For the medicine box accessory with identifier 0x01, the corresponding configuration data in the protocol dynamic mapping table includes: communication protocol type identifier is I²C, bus speed parameter is 100kHz, data frame format is defined as 7-bit address 0x50, power supply voltage is 5V, power supply current is 200mA, function driver storage address pointer is 0x0800A000, and interaction logic configuration parameter is time interval = 1800s.

[0047] The communication protocol parameter configuration process includes: extracting the communication protocol type identifier I²C and bus speed parameter 100kHz from the configuration data; calling the I²C communication interface configuration function provided by the operating system; switching the communication bus to the I²C protocol; configuring the clock frequency to 100kHz; setting the device address to a 7-bit address 0x50; and defining and configuring communication timing parameters according to the data frame format. After configuration, establishing a communication link with the medicine box accessory that conforms to the I²C protocol.

[0048] The power supply parameter configuration process includes: extracting the power supply voltage value of 5V and the power supply current value of 200mA from the configuration data, converting these two values ​​into digital control signals, and writing the digital control signals to the digital control interface of the adjustable power module through a digital-to-analog converter, so that the adjustable power module outputs 5V voltage and limits the current to 200mA to provide working power for the medicine box accessories.

[0049] The function driver loading process includes: extracting the function driver storage address pointer 0x0800A000 from the configuration data; reading the binary code of the medicine box management function driver from the corresponding address in memory based on this pointer; loading the binary code into the running memory through the operating system's dynamic loading mechanism; performing integrity verification on the driver code; and executing the driver's initialization function. During initialization, the timer interrupt service function pointer (used to trigger medication reminders every 30 minutes) and callback function pointer of the medicine box accessory are registered with the operating system kernel, completing the driver installation. After configuration, the message "Medicine box recognized, medication reminder set for you" is output via voice or the robot's display interface.

[0050] Step S40: Continuously collect three-dimensional magnetic field data of the accessory, calculate the magnetic field amplitude in real time and compare it with a preset threshold. When it is determined that the accessory has been removed, execute drive unloading and power supply shutdown. When it is determined that a new accessory has been adsorbed, repeat steps S10 to S30.

[0051] In this embodiment, during the normal operation of the medicine box accessory, the output data of the triaxial magnetic field sensor is continuously collected at a predetermined sampling frequency of 100Hz to obtain real-time three-dimensional magnetic field data. The 100Hz sampling frequency was set based on the following: this frequency is much higher than the timescale of the physical removal operation of the accessory (the user's action of removing the accessory is usually more than hundreds of milliseconds), which can ensure that the event is detected in time when the accessory's state changes, while avoiding unnecessary power consumption caused by excessively high sampling frequencies. Next, the magnetic field amplitude is calculated based on the real-time three-dimensional magnetic field data. : ,in , and These are the current magnetic field strength values ​​of the accessory in the X, Y, and Z axes, respectively. When the medicine box accessory is attached to the magnetic docking structure on the robot, the additional magnetic field of the embedded magnet in the accessory causes... Maintain at a high value; in real time Compared with the preset adsorption judgment threshold and removal threshold Comparison. Among them, > The hysteresis interval between the two is used to prevent misjudgment caused by magnetic field jitter.

[0052] The calculation process for the adsorption and removal thresholds is as follows: In the initial state without adsorption of accessories, the background magnetic field (including the Earth's magnetic field and environmental stray magnetic fields) is sampled and statistically analyzed multiple times, and the average value of the background magnetic field amplitude is calculated. and standard deviation The decision threshold will be removed. Set as ( Set the value to 3-5 to ensure that there are no parts present when the adsorption threshold is set. Set as ,in The hysteresis width is greater than the sensor's measurement noise and the maximum amplitude of short-term magnetic field drift to ensure a stable interval between adsorption and removal decisions, preventing frequent state jumps caused by magnetic field fluctuations. This threshold can be automatically set by the system during power-on initialization after background magnetic field self-calibration, or it can be manually adjusted by the user according to the actual application scenario.

[0053] When the user removes the medicine box accessory from the magnetic docking structure, the magnetic field strength detected by the triaxial magnetic field sensor drops rapidly. The magnetic field amplitude is monitored. From above the adsorption determination threshold The state change is less than the removal threshold. The multi-contact pin array detected that the electrical coding vector changed from non-all zeros to all zeros, and based on this, it was determined that the medicine box accessory had been removed.

[0054] The system then performs accessory removal data processing: based on the currently loaded medicine box accessory identifier 0x01, it retrieves the corresponding function driver storage address pointer in the protocol dynamic mapping table, calls the operating system's driver unloading interface to release timer interrupt resources and memory buffers, writes a power supply shutdown control signal to the adjustable power module through the digital-to-analog converter, and updates the system status flag to idle state.

[0055] When the user attaches another accessory (such as an ambient light accessory) to the magnetic docking structure on the robot, the magnetic field amplitude is detected. From below the removal threshold The state change is greater than the adsorption determination threshold. If the electrical coding vector changes from all zeros to non-all zeros, it is determined that a new component has been attracted. The system automatically triggers steps S10 to S30 to perform a complete identification and protocol adaptive configuration process for the new component.

[0056] Throughout the entire component switching process, the system runs continuously, and users do not need to perform any manual configuration or restart operations, realizing hot-swapping and dynamic reconfiguration of peripheral components.

[0057] In this embodiment, the values ​​of each parameter (including but not limited to the number of sampling points, sampling frequency, various time thresholds, matching thresholds, confidence values, number of re-detections, and hysteresis interval coefficients) are illustrative examples. In actual engineering implementation, those skilled in the art can preset, calibrate, or dynamically adjust the above parameters within a reasonable range according to specific application scenarios, sensor models, electromagnetic environment characteristics, and system performance requirements. As long as they do not deviate from the core idea of ​​this invention, the automatic identification and adaptive configuration of peripheral accessories achieved through parallel acquisition and fusion processing of multi-source sensor data, dual-engine cross-validation identification, recognition result-driven protocol adaptive configuration, and continuous status monitoring are all within the protection scope of this invention.

[0058] In some cases, the actions or steps described in this application can be performed in a different order than those shown in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

Claims

1. A method for identifying accessory types and adapting protocols for magnetically attached peripherals, characterized in that, The method includes: Step S10: When the accessory is magnetically attached to the magnetic docking structure on the robot, the three-dimensional magnetic field data of the accessory is collected by the three-axis magnetic field sensor, and the electrical coding data of the accessory is collected by the multi-contact pin array. The three-dimensional magnetic field data is subjected to arithmetic mean filtering to generate magnetic field feature vector, and the electrical coding data is subjected to analog-to-digital conversion and binarization to generate electrical coding vector. Step S20: Perform magnetic field fingerprint matching calculation between the magnetic field feature vector and the standard magnetic field fingerprint vector in the pre-stored parts feature library; perform electrical code matching calculation between the electrical code vector and the standard electrical code vector in the parts feature library; perform cross-validation and fusion decision based on the two matching calculation results; and output the parts identifier as the identification result. Each record is read sequentially from the accessory feature database. Each record contains an accessory identifier and its corresponding standard magnetic field fingerprint vector. , The standard magnetic field characteristics representing a certain type of accessory, among which , and These represent the standard magnetic field strength reference values ​​for the corresponding type of accessory in the X, Y, and Z axes, respectively. The magnetic field feature vector The distance value is calculated by substituting the standard magnetic field fingerprint vector into the weighted Euclidean distance formula. : ,in , and The weighting coefficients for the X, Y, and Z axes are set according to the accuracy specifications of the triaxial magnetic field sensor in each axis. , and These represent the filtered magnetic field strength values ​​of the components in the X, Y, and Z axes, respectively. The distance value Matching threshold with preset magnetic field When comparing, Less than If the record is found to be a successful match, the corresponding part identifier will be output. When all records All are greater than or equal to If no magnetic field fingerprint match is found, an empty value is output. Each record is read sequentially from the accessory feature library. Each record contains an accessory identifier and its corresponding standard electrical code vector. ,in For the first in the standard electrical coding vector The binary bit values ​​of each encoding pin, with subscript 0 indicating the standard reference, correspond to the measured electrical encoding vector. Location; This refers to the number of encoding pins; Electrical coding vector and standard electrical coding vector Substitute into the Hamming distance formula to calculate the degree of difference : ,in This represents the XOR operation. It is the first in the electrical coding vector The binary bits of each encoding pin, when and The XOR result is 1 when the values ​​are different and 0 when they are the same. The Hamming distance is obtained by summing the XOR results of each encoding pin. ; This refers to the number of encoding pins; when When the value is 0, the electrical code of the record is considered to be a complete match, and the corresponding part identifier is output. ;when If the value is greater than 0, the record is considered a mismatch, and the search continues to the next record; when all records are... If all values ​​are greater than 0, the electrical code verification is considered to have no result, and a null value is output. Cross-validation and fusion decisions specifically include: Obtain the first matching result from the magnetic field fingerprint matching calculation. The second matching result is calculated and output by the electrical coding matching. ; when and Neither empty nor empty = At that time, or As the final identification result Output; when and Neither empty nor empty If a conflict is found in the matching results, a re-examination process is triggered. when Non-empty and When empty, with As the final identification result And, according to the preset confidence rule, the final recognition result is labeled with a first confidence value; when empty and When not empty, with As the final identification result And, according to the confidence rule, label the final identification result with a second confidence value; when and If all values ​​are empty, the current accessory is determined to be an unknown accessory. Step S30: Using the identification result as the index key, retrieve the corresponding configuration data from the protocol dynamic mapping table, and automatically complete the configuration of communication protocol parameters, power supply parameters, and function driver loading based on the configuration data; Step S40: Continuously collect three-dimensional magnetic field data of the accessory, calculate the magnetic field amplitude in real time and compare it with a preset threshold. When it is determined that the accessory has been removed, execute drive unloading and power supply shutdown. When it is determined that a new accessory has been adsorbed, repeat steps S10 to S30.

2. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, Step S10 includes the following detailed steps: The original magnetic field strength data sequences of the component in the X, Y, and Z axes were collected by a triaxial magnetic field sensor. The arithmetic mean of a predetermined number of consecutive sampling points in the sequence was calculated to obtain the filtered three-dimensional magnetic field feature vector. ,in , and These represent the magnetic field strength values ​​in the X, Y, and Z axes after filtering, respectively. Analog voltage values ​​are acquired through the coded pins of the multi-contact pin array. The analog voltage values ​​of each coded pin are converted into digital values ​​by an analog-to-digital converter. The digital values ​​are then compared with a preset voltage threshold. When the digital value is greater than or equal to the voltage threshold, a binary bit of 1 is output; when the digital value is less than the voltage threshold, a binary bit of 0 is output. The binary bits output by all encoding pins are arranged in a preset order to form an electrical encoding vector. ,in It is the first in the electrical coding vector Each encoding pin has a binary bit, which can be either 0 or 1, representing the encoding state corresponding to that pin. This refers to the number of encoding pins; The data acquisition of the triaxial magnetic field sensor and the multi-contact pin array is controlled by the data acquisition module and executed in parallel. The completion time of the two-channel data acquisition and preprocessing does not exceed the predetermined time threshold.

3. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, Step S10 also collects optical identification image data of accessories through optical sensors, performs grayscale processing and adaptive threshold binarization processing on the optical identification image data to generate a binarized image, performs error correction decoding processing on the binarized image to generate an optical feature vector as auxiliary identification data; the optical feature vector is used as the sole identification basis for accessory type identification and performs redundancy verification when the magnetic field feature vector or electrical coding vector cannot be collected due to interference.

4. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, The re-inspection process specifically includes: Return to step S10 to re-execute data acquisition and preprocessing, and repeat step S20's magnetic field fingerprint matching calculation, electrical code matching calculation, and cross-validation and fusion decision based on the re-acquired data; If the number of re-checks has not reached the preset maximum number of re-checks and a matching result conflict occurs again, the re-check process continues; if the number of re-checks reaches the preset maximum number of re-checks... and If they still don't match, output the following separately. and The system will generate two results and mark the accessory as being in a conflict state. It will then output a conflict warning message containing the two candidate recognition results through the output interface.

5. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, In step S30, the protocol dynamic mapping table is stored in the memory as a hash table data structure, with the accessory identifier as the key field of the hash table and the configuration data as the value field of the hash table. The configuration data includes communication protocol type identifier, bus speed parameter, data frame format definition, power supply voltage value, power supply current value, function driver storage address pointer, and interaction logic configuration parameters. The specific steps of retrieving and extracting the corresponding configuration data from the protocol dynamic mapping table include: using the identification results... Using the query key, a hash table lookup function is invoked to locate and extract the configuration data record associated with the key from the protocol dynamic mapping table.

6. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, In step S30, the automatic completion of communication protocol parameter configuration, power supply parameter configuration, and function driver loading based on configuration data specifically includes: Communication protocol parameter configuration: Extract the communication protocol type identifier and bus rate parameter from the configuration data, call the communication interface configuration function provided by the operating system, switch the communication bus to the bus protocol specified by the communication protocol type identifier, and configure the communication timing parameters according to the bus rate parameter; Power supply parameter configuration: Extract the power supply voltage and current values ​​from the configuration data, convert them into digital control signals, and write the digital control signals to the digital control interface of the adjustable power supply module through a digital-to-analog converter, so that the adjustable power supply module outputs voltage and current that match the power supply voltage and current values; Function driver loading: Extract the function driver storage address pointer from the configuration data, read the binary code of the function driver from the corresponding address in the memory, load the binary code into the running memory through the operating system's dynamic loading mechanism, execute the function driver's initialization function, and register the accessory's interrupt service function pointer and callback function pointer to the operating system kernel.

7. The accessory type identification and protocol adaptation method for magnetic peripheral mounting as described in claim 1, characterized in that, Step S40 includes the following detailed steps: The output data of the triaxial magnetic field sensor is continuously collected at a predetermined sampling frequency to obtain real-time three-dimensional magnetic field data of the accessory. Calculate the magnetic field amplitude : ,in , and These are the current magnetic field strength values ​​of the accessory in the X, Y, and Z axes, respectively. magnetic field amplitude Adsorption determination threshold and removal threshold Compare; when the magnetic field amplitude From below the removal determination threshold The state change is greater than the adsorption determination threshold. When the electrical coding vector changes from all zeros to non-all zeros, it is determined that a new accessory has been attracted, triggering the execution of steps S10 to S30. When the magnetic field amplitude From above the adsorption determination threshold The state change is less than the removal determination threshold. When the electrical coding vector changes from non-all zeros to all zeros, it is determined that the accessory has been removed, and accessory removal data processing is performed: Based on the currently loaded accessory identifier, the corresponding function driver storage address pointer is retrieved from the protocol dynamic mapping table. The driver unloading interface of the operating system is called to release the resources occupied by the driver. A power-off control signal is written to the digital control interface of the adjustable power module through the digital-to-analog converter, and the system status flag is updated to idle state.

Citation Information

Patent Citations

  • Robot modularized electromechanical interface, identification method, robot and storage medium

    CN117961896A

  • Magnetic accessory identification system and electronic equipment

    CN121385748A

  • System and method for identification of a peripheral device

    US20130083949A1