Infrared key control method and system for instrument
By executing preset wave transmitting programs and echo signal matching technology on the infrared key module, the existing explosion-proof instruments are solved due to functional error triggering caused by clutter interference in flammable and explosive environments, achieving higher reliability and normal usage rate.
Patent Information
- Application Number
- CN202411331364.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2044-09-24
AI Technical Summary
Existing explosion-proof instruments with infrared buttons are susceptible to clutter interference in flammable and explosive environments, resulting in mistriggered instrument functions and affecting normal use.
By executing the preset wave transmitting program, the transmitting unit of the infrared key module outputs infrared light of a specific waveform, the receiving unit outputs the echo signal based on the received infrared light signal, and judges the touch state of the infrared key by matching the characteristics of the transmitted waveform and the echo signal, and outputs the command code only when the preset trigger condition is met to execute the corresponding function.
It effectively reduces the probability of instrument function being accidentally triggered due to external irradiation or mistouch, and improves the reliability and normal use rate of instruments in flammable and explosive environments.
Smart Images

Figure CN119207065B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of instruments and meters, and in particular to an infrared key control method, system, storage medium and computer program product for instruments and meters. Background Art
[0002] In some process automation scenarios, there are flammable and explosive substances such as dust or combustible gas, so the instruments used in these scenarios often have higher explosion-proof performance requirements. Since such process industrial sites do not allow the instrument housing to be opened for operation, infrared buttons and other inductive buttons have begun to be widely used in explosion-proof instruments.
[0003] The existing Chinese patent with announcement number CN204302735U discloses a flameproof instrument with infrared buttons, including a main control unit and an HMI interface unit; the main control unit and the HMI interface unit communicate through the UART protocol; the HMI interface unit includes an HMI controller, an LCD liquid crystal display and a drive unit, and an infrared button unit; the HMI controller transmits the detected infrared button data to the main control unit of the radar level meter, and outputs the feedback information of the main control unit and displays it on the LCD liquid crystal display. The utility model does not need to unscrew the shell, and can realize on-site instrument debugging operation. Especially in the explosive hazardous area, the flameproof product can debug the instrument without powering off.
[0004] However, this type of explosion-proof instrument with infrared buttons still has the following problems: since there are other clutters in the infrared band in the usage scenario, these clutters will be received by the infrared button unit and cause some functions of the instrument to be triggered by mistake, affecting the normal use of the instrument. Summary of the invention
[0005] Based on this, it is necessary to provide an infrared button control method, system, computer-readable storage medium and computer program product for an instrument that can improve the false triggering problem in response to the above technical problems.
[0006] In a first aspect, the present application provides an infrared key control method for an instrument, the method comprising:
[0007] Step S100: executing a preset wave-transmitting program to control the transmitting unit of the infrared key module to output a preset transmitting waveform. The infrared key module is provided with at least two infrared keys, and each infrared key includes a transmitting unit and a receiving unit;
[0008] Step S200: reading the echo signal output by the receiving unit, matching the echo signal with a preset transmission waveform, and acquiring key touch data according to the matching result;
[0009] Step S300: extracting key configuration data matching the key touch data from the preset key function configuration list, and determining whether the trigger state data corresponding to the key configuration data meets the preset trigger condition;
[0010] Step S400: If yes, output the instruction code corresponding to the preset key function to execute the function corresponding to the preset key function.
[0011] In one embodiment, step S100 includes:
[0012] A waving signal having a preset waveform characteristic is output, wherein the preset waveform characteristic is a square wave signal whose waveform changes output sequentially per unit time are high-low-high-low-high-low-low-low-low-low-low-low-low-low.
[0013] In one embodiment, step S200 includes:
[0014] Step S210: matching the multi-path echo signals received by the multiple receiving units with the preset waveforms respectively, so as to determine whether the multi-path echo signals have the same preset waveform characteristics as the transmitting signal;
[0015] Step S220: Recording the echo signal with the preset waveform feature as a valid echo signal, and recording the echo signal without the preset waveform feature as an invalid waveform signal;
[0016] Step S230: storing the multiple echo signals as valid signals or invalid signals in a preset order as key touch data.
[0017] In one embodiment, the trigger state data includes debounce timing data, key touch duration data and key state data, and the preset trigger condition includes a preset debounce time threshold; step S300 includes:
[0018] Read a key configuration data in the key function configuration list in order, and determine whether the key configuration data matches the key touch data;
[0019] If the key configuration data matches the key touch data, the debounce timing data corresponding to the key configuration data is read to determine whether the debounce timing data is greater than a preset debounce time threshold;
[0020] If not, then add a preset unit time length to the de-jittering time data, and use the calculation result as the new de-jittering time data;
[0021] If yes, the key state data corresponding to the key configuration data is changed to a pressed state, and the key touch duration data corresponding to the key configuration data is obtained, a preset unit duration is added to the key touch duration data, and the calculation result is used as the new key touch duration data;
[0022] Determine whether the button configuration data is the last one in the preset button function configuration list;
[0023] If so, the preset wave-transmitting program is re-executed to control the transmitting unit of the infrared key module to output the preset transmitting waveform.
[0024] In one embodiment, step S300 includes:
[0025] Determine whether the button configuration data has the corresponding preset long press function;
[0026] If yes, further determine whether the key touch duration data is greater than the preset long press time;
[0027] If the key touch duration data is greater than the preset long press time, a trigger signal indicating that the key touch data meets the corresponding condition of the long press function in the preset key function is output.
[0028] In one embodiment, the trigger state data includes debounce timing data, key touch duration data and key state data, and the preset trigger condition includes a preset debounce time threshold; step S300 includes:
[0029] Read a key configuration data in the key function configuration list in order, and determine whether the key configuration data matches the key touch data;
[0030] If the key configuration data does not match the key touch data, the debounce timing data corresponding to the key configuration data is read to determine whether the debounce timing data is greater than a preset debounce time threshold;
[0031] If yes, then the debounce time data is reduced by a preset unit time length, and the calculation result is used as the new debounce time data;
[0032] If not, the debounce timing data corresponding to the key configuration data is cleared to zero, and the key state data corresponding to the key configuration data is changed to a pop-up state.
[0033] In one embodiment, step S300 includes:
[0034] Determine whether the key touch duration data corresponding to the key configuration data is greater than the preset short press time;
[0035] If the key touch duration data is greater than the preset short press time, a trigger signal indicating that the key touch data meets the corresponding condition of the short press function in the preset key function is output.
[0036] In a second aspect, the present application also provides an infrared key control system for an instrument, the system comprising:
[0037] At least two infrared key modules, each infrared key module includes a transmitting unit and a receiving unit, the transmitting unit is used to receive a control instruction corresponding to a preset wave transmission program and output a preset transmission waveform; the receiving unit receives an echo waveform and outputs an echo signal corresponding to the echo waveform;
[0038] A storage module, used to store a preset key function configuration list and instruction codes corresponding to the functions, wherein the key function configuration list includes key configuration data;
[0039] The calculation and data processing unit is used to match the echo signal with the transmission waveform to obtain the touch key data, match the touch key data with the preset key configuration data, and determine whether the matched key configuration data meets the conditions of the preset key function. If so, output the corresponding instruction code.
[0040] In a third aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0041] Step S100: executing a preset wave-transmitting program to control the transmitting unit of the infrared key module to output a preset transmitting waveform. The infrared key module is provided with at least two infrared keys, and each infrared key includes a transmitting unit and a receiving unit;
[0042] Step S200: reading the echo signal output by the receiving unit, matching the echo signal with a preset transmission waveform, and acquiring key touch data according to the matching result;
[0043] Step S300: extracting key configuration data matching the key touch data from the preset key function configuration list, and determining whether the trigger state data corresponding to the key configuration data meets the preset trigger condition;
[0044] Step S400: If yes, output the instruction code corresponding to the preset key function to execute the function corresponding to the preset key function.
[0045] In a fourth aspect, the present application further provides a computer program product, the computer program product comprising a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0046] Step S100: executing a preset wave-transmitting program to control the transmitting unit of the infrared key module to output a preset transmitting waveform. The infrared key module is provided with at least two infrared keys, and each infrared key includes a transmitting unit and a receiving unit;
[0047] Step S200: reading the echo signal output by the receiving unit, matching the echo signal with a preset transmission waveform, and acquiring key touch data according to the matching result;
[0048] Step S300: extracting key configuration data matching the key touch data from the preset key function configuration list, and determining whether the trigger state data corresponding to the key configuration data meets the preset trigger condition;
[0049] Step S400: If yes, output the instruction code corresponding to the preset key function to execute the function corresponding to the preset key function.
[0050] The above-mentioned infrared key control method, system, storage medium and computer program product for instruments execute a preset wave transmission program to make the transmitting unit output infrared light of a specific waveform, and the receiving unit outputs a corresponding echo signal according to the received infrared light signal. The waveform of the echo signal is compared with the transmitted waveform. If the waveform matches, it is regarded as a valid echo, and if the waveform does not match, it is an invalid waveform. Then, the corresponding touch key data is output according to the matching result. When the touch key condition is met, the corresponding function is triggered, thereby reducing the probability of false triggering of the instrument function due to external stray light or false touch. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of a flow chart of an infrared key control method for an instrument in an embodiment;
[0052] Figure 2 A square wave signal waveform diagram having a preset waveform characteristic in one embodiment;
[0053] Figure 3 is a schematic diagram of a specific flow chart of step S200 in an embodiment;
[0054] Figure 4 A schematic diagram of a specific flow chart of an infrared key control method for an instrument in an embodiment;
[0055] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] In one embodiment, Figure 1 As shown, a method for controlling an instrument using an infrared key is provided, comprising the following steps:
[0058] Step S100: Execute a preset wave-transmitting program to control the transmitting unit of the infrared key module to output a preset transmitting waveform. The infrared key module is provided with at least two infrared keys, and each infrared key includes a transmitting unit and a receiving unit.
[0059] Among them, the preset wave program is a control program pre-stored in the storage module, which is used to control the infrared transmitting module to output a specific transmitting waveform, and outputs a wave signal with a preset waveform characteristic. The preset waveform characteristic is a square wave signal with a waveform change of high-low-high-low-high-low-low-low-low-low-low-low-low output in sequence per unit time. In the embodiment of the present application, the square wave signal with the preset waveform characteristic is as follows Figure 2 As shown, H represents a high level and L represents a low level. When the waveform changes to a high level state, the infrared light emitting element of the transmitting unit emits light, and when the waveform changes to a low level state, the infrared light emitting element of the transmitting unit goes out. Each high / low level lasts for 2ms. Executing a preset wave program once outputs a characteristic waveform totaling 24ms.
[0060] Step S200: reading the echo signal output by the receiving unit, matching the echo signal with a preset transmission waveform, and acquiring key touch data according to the matching result.
[0061] The echo signal is an electrical signal output by the receiving unit according to the infrared light signal it receives; the touch key data is data composed of arranging the judgment results in a preset order after judging the validity of the echo signals output by all infrared key receiving units.
[0062] When the infrared light signal emitted by the transmitting unit encounters an obstacle on its optical path, it will be reflected and received by the receiving unit. In this embodiment, the receiving unit outputs a high level when receiving the infrared light, and outputs a low level when not receiving the infrared light. When there is an obstacle on the infrared emission optical path, the transmitting unit outputs an infrared light signal corresponding to the emission signal, and the echo signal output by the receiving unit should also be an echo signal corresponding to the emission signal. Therefore, by matching the waveform of the echo signal with the preset emission waveform, it can be determined whether there is an obstacle on the infrared emission optical path of the infrared key transmitting unit, and then used as a criterion for determining whether the infrared key is pressed.
[0063] like Figure 3 As shown, the specific steps of step S200 include:
[0064] Step S210: Match the multi-path echo signals received by the multiple receiving units with the preset waveforms respectively, so as to determine whether the multi-path echo signals have the same preset waveform characteristics as the transmitting signal.
[0065] In this step, by setting a specific preset waveform feature and using the preset waveform feature as the basis for determining the validity of the echo signal, that is, the echo signal also needs to satisfy the condition that the waveform change is high-low-high-low-high-low-low-low-low-low-low-low-low. Only when the condition is met will it be determined as a valid echo signal, and if it is not met, it will be determined as an invalid echo signal, thereby making a more accurate judgment on whether there is an obstruction in the optical path of the infrared light emitted by the transmitting unit.
[0066] Step S220: Recording the echo signal with the preset waveform feature as a valid echo signal, and recording the echo signal without the preset waveform feature as an invalid waveform signal;
[0067] Step S230: storing the multiple echo signals as valid signals or invalid signals in a preset order as key touch data.
[0068] In the embodiments of the present application, Figure 2 As shown, the infrared key module includes three infrared keys, and the three infrared keys each include a corresponding transmitting unit and a receiving unit. Specifically, the three infrared keys are infrared key A, infrared key B, and infrared key C. When the echo signal is valid, the validity judgment result is recorded as 1, and when the echo signal is invalid, the validity judgment result is recorded as 0. The preset order is the order in which infrared key A, infrared key B, and infrared key C are arranged in sequence. For example, the echo signal received by infrared key A is valid, the echo signal received by infrared key B is invalid, and the echo signal received by infrared key C is valid. In this case, the touch key data is 101.
[0069] Step S300: extracting key configuration data matching the key touch data from the preset key function configuration list, and determining whether the trigger state data corresponding to the key configuration data meets the preset trigger condition.
[0070] The preset key function configuration list is a data table storing the corresponding relationship between key configuration data and key functions. The list has a fixed order when stored in the preset storage space. The trigger status data includes debounce timing data, key touch duration data and key status data. The preset trigger condition includes a preset debounce time threshold. The specific steps of step S300 include:
[0071] Step S310: sequentially reading a key configuration data in the key function configuration list, and determining whether the key configuration data matches the key touch data.
[0072] Among them, the key touch duration data is data corresponding to the key configuration data one by one and used to calculate the continuous successful matching time of the corresponding key configuration data. The preset unit duration is a fixed duration. In the embodiment of the present application, the preset unit duration is 24ms, that is, after the key configuration data and the key touch data are successfully matched, the key duration data corresponding to the key configuration data increases by 24ms, indicating that the infrared key corresponding to the key touch data has been continuously pressed in the past 24ms. In the embodiment of the present application, the key configuration data and the key touch data are the same type of data, and the key configuration data is also composed of three digits, and each digit also contains only two values of "0" and "1". The key configuration data is extracted in sequence according to the order of the preset key function configuration list, and it is determined whether the key configuration data and the key touch data are the same. If they are the same, it means that the match is successful, and if they are different, it means that the match fails.
[0073] Step S311: If the key configuration data matches the key touch data, the de-bounce timing data corresponding to the key configuration data is read to determine whether the de-bounce timing data is greater than a preset de-bounce time threshold.
[0074] The preset de-bounce time threshold is used to determine whether it is external interference or false touch. When the key duration data exceeds the preset de-bounce time threshold, it is determined that the current infrared key is triggered and is not a false touch or interference key behavior. If it does not exceed the preset de-bounce time threshold, further waiting is required. In the embodiment of the present application, the preset de-bounce time threshold is 70ms.
[0075] Step S312: If not, then add a preset unit time length to the de-jittering timing data, and use the calculation result as the new de-jittering timing data.
[0076] In this step, the de-bouncing timing data corresponding to the successfully matched key configuration data is increased by a preset unit time length, which means that the key touch behavior of the input touch data has continued for another unit time length. It should be noted that the de-bouncing timing data is accumulated only when the de-bouncing timing data is less than or equal to the preset de-bouncing time threshold. After the de-bouncing timing data is accumulated to be greater than the preset de-bouncing time threshold, the de-bouncing timing data is not accumulated. After step S312 is executed, jump directly to step S317 to complete the traversal of the preset key function configuration list.
[0077] Step S313: If yes, the key state data corresponding to the key configuration data is changed to a pressed state, and the key touch duration data corresponding to the key configuration data is obtained, a preset unit duration is added to the key touch duration data, and the calculation result is used as the new key touch duration data.
[0078] Among them, the key state data is also a marking data corresponding to the key configuration data one by one, used to indicate whether the current key state is a pressed state or a pop-up state. Specifically, the key configuration data whose debounce timing data is greater than the preset debounce time threshold is marked as a pressed state. In this step, by marking the key configuration data that satisfies the condition that the debounce timing data is greater than the preset debounce time threshold as a pressed state, it means that the duration of the current touch key data exceeds the preset debounce time threshold, and the continuous input time is long, which can exclude the erroneous input caused by stray light or false touch, that is, it can be determined that the touch key behavior of inputting the current touch key data is input by the operator, and the probability of false triggering is reduced by adding a separate debounce timing and debounce duration. In step S313, the touch key duration data is also corresponding to the key configuration data one by one, used to record the time that the key configuration data that meets the debounce condition continues to match successfully after meeting the debounce timing data, and the touch key duration data is a key parameter for determining whether to trigger a long press function or a short press function.
[0079] Step S314: Determine whether the button configuration data has a corresponding preset long press function.
[0080] Among them, the preset long press function is a function included in at least part of the key configuration function, that is, for at least part of the key configuration data, it includes a preset long press function and a preset short press function; for the key corresponding to the same key configuration data, different functions are triggered when the key touch behavior is applied for different durations; by adding the long press function and the short press function to the same key configuration data, the utilization rate of the key can be improved, and the number of infrared keys used in the same instrument can be reduced, which can save production costs on the one hand, and reduce the density of the infrared keys on the other hand, and reduce the probability of false triggering of adjacent infrared keys when touching the keys. And because both the wave signal and the effective echo signal need to match the preset characteristic waveform, the duration of the long press key touch behavior can be more accurately judged and calculated, thereby improving the accuracy of triggering the corresponding function.
[0081] Step S315: If yes, further determine whether the key touch duration data is greater than the preset long press time.
[0082] Among them, the preset long press time is used to determine whether the key touch duration data reaches the time threshold for triggering the long press function. In the embodiment of the present application, the preset long press time is 1000ms, that is, the same key touch data must be received continuously for 42 times and the key touch duration exceeds 1000ms to meet the conditions for triggering the long press function.
[0083] Step S316: If the key touch duration data is greater than the preset long press time, a trigger signal indicating that the key touch data satisfies the condition corresponding to the long press function in the preset key function is output.
[0084] Through steps S315 and S316, it is possible to determine whether the current key behavior meets the conditions for triggering the long press function, that is, the key touch duration data is greater than the preset key touch duration. If the key touch duration data exceeds the preset key touch duration, the corresponding long press function is triggered. The specific method of triggering the long press function is to output a trigger signal. In an embodiment of the present application, the trigger signal is a code corresponding to the long press / short press function of the key configuration data. By using the code as an index, the corresponding function can be called to implement the corresponding function.
[0085] If the key touch duration data is less than or equal to the preset long press time, jump to step S317 to complete traversing the subsequent key configuration data in the preset key function configuration list.
[0086] Step S317: Determine whether the key configuration data is the last one in the preset key function configuration list.
[0087] Step S318: If yes, re-execute the preset wave-transmitting program to control the transmitting unit of the infrared key module to output the preset transmitting waveform.
[0088] Through step S317 and step S318, it is determined whether the key configuration data in the preset key configuration list has been accessed. If so, the preset wave transmission program is re-executed to control the transmitting unit of the infrared key module to output the preset transmitting waveform, that is, return to step S100. Otherwise, return to step S310 to continue to complete the subsequent function of traversing the preset key function configuration list.
[0089] In one embodiment, step S300 further includes:
[0090] Step S321: If the key configuration data does not match the key touch data, the debouncing timing data corresponding to the key configuration data is read to determine whether the debouncing timing data is greater than a preset debouncing time threshold.
[0091] In step S310, it is determined whether the extracted key configuration data matches the touch key data. In step S321, the debounce timing data corresponding to the key configuration data that fails to match is still read, and it is determined whether the debounce timing data is greater than the preset debounce time threshold. If the debounce timing data extracted at this time is greater than the preset debounce time threshold, it means that the case configuration data has been pressed before. At this time, it is necessary to further determine whether the touch key behavior of the previously input corresponding touch key data has ended or has jittered.
[0092] Step S322: If yes, the de-jittering timing data is reduced by a preset unit time length, and the calculation result is used as the new de-jittering timing data.
[0093] In this step, the de-bouncing timing data that is originally greater than the preset de-bouncing time threshold is reduced by a preset unit time length, so that it is less than or equal to the preset de-bouncing time data. After completing this step, jump to step S317. Through step 322, it can provide an opportunity for further judgment for the key configuration information that is not currently matched successfully but has been marked as pressed in the past. If the key configuration data is matched successfully again after the next round of wave transmission, the condition for entering step S311 is met, and in step S312, the de-bouncing timing data corresponding to the key configuration data is re-added with a preset unit time length, so that the de-bouncing timing data is greater than the preset de-bouncing timing data. In this way, input interruptions caused by factors such as stray light, operator finger jitter or improper operation can be avoided, and the effect of eliminating jitter and increasing fault tolerance can be achieved.
[0094] Step S323: If not, the debounce timing data corresponding to the key configuration data is cleared, and the key state data corresponding to the key configuration data is changed to a pop-up state.
[0095] Through this step, the debounce timing data that is less than the preset debounce time threshold can be cleared, and the corresponding key configuration data can be restored to the pop-up state. When this step is executed, it means that the extracted key configuration information has failed to match successfully for two consecutive wave cycles. If the key configuration data has been pressed before, it still fails to match successfully after two wave cycles. It can be determined that the previous key touch behavior has stopped, and the debounce timing data should be cleared, and the key state data corresponding to the key configuration data should be restored to the pop-up state. When the same key touch behavior occurs later, a new judgment should be made; in addition, it is necessary to further determine whether the previous key touch behavior should trigger the corresponding function.
[0096] Step S324: determining whether the key touch duration data corresponding to the key configuration data is greater than the preset short press time.
[0097] Step S325: If the key touch duration data is greater than the preset short press time, a trigger signal indicating that the key touch data meets the condition corresponding to the short press function in the preset key function is output.
[0098] Through step S324 and step S325, it can be determined whether the key configuration data that has been determined to be pop-up meets the trigger condition of the short press function. The trigger condition of the short press function is whether the touch key duration data corresponding to the key configuration data is greater than the preset short press time; if so, it means that the key configuration data meets the trigger condition of the short press function, thereby outputting a trigger signal indicating that the touch key data meets the corresponding condition of the short press function in the preset key function; if not, it means that the key configuration data does not meet the trigger condition of the short press function, and at this time, the touch key duration data corresponding to the key configuration data needs to be cleared.
[0099] Step S400: If yes, output the instruction code corresponding to the preset key function to execute the function corresponding to the preset key function.
[0100] In the process of executing steps S100 to S300, a trigger signal indicating that the touch key data meets the conditions corresponding to the short press function in the preset key function may be output, and a trigger signal indicating that the touch key data meets the conditions corresponding to the long press function in the preset key function may also be output. In addition, the above two trigger signals may not be output and the cycle will continue; but after outputting the trigger signal corresponding to the conditions of the short press function or the trigger signal corresponding to the conditions of the long press function, the conditions for entering step S400 will be met. By executing step S400, different programs or functions will be executed according to different trigger signals to achieve different functions.
[0101] like Figure 3 As shown, the embodiment of the present application provides an execution mode of running and jumping of step S100 to step S300 and its sub-steps. It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless clearly stated herein, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0102] Reference Figure 4, the embodiment of the present application takes the unlocking function as an example to further elaborate on the specific process of steps S100 to S400. In this example, the unlocking function is a function in the preset key function configuration list, and its key configuration data is 101, and the unlocking function is the preset long-press function corresponding to the key configuration data 101. Therefore, if the operator wants to complete the unlocking function of the instrument through the infrared key, it is necessary to press the infrared key A and the infrared key C for more than 1000ms at the same time to trigger the unlocking function. During the key-touching process, the operator will inevitably press the infrared key A and the infrared key C successively. Although the time difference between the pressing successively is short, there may still be a time difference of several milliseconds to tens of milliseconds.Therefore, when only one finger touches the corresponding area of infrared key A or infrared key C, the infrared light signal with preset waveform characteristics is emitted by executing step S100. After encountering the finger, the infrared light signal is reflected and received by the receiving unit. The receiving unit outputs an echo signal. After the echo signal is determined to be a valid echo signal, the touch key information of 001 or 100 is output. From then on, the preset key function configuration list in the preset key function configuration list is extracted one by one until the key configuration information 001 or 100 that is the same as the touch key information is extracted. After the match is successful, the touch key duration data corresponding to the key configuration information is increased from 0ms to 24ms. Since the touch key duration data does not exceed the preset de-bounce time threshold at this time, the preset key function configuration list is continued to be accessed. Assume that the subsequent key configuration data in the key function configuration list is accessed until the last key configuration data in the preset key function configuration list is accessed. Since the condition for triggering the corresponding function is not met, the process returns to step S100 to start a new round of loop. Assume that in the process of executing a new wave-emitting program, another finger of the staff member presses the sensing area of another infrared key, but the echo signal waveform output by the receiving unit of the infrared key is not complete, that is, it does not meet the preset waveform characteristics. Therefore, the key touch data output in this round of loop is still 100 or 001, and the key touch data output in the next round of loop is 101; after the key touch data with a value of 101 is output for the first time, the key configuration data successfully matched in the previous round will be reset. The key touch duration data corresponding to the data (100 or 001) is cleared, and the newly matched key configuration data (101) is increased by 24ms, that is, from 0ms to 24ms, and the subsequent steps are completed until a new round of cycles is completed. When the above cycle is performed to the third round, the key touch duration data increases to 72ms, which is higher than the preset de-jitter duration threshold of 70ms. At this time, it is determined that the key touch behavior at this time is not jitter or other scattered light, and the key state data corresponding to the key configuration data is marked as pressed state, and its key duration data is accumulated from zero. In the subsequent cycles, it will be checked whether the key configuration data has the corresponding long press function. If there is no corresponding long press function, it will jump to step S317 to visit The program will then ask for other key configuration data in the preset key configuration list to complete the subsequent cycle; if the key configuration data has the corresponding long press function, it will further determine whether the key touch duration data is greater than the preset long press time. When the cycle reaches a key touch duration greater than 1000ms, the long press function will be triggered; if the key touch duration does not reach 1000ms and the operator removes his finger and stops touching the key, then in the next cycle, the key configuration data that has been successfully matched will fail to match for two consecutive wave cycles, and then the de-bouncing timing data corresponding to the key configuration data will be cleared, and it will be determined whether the key touch duration data is greater than the preset short press time. If so, the short press function will be triggered, and its key duration data will be cleared, and the key state will be restored to the pop-up state.When the key touch duration exceeds the preset long press / short press time and the corresponding function is triggered, a trigger signal indicating that the key touch data meets the corresponding conditions of the long press / short press function in the preset key function is first output. In this example, the trigger signal is composed of three-digit key configuration data and a long press / short press function indication bit. The long press / short press function indication bit corresponding to the long press function is 1, and the long press / short press function indication bit corresponding to the short press function is 0. That is, when the key touch duration is greater than 1000ms, a trigger signal 1011 indicating that the unlocking function conditions are met is output, and then 1011 is used as an instruction code to call and execute the unlocking function function / program, thereby realizing the unlocking function.
[0103] Based on the same inventive concept, the embodiment of the present application also provides an instrument infrared key control system for implementing the above-mentioned instrument infrared key control method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more instrument infrared key control system embodiments provided below can refer to the limitations of the instrument infrared key control method above, and will not be repeated here.
[0104] In one embodiment, an infrared key control system for an instrument is provided, comprising: a storage module, a computing and data processing unit, and three infrared modules, wherein:
[0105] The three infrared key modules are infrared key A, infrared key B and infrared key C. Each infrared key module includes a transmitting unit and a receiving unit. The transmitting unit is used to receive a control instruction corresponding to a preset wave transmission program and output a preset transmission waveform; the receiving unit receives an echo waveform and outputs an echo signal corresponding to the echo waveform.
[0106] A storage module, used to store a preset key function configuration list and instruction codes corresponding to the functions, wherein the key function configuration list includes key configuration data;
[0107] The calculation and data processing unit is used to match the echo signal with the transmission waveform to obtain the touch key data, match the touch key data with the preset key configuration data, and determine whether the matched key configuration data meets the conditions of the preset key function. If so, output the corresponding instruction code.
[0108] Each module in the above-mentioned infrared key control system for instruments can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module above.
[0109] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an infrared key control method for an instrument is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse, etc.
[0110] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0111] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0112] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0113] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0114] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0115] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0116] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for controlling an instrument using an infrared key, characterized in that: The method comprises: Execute a preset wave-transmitting program to control the transmitting unit of the infrared key module to output a preset transmitting waveform, wherein the infrared key module is provided with at least two infrared keys, each of which includes a transmitting unit and a receiving unit; Read the echo signal output by the receiving unit, match the echo signal with the preset transmission waveform, and obtain the key touch data according to the matching result; Extracting key configuration data matching the key touch data from a preset key function configuration list, and determining whether the trigger state data corresponding to the key configuration data meets a preset trigger condition; If yes, output the instruction code corresponding to the preset key function to execute the function corresponding to the preset key function; The specific steps of reading the echo signal output by the receiving unit, matching the echo signal with a preset transmission waveform, and acquiring the key touch data according to the matching result include: Matching the multiple echo signals received by the multiple receiving units with preset waveforms respectively, so as to determine whether the multiple echo signals have the same preset waveform characteristics as the transmitting signal; Recording the echo signal having the preset waveform feature as a valid echo signal, and recording the echo signal not having the preset waveform feature as an invalid waveform signal; The multiple echo signals are stored as valid signals or invalid signals in a preset order as key touch data.
2. The infrared key control method for an instrument according to claim 1, characterized in that: The specific steps of the preset wave-generating program include: A wave signal having a preset waveform characteristic is output, wherein the preset waveform characteristic is a square wave signal whose waveform changes sequentially output per unit time are high-low-high-low-high-low-low-low-low-low-low-low-low.
3. The infrared key control method for an instrument according to claim 1 or 2, characterized in that: The trigger status data includes debounce timing data, key touch duration data and key status data, and the preset trigger condition includes a preset debounce time threshold; the specific steps of extracting key configuration data matching the key touch data from the preset key function configuration list and judging whether the trigger status data corresponding to the key configuration data meets the preset trigger condition include: Read one of the key configuration data in the key function configuration list in order, and determine whether the key configuration data matches the key touch data; If the key configuration data matches the key touch data, then reading the debounce timing data corresponding to the key configuration data, and determining whether the debounce timing data is greater than a preset debounce time threshold; If not, then add a preset unit time length to the de-jittering time data, and use the calculation result as the new de-jittering time data; If yes, the key state data corresponding to the key configuration data is changed to a pressed state, and the key touch duration data corresponding to the key configuration data is obtained, a preset unit duration is added to the key touch duration data, and the calculation result is used as the new key touch duration data; Determine whether the button configuration data is the last one in the preset button function configuration list; If so, the preset wave-transmitting program is re-executed to control the transmitting unit of the infrared key module to output the preset transmitting waveform.
4. The infrared key control method for an instrument according to claim 3, characterized in that: The specific steps of determining whether the trigger status data corresponding to the button configuration data meets the preset trigger condition include: Determine whether the button configuration data has a corresponding preset long press function; If yes, further determine whether the key touch duration data is greater than the preset long press time; If the key touch duration data is greater than the preset long press time, a trigger signal indicating that the key touch data meets the corresponding condition of the long press function in the preset key function is output.
5. The infrared key control method for an instrument according to any one of claims 1 to 2, characterized in that: The trigger state data includes debounce timing data and key touch duration data, and the preset trigger condition includes a preset debounce time threshold; the specific steps of extracting key configuration data matching the key touch data from the preset key function configuration list and judging whether the trigger state data corresponding to the key configuration data meets the preset trigger condition include: Read one of the key configuration data in the key function configuration list in order, and determine whether the key configuration data matches the key touch data; If the key configuration data does not match the key touch data, then reading the debounce timing data corresponding to the key configuration data, and determining whether the debounce timing data is greater than a preset debounce time threshold; If yes, the de-jittering time data is reduced by a preset unit time length, and the calculation result is used as the new de-jittering time data; If not, the de-jitter timing data corresponding to the button configuration data is cleared, and the button state data corresponding to the button configuration data is changed to a pop-up state.
6. The infrared key control method for an instrument according to claim 5, characterized in that: The specific step of determining whether the trigger status data corresponding to the button configuration data meets the preset trigger condition also includes: Determine whether the key touch duration data corresponding to the key configuration data is greater than a preset short press time; If the key touch duration data is greater than the preset short press time, a trigger signal indicating that the key touch data satisfies a condition corresponding to a short press function in the preset key function is output.
7. An infrared key control system for an instrument, characterized in that: The system comprises: At least two infrared key modules, each of which includes a transmitting unit and a receiving unit, wherein the transmitting unit is used to receive a control instruction corresponding to a preset wave transmission program and output a preset transmission waveform; and the receiving unit receives an echo waveform and outputs an echo signal corresponding to the echo waveform; A storage module, used to store a preset key function configuration list and instruction codes corresponding to the functions, wherein the key function configuration list includes key configuration data; A calculation and data processing unit, used for matching the echo signal with the transmission waveform to obtain key touch data, matching the key touch data with the preset key configuration data, and determining whether the matched key configuration data satisfies the condition of the preset key function, and if so, outputting the corresponding instruction code; The specific steps of matching the echo signal with the transmission waveform to obtain the key touch data, matching the echo signal with the preset transmission waveform, and obtaining the key touch data according to the matching result include: Matching the multiple echo signals received by the multiple receiving units with preset waveforms respectively, so as to determine whether the multiple echo signals have the same preset waveform characteristics as the transmitting signal; Recording the echo signal having the preset waveform feature as a valid echo signal, and recording the echo signal not having the preset waveform feature as an invalid waveform signal; The multiple echo signals are stored as valid signals or invalid signals in a preset order as key touch data.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Explosion-proof instrument with infrared key
CN204302735U
Infrared key control method and circuit
CN117544155A
Touch sensor switch of field apparatus
JP2013164968A