A dynamic sampling method and device for an analog sensor
By setting a preset sampling range in the analog sensor and dynamically adjusting the sampling range, the output value error problem caused by individual sensor differences and installation position differences is solved, and high-precision and full-range usage effects are achieved.
Patent Information
- Application Number
- CN202110485458.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-30
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-04-30
AI Technical Summary
When collecting data, the output value errors are caused by individual differences and installation position differences, which affects the user's control accuracy and user experience.
A dynamic sampling method for analog sensors is proposed. By setting a preset sampling range, the actual sampling value is output based on the comparison results of the analog sampling value and the actual sampling range, and the actual sampling range is adjusted if necessary to dynamically adjust the sampling range.
Dynamic adjustment of the sampling range of the analog sensor is realized, ensuring that all the values within the output range of the analog sensor can be collected, improving user control accuracy and user experience.
Smart Images

Figure CN115265629B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sensing technologies, and in particular to a dynamic sampling method and device for analog sensors. Background Art
[0002] At present, some analog sensors, such as Hall sensors, potentiometers, pressure sensors, capacitive position sensors, etc., generally have the problem of output value errors. The reasons for this problem are, on the one hand, the individual differences of the sensors themselves, and on the other hand, the output value errors caused by external structures such as the housing or magnet at the installation position of the sensors.
[0003] To solve this problem, the currently common method is to set a relatively small and safe fixed value range to detect the output value of the sensor. Taking the potentiometer on the game controller joystick as an example, the potentiometer is installed on the product housing, and the actual output range is normally in the voltage range of 0.5V - 2.7V. However, considering the individual differences of the sensors and the errors caused by the housing, etc., the sampling value range of the potentiometer is limited to 0.7V - 2.5V to prevent the joystick of the game controller from not being able to be moved to the maximum stroke to obtain the maximum actual output value. However, such a range limitation will affect the user's control accuracy. When the user uses the joystick, before reaching the outermost edge, the actual output has already reached the maximum, bringing an unpleasant user experience to the user.
[0004] Therefore, when collecting data of analog sensors, how to overcome the output value errors caused by the individual differences and installation position differences of the sensors without affecting the actual output range of the analog sensors has become an urgent technical problem to be solved. Summary of the Invention
[0005] To solve the above problems, the present invention proposes a dynamic sampling method and device for analog sensors to solve the above problems.
[0006] For this purpose, according to a first aspect, an embodiment of the present invention discloses a dynamic sampling method for an analog sensor, including the following steps:
[0007] S1: Read a preset sampling range, take the minimum value of the preset sampling range as the minimum value of the actual sampling range, and take the maximum value of the preset sampling range as the maximum value of the actual sampling range;
[0008] S2: Sample the output of the analog sensor to obtain an analog sampling value;
[0009] S3: Output an actual sampling value according to the comparison result between the analog sampling value and the actual sampling range;
[0010] S4: Adjust the actual sampling range according to the comparison result between the analog sampling value and the actual sampling range;
[0011] S5: Return to execute step S2.
[0012] Optionally, step S3 is specifically:
[0013] Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, use the analog sampling value as the sampling output value; if the analog sampling value is less than the minimum value of the actual sampling range, use the minimum value of the actual sampling range as the sampling output value; if the analog sampling value is greater than the maximum value of the actual sampling range, use the maximum value of the actual sampling range as the sampling output value.
[0014] Optionally, step S4 is specifically:
[0015] Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, do not adjust the actual sampling range; if the analog sampling value is less than the minimum value of the actual sampling range, update the minimum value of the actual sampling range with the analog sampling value; if the analog sampling value is greater than the maximum value of the actual sampling range, update the maximum value of the actual sampling range with the analog sampling value.
[0016] Optionally, step S3 further includes: determining the actual output value through the sampling output value, the actual sampling range, and the actual output range.
[0017] Optionally, the difference between the maximum value and the minimum value of the actual sampling range is used as the actual sampling range amplitude, the difference between the maximum value and the minimum value of the actual output range is used as the actual output range amplitude, and the ratio of the sampling output value to the actual sampling range amplitude is equal to the ratio of the actual output value to the actual output range amplitude.
[0018] Optionally, the analog sensor is used to collect the handle rocker state signal.
[0019] Optionally, the analog sensor is a Hall sensor, a sliding rheostat, a pressure sensor, or a capacitive position sensor.
[0020] Optionally, the analog sampling value is a voltage value or a current value.
[0021] According to a second aspect, an embodiment of the present invention discloses a computer device, which is characterized by including a processor, a memory, and an analog sensor sampling device. The processor is configured to execute a computer program stored in the memory to implement a dynamic sampling method for an analog sensor according to any one of the above first aspects.
[0022] 10. A computer-readable storage medium, on which a computer program is stored, and is characterized in that when the computer program is executed by a processor, it implements a dynamic sampling method for an analog sensor according to any one of the above first aspects.
[0023] Advantages of the present invention:
[0024] The present invention provides a dynamic sampling method for an analog sensor. By setting a preset sampling range, outputting an actual sampling value according to the comparison result between the analog sampling value and the actual sampling range, and adjusting the actual sampling range according to the comparison result between the analog sampling value and the actual sampling range after outputting the actual sampling value, dynamic adjustment of the sampling range of the analog sensor can be achieved. When the analog sampling value exceeds the preset range value, the sampling range can be updated in a timely and dynamic manner to ensure that all values within the output range of the analog sensor can be collected to adapt to applications in different scenarios. In particular, in the application of collecting the state of a handle crank, by setting steps such as a preset range, parameter comparison, dynamic adjustment, and using the current value, when the sampling range value exceeds the preset range value, the latest range value can still be updated in real time, that is, the range of remote control component manipulation is corrected without the user's awareness, avoiding voltage output errors caused by individual component differences in mass production of remote control components, ensuring the normal operation of remote control components, enabling each remote control component to have high-precision and full-range usage effects when fully manipulated, and providing a relatively safe fixed preset range value for the user when replacing remote control components, which is beneficial for the user to select different remote control components in multiple aspects. Description of the Drawings
[0025] Figure 1 It is a flowchart of Embodiment 1 of the dynamic sampling method for an analog sensor proposed by the present invention.
[0026] Figure 2 It is a flowchart of Embodiment 2 of the dynamic sampling method for an analog sensor proposed by the present invention. Detailed Embodiments
[0027] To more clearly and completely illustrate the technical solution of the present invention, the present invention will be further described below with reference to the accompanying drawings.
[0028] Embodiment 1
[0029] Please refer to Figure 1, an embodiment of a dynamic sampling method for an analog sensor is proposed in the present invention, including the following steps:
[0030] S1: Read the preset sampling range, take the minimum value of the preset sampling range as the minimum value of the actual sampling range, and take the maximum value of the preset sampling range as the maximum value of the actual sampling range;
[0031] S2: Sample the output of the analog sensor to obtain an analog sampling value;
[0032] S3: Output the actual sampling value according to the comparison result between the analog sampling value and the actual sampling range;
[0033] S4: Adjust the actual sampling range according to the comparison result between the analog sampling value and the actual sampling range;
[0034] S5: Return to step S2 for execution.
[0035] It should be noted that in this embodiment, the preset sampling range can be stored in a non-volatile storage device, that is, the data can be retained even in the case of power failure. The preset sampling range is a relatively safe parameter range, which can adapt to the output range differences of analog sensors due to individual differences or different housing structures of the installation positions. As an example, the boundaries of the preset sampling range can be set within the boundaries of the output values of multiple analog sensors.
[0036] In the embodiment of the present invention, by setting the preset sampling range, outputting the actual sampling value according to the comparison result between the analog sampling value and the actual sampling range, and adjusting the actual sampling range according to the comparison result between the analog sampling value and the actual sampling range after outputting the actual sampling value, dynamic adjustment of the sampling range of the analog sensor can be achieved. When the analog sampling value exceeds the preset range value, the sampling range can be updated in a timely and dynamic manner to ensure that all values within the output range of the analog sensor can be collected to adapt to applications in different scenarios.
[0037] In an alternative embodiment, step S3 is specifically:
[0038] Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, use the analog sampling value as the sampling output value; if the analog sampling value is less than the minimum value of the actual sampling range, use the minimum value of the actual sampling range as the sampling output value; if the analog sampling value is greater than the maximum value of the actual sampling range, use the maximum value of the actual sampling range as the sampling output value.
[0039] In an alternative embodiment, step S4 is specifically:
[0040] Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, the actual sampling range is not adjusted; if the analog sampling value is less than the minimum value of the actual sampling range, the minimum value of the actual sampling range is updated with the analog sampling value; if the analog sampling value is greater than the maximum value of the actual sampling range, the maximum value of the actual sampling range is updated with the analog sampling value.
[0041] In an alternative embodiment, step S3 further includes: determining the actual output value based on the sampling output value, the actual sampling range, and the actual output range.
[0042] In an alternative embodiment, the difference between the maximum value and the minimum value of the actual sampling range is used as the actual sampling range amplitude, the difference between the maximum value and the minimum value of the actual output range is used as the actual output range amplitude, and the ratio of the sampling output value to the actual sampling range amplitude is equal to the ratio of the actual output value to the actual output range amplitude.
[0043] It should be noted that in the embodiments of the present invention, the actual output value is the data collected from the analog sensor and adjusted, and then transmitted to subsequent devices or programs for use. Through the adjustment method of this embodiment, any value within the output value range of the analog sensor can be mapped within the actual output range.
[0044] In an alternative embodiment, the analog sensor is used to collect the handle rocker state signal. In some embodiments, the handle can be a game handle, an aircraft handle, or other handles involved in control operations.
[0045] In an alternative embodiment, the analog sensor is a Hall sensor, a potentiometer, a pressure sensor, or a capacitive position sensor.
[0046] In an alternative embodiment, the analog sampling value is a voltage value or a current value.
[0047] Embodiment 2
[0048] Please refer to Figure 2 , an embodiment in which a dynamic sampling method of an analog sensor is applied to the collection of the handle rocker state proposed by the present invention, and the specific working process is as follows:
[0049] After the data acquisition system or device is powered on and initialized, read the end values (A, B) of the sampling initial value range of the joystick stored in the storage module (such as FLASH), store the end values in the buffer for use. At this time, store the end value A at the position of key value C in the buffer, and store the end value B at the position of key value D in the buffer. Then, scan the joystick and read the joystick key value E. In this embodiment, the joystick key value E is obtained by collecting the state signal of the handle joystick through an analog sensor. After that, determine whether the joystick key value E is less than the value at the position of key value C in the buffer. If the joystick key value E is less than the value at the position of key value C in the buffer, send the current joystick value C to the relevant device for use, and store the key value E at the position of key value C in the buffer to overwrite and update the value at the position of key value C in the buffer, and return to scanning the joystick state; if the joystick key value E is greater than or equal to the value at the position of key value C in the buffer, further determine whether the joystick key value E is greater than the value at the position of key value D in the buffer. If the joystick key value E is greater than the value at the position of key value D in the buffer, send the current joystick value D to the relevant device for use, and store the key value E at the position of key value D in the buffer to overwrite and update the value at the position of key value D in the buffer, and return to scanning the joystick state; if the joystick key value E is less than or equal to the value at the position of key value D in the buffer, send the current joystick value E to the relevant device for use, and return to scanning the joystick state. If power is off and then powered on again, it will return to the initial state.
[0050] Taking the game handle joystick using a sliding rheostat as an example: The default set sampling initial value range is 0.7V - 2.5V. When it is used and it is found that the sampling voltage range reaches 0.5V - 3V, the sampling range will be dynamically adjusted to 0.5V - 3V until power is off. After power is on again, it will return to the default range of 0.7V - 2.5V; if the sampling voltage range is 0.8V - 2.4V during use, the default range value of 0.7V - 2.5V is still used; if the sampling voltage range is 0.8V - 2.8V during use, the sampling range will be dynamically adjusted to 0.7 - 2.8V; if the sampling voltage range is 0.5V - 2.4V during use, the sampling range will be dynamically adjusted to 0.5V - 2.5V.
[0051] By setting steps of preset range, parameter comparison, dynamic adjustment, and using the current value, when the sampling range value exceeds the preset range value, the latest range value can still be updated in real time. That is, the range of remote control of components by the user is corrected without the user's perception, avoiding the voltage output error caused by individual component differences in the mass production of remote control components, ensuring the normal operation of remote control components, enabling each remote control component to have a high-precision and full-range use effect when fully controlled, and providing a relatively safe fixed preset range value for the user when replacing remote control components, which is beneficial for the user to select different remote control components in multiple aspects.
[0052] In addition, an embodiment of the present invention further provides a computer device, including a processor, a memory, and an analog sensor sampling device. The processor is configured to execute a computer program stored in the memory to implement the dynamic sampling method of the analog sensor in the above embodiment. The computer device can be a PC, an industrial control computer, a single-chip microcomputer, a microprocessor, or the like. The analog sensor sampling device can be an A / D converter, a modular analog acquisition unit, a data acquisition card, or the like.
[0053] Those skilled in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a hard disk, a USB flash drive, or a FLASH, etc.
[0054] Certainly, the present invention can also have many other implementation manners. Based on this implementation manner, other implementation manners obtained by those of ordinary skill in the art without any creative labor belong to the scope protected by the present invention.
Claims
1. A dynamic sampling method for an analog sensor, characterized in that, The analog sensor is used to collect the state signals of the handle rocker. The dynamic sampling method of the analog sensor includes the following steps: S1: Read the preset sampling range, take the minimum value of the preset sampling range as the minimum value of the actual sampling range, and take the maximum value of the preset sampling range as the maximum value of the actual sampling range. The boundaries of the preset sampling range are set within the boundaries of the output values of multiple analog sensors; S2: Sample the output of the analog sensor to obtain an analog sampling value; S3: Output the actual sampling value according to the comparison result between the analog sampling value and the actual sampling range; Step S3 is specifically: Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, use the analog sampling value as the sampling output value; If the analog sampling value is less than the minimum value of the actual sampling range, use the minimum value of the actual sampling range as the sampling output value; If the analog sampling value is greater than the maximum value of the actual sampling range, use the maximum value of the actual sampling range as the sampling output value; S4: After outputting the actual sampling value, adjust the actual sampling range according to the comparison result between the analog sampling value and the actual sampling range; S5: Return to execute step S2.
2. The dynamic sampling method for an analog sensor according to claim 1, characterized in that, Step S4 is specifically: Compare the analog sampling value with the maximum and minimum values of the actual sampling range respectively. If the analog sampling value is within the actual sampling range, do not adjust the actual sampling range; If the analog sampling value is less than the minimum value of the actual sampling range, use the analog sampling value to update the minimum value of the actual sampling range; If the analog sampling value is greater than the maximum value of the actual sampling range, use the analog sampling value to update the maximum value of the actual sampling range.
3. The dynamic sampling method for an analog sensor according to any one of claims 1 or 2, characterized in that, Step S3 further includes: determining the actual output value through the sampling output value, the actual sampling range, and the actual output range.
4. The dynamic sampling method for an analog sensor according to claim 3, characterized in that, The difference between the maximum value and the minimum value of the actual sampling range is used as the amplitude of the actual sampling range. The difference between the maximum value and the minimum value of the actual output range is used as the amplitude of the actual output range. The ratio of the sampling output value to the amplitude of the actual sampling range is equal to the ratio of the actual output value to the amplitude of the actual output range.
5. The dynamic sampling method for an analog sensor according to claim 1, characterized in that, The analog sensor is a Hall sensor, a sliding rheostat, a pressure sensor, or a capacitive position sensor.
6. The dynamic sampling method for an analog sensor according to claim 1, characterized in that, The analog sampling value is a voltage value or a current value.
7. A computer device, characterized in that, It includes a processor, a memory, and an analog sensor sampling device. The processor is used to execute the computer program stored in the memory to implement a dynamic sampling method of an analog sensor as described in any one of claims 1 to 6.
8. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by the processor, it implements a dynamic sampling method of an analog sensor as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Mobile terminal gyroscope range setting method, system and mobile terminal
CN104061922A
Operation device
JP2014002595A