Several problems about infrared remote controller
By analyzing the pulse waveforms emitted by the buttons of the infrared remote controller, the types can be identified, thus providing a basis for software decoding. This paper introduces the hardware interface between infrared remote controller and single chip microcomputer with examples, and gives the method of software decoding in principle. This is a successful example that can be directly cited, and also provides a very practical reference for the development and application of various infrared remote controllers in single chip microcomputer control products. Keywords: remote control software decoding In the development and application of single-chip microcomputer control products, in order to send control commands to the control system software, the keyboard is often essential. The traditional method is to extend a keyboard interface with a parallel I/O interface chip, or directly extend it with the parallel port of a single chip microcomputer. In some application environments, this method has two shortcomings: ① the keyboard is connected with the control system, which is inflexible and has poor environmental adaptability; (2) waste the port of single chip microcomputer, and the hardware cost is high. Using infrared remote controller as the input device of the control system has the characteristics of low cost, flexibility and convenience. This paper aims to introduce the general method of software decoding research and the application technology of secondary development of infrared remote controller. This method has been successfully implemented in several application system designs, and the effect is good. Infrared remote controller is a kind of product that is very easy to buy and cheap. There are many kinds, but all of them are matched with a certain electronic product (such as various televisions, VCDs, air conditioners, etc.). ), decoded by special CPU, can be directly used as a general single chip microcomputer control system. Using the ready-made remote controller as the input of the control system needs to solve the following problems: how to receive infrared remote control signals; How to identify infrared remote control signals; Design of decoding software. Other problems are non-essential, such as the labeling of function keys on the remote control panel, and you can design and reprint them yourself. 1 The receiving circuit of infrared remote control signal can use integrated infrared receiver. The receiver includes an infrared receiving tube and a signal processing integrated circuit. The receiver has only three external pins: Vcc, GND and 1 pulse signal output PO. It is very convenient to interface with single chip microcomputer, as shown in figure 1. ①Vcc is connected to the positive pole of the system power supply (+5v); ②GND is connected to the system ground (0V); ③ The pulse signal output is connected to the interrupt input pin of the CPU (for example, the 13 pin INT 1 of 803 1). Using this connection method, the software solution can work in query mode and interrupt mode. 2 Pulse stream analysis To understand an unknown remote controller, we must first analyze its pulse stream, so as to understand its pulse waveform characteristics (how to carry "0" and "1" information), and then understand its coding law. The analysis of pulse flow should start with the analysis of the high and low level widths of pulses. The author realizes the analysis of pulse flow with software. Take the interface shown in figure 1 as an example. If no infrared remote control signal comes, the output POrt po of the receiver remains high. When the infrared remote control signal is received, the signal of the receiving device is converted into a pulse sequence and applied to the interrupt input pin of the CPU. Test the logic level of the pin with software, and start the TC timer at the same time, measure the time values when the pin is logic "0" and logic "1" respectively, store them, and then print and analyze them. 805 1 assembly language gives the following program segments for collecting and storing pulse streams: MOV R0, #00HMOV R 1, #28HMOV TMOD, #0 1HTK:JB P3.3, tk; Waiting for the arrival of the lower level; Measure the low-level width TK 1:MOV TH0, #00HMOV TL0, # 00HSETB TR0TK0: JBTF0, the if the timeout is invalid, return jnb3.3, TK2CLR TR0MOV A, TH0MOVX @R0, AINC R0MOV A, TL0MOVX @R0, Aincr0 measures the horizontal width of MOV TH0, #00HMOV TL0, # 00hsetbtr0tk3: jbtf0, tke. If the timeout is invalid, it will return JB P3.3, TK3CLR TR0MOV A, TH0MOVX @R0, AINC R0MOV A, TL0MOVX @R0, Aincr0DNZ R 1, TK/. Loop TKE:RET This program first sets TC0 to 16-bit timer mode, initializes ram address pointer R0 and loop count pointer R 1, stops timing whenever the logic level of the pin jumps, and saves the timing value in continuous RAM. This program can continuously measure the time value of 40 pulses (including 40 low-level pulse widths). Taking the remote controller of TC90 12 chip as the object, the programming pulse waveforms of all keys are collected, and the same key is repeated. Limited by space, we can't give the sampling data, but only the pulse flow law (the crystal oscillator of the simulator CPU is 6 MHz): ① the pilot pulse is low level, the time value is 0937 h ~ 0957 h, and the high level, the time value is 084fh ~ 086fh; ② the low level time value of the data pulse is about 0.127h ~ 0177h. ③ There are two advanced time values: 00 bbh ~ 00 ffh (narrow) and 02EFH~0333H (wide). Based on the analysis of a large number of data, the key coding rules are as follows: ① The pulses except the pilot pulse are data coding pulses, and the data bit information is determined by the high-level pulse width: the narrow pulse width means "0" and the wide pulse width means "1"; ② After the pulse stream of each key is decoded, it contains four bytes of information: * The first two bytes of all keys have the same code, which is two bytes of "0eh"; * The third byte is the key code; * The fourth byte is the complement of the key code. After sampling the same key pulse for many times, it is found that the pulse width time value of the corresponding position of the same key pulse sequence fluctuates in a small range (not a certain value), so the accurate comparison method cannot be used for pattern recognition. In this regard, I take a fuzzy approach to abstract processing. According to the above experimental rules, the analysis and judgment basis and algorithm design ideas of pulse in software decoding are summarized: ① the judgment basis of low level and high level width of pilot pulse is "the high byte is greater than 08H" of time value, and the low byte is ignored; ② The low-level pulse width of the data pulse stream is the same, which is ignored and will not be judged; ③ The high-level pulse width is the basis for judging whether each bit of the data stream is "0" or "1". My judgment is that if the high byte of the pulse width is less than 2, it means "0", otherwise it means "1", and the low byte of the pulse width is ignored. Practice has proved that the above standards are effective and feasible. This processing not only simplifies the design of decoding software, but also greatly improves the decoding speed. When writing a software decoding program using the above criteria, we should pay attention to the corresponding relationship between the storage address of pulse stream sampling data and pulses. The software mainly includes the following parts: ① judging the arrival of remote control signal (calling 1 independent subroutine before decoding); ② Sampling and storage of pulse stream; (3) judging whether the pilot pulse is effective; (4) decode the first 2 bytes to determine whether it is "0eh"; (5) decoding the third byte, which is an effective key code; ⑥ Lookup table mapping of key code (if the original key code is used, this step can be omitted). 3 Design of Decoding Software The software decoding system based on the above ideas has been successfully applied in many control systems. The following is an example of assembly language program (software decoding with MCS-5 1 series MC traffic rules TC90 12 infrared remote controller). The parameters used in the program are aimed at the situation that the single chip microcomputer uses 6MHz crystal oscillator, and only the pulse width criterion needs to be modified when using crystal oscillators with other frequencies. In order to make it easier to understand and make the principle statement as true as possible, a more detailed annotation translation is given in the program. For details, please refer to the network supplement (). Although this paper is a research on decoding the software of TC90 12 infrared remote controller with MCS-5 1 series single chip microcomputer, its method is universal. The specific application can be mastered flexibly.