Infrared remote controller decoding method and device based on timer
By using timer interrupt and level jump judgment methods in infrared remote control decoding, the problem of decoding methods occupying microcontroller resources in the existing technology is solved, and efficient and accurate infrared remote control decoding is achieved, and compatible with different batches is achieved. The waveform difference of the remote control.
Patent Information
- Application Number
- CN202411566391.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-18
AI Technical Summary
The software decoding method of existing infrared remote controls occupies the external interrupt pin and timer resources of the microcontroller, affects the working efficiency of the microcontroller, and is unable to effectively compatible with the waveform differences of different batches of remote controls.
By connecting the IO port of the infrared receiving circuit to the IO of the microcontroller, configuring the timer interrupt, and obtaining the number of interrupts of the timing interrupts between level jumps, and determining bit "0" or bit "1" based on the number of interrupts, thereby realizing Decoding of infrared remote control.
Without occupying the external interrupt pin of the microcontroller, decoding can be completed using only one timer resource to ensure decoding accuracy and be compatible with the waveform differences of different batches of remote controls.
Smart Images

Figure CN119479257A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of infrared remote controller data decoding, and in particular to a timer-based infrared remote controller decoding method and device. Background Art
[0002] At present, there are generally two ways to decode infrared remote controllers. One is hardware decoding, that is, decoding is completed through a dedicated decoding chip; the other is software decoding, which uses an external interrupt pin and a timer of the microcontroller to implement signal sampling and complete decoding. The decoding method based on a dedicated chip is relatively simple in design, but it will increase certain hardware costs, and it has become less and less competitive in some scenarios. When using the software decoding method, it is necessary to occupy an external interrupt pin and a timer of the microcontroller. The external interrupt is an important peripheral resource for the microcontroller, and many functions are strongly dependent on it. If software decoding is used, it will affect the realization of many functions of the microcontroller and reduce the working efficiency of the microcontroller; for example, when using the software decoding method, the level is directly sampled. When this method is used, there are very strict requirements on the transmission frequency of the remote control, that is, the 0.56ms of the high level cannot produce too large deviations. Once a deviation occurs, the sampling accuracy of the data bits transmitted relatively later will be greatly reduced. Based on the test data, the waveform frequency of the transmission of remote controllers from different batches is biased, so that the waveforms of remote controllers from different batches cannot be correctly identified by direct sampling. Summary of the invention
[0003] In order to solve the above problems, the embodiments of the present application provide a timer-based infrared remote control decoding method and device.
[0004] In a first aspect, the present application provides a timer-based infrared remote control decoding method, comprising the following steps: S1: Connect the infrared IO port of the infrared receiving circuit to the IO of the microcontroller, configure the infrared IO port as an input function, configure the timer interrupt to the first preset duration, and enable the timer interrupt; S2: Sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; S3: Obtain the interruption count of the timing interruption between two consecutive level jumps of the same type; S4: when comparing the number of interruptions with the set value, determining whether a preset condition is met, if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; S5: Cache bit "0" or bit "1" data, continue sampling the subsequent levels, and return to step S3.
[0005] Preferably, step S3 specifically includes: S31: start recording the timing interrupt when the state of the first high level is a rising edge, stop recording the timing interrupt when the state of the second high level set continuously with the first high level is a rising edge, and obtain the recorded data; S32: Calculate and obtain the interruption times of the timing interruption between two rising edges according to the recorded data.
[0006] Preferably, in step S4, determining whether the preset condition is met when comparing the number of interruptions with the set value specifically includes: comparing the number of interruptions with the set value, if the number of interruptions is less than the set value, determining that the preset condition is met, if the number of interruptions is not less than the set value, determining that the preset condition is not met.
[0007] Preferably, after step S5, the following steps are further included: S6: Stop sampling when the data transmission completion condition is met.
[0008] Preferably, the set value is 12.
[0009] In a second aspect, an embodiment of the present application provides an infrared remote controller decoding device based on a timer, comprising: A configuration module is used to connect the infrared IO port of the infrared receiving circuit to the IO of the single-chip microcomputer, configure the infrared IO port as an input function, configure the timer interrupt to a first preset duration, and enable the timer interrupt; The sampling module is used to sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; A times acquisition module is used to acquire the interrupt times of the timing interrupt between two consecutive level jumps of the same type; A determination module, used for determining whether a preset condition is met when comparing the number of interruptions with a set value, and if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, and if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; Storage module, used to cache bit "0" or bit "1" data.
[0010] Preferably, the number acquisition module includes A recording unit, used for starting to record the timing interrupt when the first level jumps to the rising edge of the first high level, and stopping to record the timing interrupt when the second level jumps to the rising edge of the second high level set continuously with the first high level, so as to obtain the recorded data; The calculation unit is used to calculate the interruption times of the timing interruption located between two rising edges according to the recorded data.
[0011] Preferably, the determination module is used to compare the number of interruptions with a set value. If the number of interruptions is less than the set value, it is determined that the preset condition is met; if the number of interruptions is not less than the set value, it is determined that the preset condition is not met.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method provided in the first aspect or any possible implementation of the first aspect are implemented.
[0013] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in the first aspect or any possible implementation of the first aspect.
[0014] The beneficial effects of the present invention are as follows: obtaining the number of interruptions of the timing interruption between two consecutive same-type level jumps, and judging whether the infrared remote control transmits a bit "0" or a bit "1" between two same-type level jumps based on the comparison of the number of interruptions and the set value. Under the premise of ensuring the decoding accuracy, it does not occupy the external interrupt of the microcontroller and only occupies one timer resource. At the same time, compared with the direct sampling level in the prior art, the present application adopts the method of level jump judgment to sample the waveform, thereby eliminating the influence of the cumulative error on the waveform sampling. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A schematic diagram of a flow chart of a timer-based infrared remote controller decoding method provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of a timer-based infrared remote control decoding device provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application; Figure 4 This is a waveform diagram of a signal sent by an infrared remote control provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0018] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application, and different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments recorded. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, although the embodiment may not be clearly recorded in the following text.
[0019] The following description provides examples and does not limit the scope, applicability or examples set forth in the claims. Changes may be made to the functions and arrangements of the elements described without departing from the scope of the present application. Various processes or components may be appropriately omitted, substituted or added to each example. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted or combined. In addition, features described in some examples may be combined in other examples.
[0020] See also Figure 1 . Figure 1 1 is a flow chart of a method for calculating the leakage flow of a pipeline 1 based on pressure changes provided in an embodiment of the present application. In an embodiment of the present application, the method comprises the following steps: S1: Connect the infrared IO port of the infrared receiving circuit to the IO of the microcontroller, configure the infrared IO port as an input function, configure the timer interrupt to the first preset duration, and enable the timer interrupt; S2: Sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; S3: Obtain the interruption count of the timing interruption between two consecutive level jumps of the same type; S4: when comparing the number of interruptions with the set value, determining whether a preset condition is met, if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; S5: Cache bit "0" or bit "1" data, continue sampling the subsequent levels, and return to step S3.
[0021] In the embodiment of the present application, the level jump includes a jump from a low level to a high level, a jump from a high level to a low level, and a jump from a low level to a high level. The same type of level jump means that the two level jumps are in the same form, either a jump from a low level to a high level, or a jump from a high level to a low level. When the level jumps from a low level to a high level, it indicates that the state of the level is a rising edge. When the level jumps from a high level to a low level, it indicates that the state of the level is a falling edge. Then two consecutive level jumps of the same type can be two consecutive rising edges or two consecutive falling edges. The present invention is a software decoding method implemented based on a single product timer. It does not need to occupy the external interrupt pin of the single-chip microcomputer. Under the premise of ensuring the decoding accuracy, it can be completed by occupying only one timer resource. The user display unit CIU of the energy meter uses an infrared remote control as data input. Due to its limited single-chip microcomputer resources and the need to be compatible with remote control products of different batches, the decoding method of the present invention is used to successfully realize the infrared remote control decoding function, and it can be perfectly compatible with remote controls of each batch.
[0022] In the embodiment of the present application, in the hardware part, the infrared receiving circuit is set on the infrared remote controller, and the infrared remote controller is connected to the IO port of the single-chip computer through the receiving pin of the infrared receiving circuit; in the software part, the infrared receiving IO port is configured as an input function, the timer interrupt is configured as 140ms, and the timer interrupt is enabled. Figure 4 , Figure 4 This is the waveform of the signal sent by the infrared remote control. As can be seen from the figure, when the remote control transmits a bit "0", it sends a high level of 0.56ms and a low level of 0.56ms; when the remote control transmits a bit "1", it sends a high level of 0.56ms and a low level of 1.68ms. That is to say, each bit starts with a fixed time of high level, and the difference is the different holding time of the low level. It can also be understood that the different intervals between the two rising edges determine whether the current transmission is "0" or "1". If the interval between the two rising edges is 1.125ms, a bit "0" is transmitted, and if the interval between the two rising edges is 2.25ms, a bit "1" is transmitted. The first preset duration is 140ms. The timer interrupt is the interrupt of the timer.
[0023] In one possible implementation, step S3 specifically includes: S31: start recording the timing interrupt when the first level jumps to the rising edge of the first high level, stop recording the timing interrupt when the second level jumps to the rising edge of the second high level set continuously with the first high level, and obtain the recorded data; S32: Calculate and obtain the interruption times of the timing interruption between two rising edges according to the recorded data.
[0024] In one embodiment, determining whether the preset condition is met when comparing the number of interruptions with the set value in step S4 specifically includes: comparing the number of interruptions with the set value, if the number of interruptions is less than the set value, determining that the preset condition is met, if the number of interruptions is not less than the set value, determining that the preset condition is not met.
[0025] In one possible implementation, the set value is 12.
[0026] In an embodiment of the present application, when one type of infrared remote control transmits a bit "0", it sends a high level of 0.56ms and a low level of 0.56ms. When this type of infrared remote control transmits a bit "1", it sends a high level of 0.56ms and a low level of 1.68ms. The timing interrupt is recorded when a rising edge appears, but the timing interrupt is recorded only when a low level appears, and the timing interrupt is stopped at the next rising edge. When a bit "0" is transmitted, the timing interrupt is recorded only when it is within a low level of 0.56ms, and when a bit "1" is transmitted, the timing interrupt is recorded only when it is within a low level of 1.68ms. The first interruption number corresponding to the timing interruption will be recorded within the 0.56ms low level of transmitting a bit "0", and the second interruption number corresponding to the timing interruption will be recorded within the 1.68ms low level of transmitting a bit "1". The second interruption number can be 12, and the first interruption number can be less than 12; set the set value to 12. If the interruption number is less than 12, it is determined that the preset condition is met, that is, the timing interruption is recorded within the 0.56ms low level at this time, and a bit "0" is transmitted at this time; if the interruption number is equal to the set value, it is determined that the preset condition is not met, and the timing interruption is recorded within the 1.68ms low level at this time, and a bit "1" is transmitted at this time.
[0027] In the embodiment of the present application, the level of the infrared IO port is sampled in the 140ms timer interruption and recorded. When a jump from low level to high level occurs, it is judged that a rising edge is sampled. At this time, the number of timer interruptions is recorded until the next rising edge is judged. The number of interruptions between two rising edges is calculated. If the number of interruptions is less than the set value, which can be 12, i.e. 1.68ms, it is judged as bit "0", otherwise it is judged as bit "1".
[0028] In one possible implementation, step S5 further includes: S6: Stop sampling when the data transmission completion condition is met.
[0029] In an embodiment of the present application, when a data transmission completion instruction is received from an infrared remote control or a timeout counter determines that the duration of the level has timed out, it is determined that the data transmission completion condition is met, that is, until all the data is received or an abnormal timeout occurs, it is determined that the reception is completed.
[0030] In the embodiment of the present application, the start of the bit is determined by level jumps, whether to record the number of interruptions of the timing interrupt is determined based on the rising edge, and "0" and "1" are distinguished by the interval between the two rising edges, which can effectively eliminate the influence caused by the difference in the received waveform. By adopting the edge pressure judgment method to sample the waveform, the influence of the cumulative error on the waveform sampling is eliminated. The distinction between "0" and "1" is made by the interval between the two rising edges, and the fault tolerance space is larger. There is a larger judgment space between bit "0" (1.125ms) and bit "1" (2.25ms), and even if there is a large deviation in the duration, it can still be correctly identified.
[0031] In the embodiment of the present application, the present application adopts limited resource occupation, and only one timer and one general IO port are used in the present application; timer sampling is adopted, and level jump is used to realize edge judgment; data bit judgment (distinguishing between 0 and 1) is realized through edge interval.
[0032] The following will be combined with the attached Figure 2 , a timer-based infrared remote controller decoding device provided in an embodiment of the present application is introduced in detail. It should be noted that the attached Figure 2 The infrared remote controller decoding device based on a timer is used to execute the present application Figure 1 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 1 The embodiment shown.
[0033] See also Figure 2 , Figure 2 Schematic diagram of a timer-based infrared remote controller decoding device provided in an embodiment of the present application. Figure 2 As shown, the device comprises Configuration module 201, used to connect the infrared IO port of the infrared receiving circuit to the IO of the single-chip microcomputer, configure the infrared IO port as an input function, configure the timer interrupt to a first preset duration, and enable the timer interrupt; The sampling module 202 is used to sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; The number acquisition module 203 is used to acquire the number of interruptions of the timing interruption between two consecutive level jumps of the same type; The determination module 204 is used to determine whether a preset condition is met when comparing the number of interruptions with a set value, and if the preset condition is met, it is determined that the infrared remote controller transmits a bit "0" between two same type of level jumps; if the preset condition is not met, it is determined that the infrared remote controller transmits a bit "1" between two same type of level jumps; The storage module 205 is used to cache bit “0” or bit “1” data.
[0034] In the embodiment of the present application, the sampling module 202 is used to stop sampling when the data transmission completion condition is met.
[0035] In the embodiment of the present application, the sampling module 202 is used to stop sampling when receiving a data transmission completion instruction sent by the infrared remote controller or determining that a level duration is timed out. The sampling module is used to determine that the data transmission completion condition is met when receiving a data transmission completion instruction sent by the infrared remote controller or receiving a timeout counter determining that the level duration is timed out, that is, until all data is received or abnormally times out, it is determined that the reception is completed.
[0036] In one possible implementation, the number acquisition module 203 includes A recording unit, used for starting to record the timing interrupt when the first level jumps to the rising edge of the first high level, and stopping to record the timing interrupt when the second level jumps to the rising edge of the second high level set continuously with the first high level, so as to obtain the recorded data; The calculation unit is used to calculate the interruption times of the timing interruption located between two rising edges according to the recorded data.
[0037] In one possible implementation, the determination module 204 is used to compare the number of interruptions with a set value. If the number of interruptions is less than the set value, it is determined that the preset condition is met; if the number of interruptions is not less than the set value, it is determined that the preset condition is not met.
[0038] In the embodiment of the present application, the set value may be 12.
[0039] Those skilled in the art can clearly understand that the technical solutions of the embodiments of the present application can be implemented with the help of software and / or hardware. The "unit", "module" and "part" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA), an integrated circuit (IC), etc.
[0040] Each processing unit and / or module of the embodiments of the present application may be implemented by an analog circuit that implements the functions described in the embodiments of the present application, or may be implemented by software that executes the functions described in the embodiments of the present application.
[0041] See also Figure 3 , which shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, the electronic device can be used to implement Figure 1 The method in the embodiment shown. Figure 3 As shown, the electronic device 300 may include: at least one central processor 301 , at least one network interface 304 , a user interface 303 , a memory 305 , and at least one communication bus 302 .
[0042] The communication bus 302 is used to realize the connection and communication between these components.
[0043] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0044] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0045] Among them, the central processing unit 301 may include one or more processing cores. The central processing unit 301 uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the terminal 300 by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the central processing unit 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The central processing unit 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the central processing unit 301, but implemented separately through a chip.
[0046] Among them, the memory 305 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may optionally be at least one storage device located away from the aforementioned central processor 301. As Figure 3 As shown, the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.
[0047] exist Figure 3 In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and obtain the data input by the user; and the central processor 301 can be used to call an application program based on timer infrared remote controller decoding stored in the memory 305, and specifically perform the following operations: S1: Connect the infrared IO port of the infrared receiving circuit to the IO of the microcontroller, configure the infrared IO port as an input function, configure the timer interrupt to the first preset duration, and enable the timer interrupt; S2: Sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; S3: Obtain the interruption count of the timing interruption between two consecutive level jumps of the same type; S4: when comparing the number of interruptions with the set value, determining whether a preset condition is met, if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; S5: Cache bit "0" or bit "1" data, continue sampling the subsequent levels, and return to step S3.
[0048] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0049] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0050] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0051] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0052] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0053] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0054] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program codes.
[0055] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by entering a program to instruct related hardware. The program may be stored in a computer-readable memory, and the memory may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0056] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A timer-based infrared remote controller decoding method, characterized in that: The steps include: S1: Connect the infrared IO port of the infrared receiving circuit to the IO of the microcontroller, configure the infrared IO port as an input function, configure the timer interrupt to the first preset duration, and enable the timer interrupt; S2: Sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; S3: Obtain the interruption count of the timing interruption between two consecutive level jumps of the same type; S4: when comparing the number of interruptions with the set value, determining whether a preset condition is met, if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; S5: Cache bit "0" or bit "1" data, continue sampling the subsequent levels, and return to step S3.
2. A timer-based infrared remote controller decoding method as claimed in claim 1, characterized in that: Step S3 specifically includes: S31: start recording the timing interrupt when the first level jumps to the rising edge of the first high level, stop recording the timing interrupt when the second level jumps to the rising edge of the second high level set continuously with the first high level, and obtain the recorded data; S32: Calculate and obtain the interruption times of the timing interruption between two rising edges according to the recorded data.
3. A timer-based infrared remote controller decoding method as claimed in claim 1 or 2, characterized in that: In step S4, when comparing the number of interruptions with the set value, determining whether the preset condition is met specifically includes: comparing the number of interruptions with the set value, if the number of interruptions is less than the set value, determining that the preset condition is met, if the number of interruptions is not less than the set value, determining that the preset condition is not met.
4. The timer-based infrared remote controller decoding method according to claim 1 or 2, characterized in that: After step S5, the following steps are also included: S6: Stop sampling when the data transmission completion condition is met.
5. The timer-based infrared remote controller decoding method according to claim 1 or 2, characterized in that: The set value is 12.
6. A timer-based infrared remote controller decoding device, characterized in that: include A configuration module is used to connect the infrared IO port of the infrared receiving circuit to the IO of the single-chip microcomputer, configure the infrared IO port as an input function, configure the timer interrupt to a first preset duration, and enable the timer interrupt; The sampling module is used to sample the level of the infrared IO port of the timer when the infrared remote controller transmits data to the timer; A times acquisition module is used to acquire the interrupt times of the timing interrupt between two consecutive level jumps of the same type; A determination module, used for determining whether a preset condition is met when comparing the number of interruptions with a set value, and if the preset condition is met, determining that the infrared remote controller transmits a bit "0" between two same type of level jumps, and if the preset condition is not met, determining that the infrared remote controller transmits a bit "1" between two same type of level jumps; Storage module, used to cache bit "0" or bit "1" data.
7. The timer-based infrared remote controller decoding device as claimed in claim 6, characterized in that: The number acquisition module includes A recording unit, used for starting to record the timing interrupt when the first level jumps to the rising edge of the first high level, and stopping to record the timing interrupt when the second level jumps to the rising edge of the second high level set continuously with the first high level, so as to obtain the recorded data; The calculation unit is used to calculate the interruption times of the timing interruption located between two rising edges according to the recorded data.
8. The timer-based infrared remote controller decoding device according to claim 6 or 7, characterized in that: The determination module is used to compare the number of interruptions with a set value. If the number of interruptions is less than the set value, it is determined that the preset condition is met; if the number of interruptions is not less than the set value, it is determined that the preset condition is not met.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. 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 5 are implemented.
Citation Information
Patent Citations
Ultrahigh frequency RFID reader baseband signal decoding method
CN101038620A
Infrared signal decoding treatment method and infrared signal decoding treatment device
CN103680113A
Method, system and device for achieving infrared protocol through IO simulation and storage medium
CN112000600A
Receiving and processing method of infrared remote control key
CN117292531A