Understand how the 51 system MCU decodes the infrared remote control?

The remote control is easy to use and has many functions. At present, it has been widely used in various household appliances such as TVs, VCDs, DVDs, air conditioners, etc., and the price is cheap, and it is very easy to buy in the market. If you can decode many buttons on the remote control. Used as the input of the SCM system. It solves the shortcomings of the conventional matrix keyboard circuit board is too large, the wiring is complicated, and the I/O port is occupied too much. Moreover, by using the remote control, the separation of people and equipment can be realized during operation, which is more convenient to use. Take the remote controller with TC9012 encoding chip as an example. Talk about how to use the commonly used 51 system single-chip microcomputer to decode the remote control.

The general infrared remote control system is composed of two parts: transmitting and receiving, and it uses encoding/decoding special integrated circuit chip to control operation, as shown in the figure. The transmitting part includes a keyboard matrix, code modulation, and LED infrared transmitter; the receiving part includes optical and electrical conversion amplifiers, demodulation, and decoding circuits.

Understand how the 51 system MCU decodes the infrared remote control?

1. Encoding format

1, 0 and 1 encoding

When the transmitter button is pressed, a remote control code is sent out, and the remote control code is different for different keys. This kind of remote control code has the following characteristics: a serial code using pulse width modulation, a combination of pulse width of 0.565ms, interval of 0.56ms, and period of 1.125ms represents binary "0"; with pulse width of 0.565ms and interval of 1.685 The combination of ms and period of 2.25ms represents a binary "1", and its waveform is shown in the figure.

Understand how the 51 system MCU decodes the infrared remote control?

The signal transmitted by the remote control consists of a string of 0 and 1 binary codes. Different chips have different codes for 0 and 1. Usually there are Manchester encoding and pulse width encoding. The 0 and 1 of TC9012 are coded by the PWM method, that is, pulse width modulation. The 0 and 1 codes are shown in the figure (take the waveform of the remote control receiving output as an example). The 0 code is composed of 0.56ms low level and 0.56ms high level, and the pulse width is 1.12ms. The 1 code is a combination of 0.56ms low level and 1.69ms high level, and the pulse width is 2.25ms. When writing a decoding program. By judging the width of the pulse, 0 or 1 can be obtained.

Understand how the 51 system MCU decodes the infrared remote control?

The remote control code generated by UPD6121G is a continuous 32-bit binary code group, of which the first 16 bits are user identification codes, which can distinguish different electrical equipment and prevent the remote control codes of different models from interfering with each other. For example, we can use TV sets, set-top boxes, and power amplifiers at the same time. Wait for the remote control, but they will not generate false triggers. The user identification code of this chip is fixed as hexadecimal 01H; the last 16 bits are 8-bit operation code (function code) and its inverse code. UPD6121G has a maximum of 128 different combinations of codes. After the button is pressed, the remote control sends out the same 32-bit binary code periodically with a period of about 108ms. The duration of a set of code itself varies with the number of binary "0"s and "1"s it contains, and is approximately between 45 and 63 ms.

2. The coding of the keys

When we press the button of the remote control, the remote control will send out a series of binary codes as shown in Figure 2. We call it a frame of data. According to the function of each part. They can be divided into 5 parts, namely guide code, user identification code, user identification code inverse code, data code, data inverse code. When the remote control transmits codes. All are low in the front and high in the back. It can be obtained from the analysis in Figure 3. The high level of the pilot code is 4.5ms, and the low level is 4.5ms. When this code is received, it indicates the beginning of a frame of data. The microcontroller can prepare to receive the following data. The user identification code is composed of 8 bits of binary system, 256 kinds in total. The address code in the picture is retransmitted once, mainly to strengthen the reliability of the remote control. If the two address codes are not the same, it means that the data in this frame is wrong and should be discarded. Different devices can have different user identification codes. therefore. The remote controllers of the same code will not interfere with each other as long as the address codes are different. The address code in the figure is 0EH in hexadecimal (note that the low bit is first). In the same remote control, the address codes sent by all the buttons are the same, the data code is 8 bits, and 256 states can be encoded, representing the actual key pressed. The data inversion is the inversion of each bit of the data code. By comparing the data code and the data inversion, it can be judged whether the received data is correct. If the relationship between the data code and the data inverse code does not satisfy the opposite relationship. If there is an error in the remote control reception this time, the data should be discarded. On the same remote control. The data codes of all keys are different. In Figure 3, the data code is 0CH in hexadecimal, and the inverse of the data is 0F3H in hexadecimal (note that the low bit is first), and the sum of the two should be 0FFH.

Second, the single-chip remote control receiving circuit

Infrared remote control reception can adopt the method of earlier infrared receiving diode and special infrared processing circuit. Such as CXA20106, the circuit of this method is complicated, and it is generally not used now. A better receiving method is to use an integrated infrared receiving head, which combines infrared receiving diodes, amplification, demodulation, and shaping circuits, with only three pins. They are +5V power supply, ground, and signal output. For the appearance and pins of the commonly used integrated receiving head, see the signal output of the infrared receiving head connected to the INTO or INTL pin of the single-chip microcomputer. The typical circuit is shown as in Fig. 5. In the figure, a PNP-type triode is added to amplify the output signal.

Understand how the 51 system MCU decodes the infrared remote control?

3. Decoding algorithm and programming of remote control signal

Usually, the remote control has no keys pressed. The infrared emitting diode does not send out a signal, and the remote control receiving head outputs signal 1. When a key is pressed, the high level of 0 and 1 code will output signal 0 after being inverted by the remote control head. Because it is connected with the interrupt pin of the single-chip microcomputer, it will cause the single-chip interrupt (the single-chip microcomputer is preset to generate an interrupt on the falling edge). The one-chip computer uses Timer 0 or Timer 1 to start timing when it is interrupted. When the next pulse arrives, that is, when an interrupt occurs again, the timing value is first taken out. Start timing after clearing the timing value. By judging the time interval between each interruption and the last interruption. It can be known whether the received pilot code or 0 and 1. If the timing value is 9ms. The received is the pilot code, if the timing value is equal to 1.12ms, the received code is 0. If the timing value is equal to 2.25ms. The received code is 1. When judging the time, a certain error value should be considered. Because of different remote controllers due to crystal parameters and other reasons, there will be small errors in the time of transmission and reception.

That is what we usually call decoding. The microcontroller knows what signal is sent, and then makes the corresponding judgment and control. If we press the channel button of the TV remote control, the microcontroller will control the change of the TV channel. If it is the remote control volume key, the microcontroller will control the increase or decrease of the volume. The key to decoding is how to identify "0" and "1". From the definition of bits, we can find that "0" and "1" all start with a low level of 0.56ms. The difference is that the width of the high level is different. 0" is 0.56ms, and "1" is 1.68ms, so "0" and "1" must be distinguished according to the width of the high level. If the delay starts after 0.56ms low level, after 0.56ms, if the read level is low, it means that the bit is "0", otherwise it is "1". For the sake of reliability, the delay must be greater than 0.56 The ms is longer, but it cannot exceed 1.12ms. Otherwise, if the bit is "0", the high level of the next bit is read. Therefore, it is most reliable to take (1.12ms+0.56ms)/2=0.84ms. Generally, it can be about 0.84ms. According to the code format, you should wait for the start code of 9ms and the result code of 4.5ms to finish before reading the code.

Take receiving the TC9012 remote control code as an example, the decoding method is as follows:

(1) Set external interrupt 0 (or 1) as a falling edge interrupt, timer 0 (or 1) as a 16-bit timer, and the initial value is 0.

(2) After entering the remote control interrupt for the first time, start timing.

(3) After entering the remote control interrupt for the second time, stop the timing first, save the timing value, and then restart the timing. If the timing value is equal to the time of the preamble, the preamble flag is set. Prepare to receive the next frame of remote control data. If the timing value is not equal to the time of the preamble, but the preamble has been received before, then it is judged whether it is 0 or 1 of the remote control data.

(4) Continue to receive the following address code, data code, and data inverse code.

(5) When 32-bit data is received, it indicates that one frame of data has been received. At this time, the timer can be stopped and judge whether the reception is valid. If the two address codes are the same and equal to the address of this system, and the sum of the data code and the inverse code of the data is equal to 0FFH, the received data code of this frame is valid. Otherwise, discard the data received this time.

(6) After receiving, initialize the data received this time and prepare for the next remote control reception.

Regular Back Sticker

The texture of Regular Back Sticker attracts you in a unique and innovative way. The ultra-thin and breathable material does not affect the heat dissipation function of the device at all. The smooth feel and personalized patterns not only protect the phone from scratches, dust, impacts and fingerprints. Bring you a different experience.

The Back Film protects the back cover of the phone from unnecessary scratches and repels dust, while reducing the signs of daily wear and tear.

It has oleophobic and waterproof effects, which can prevent the adhesion of oil stains and fingerprints. Provide comprehensive protection and maintain a new state.

Using the Protective Film Cutting Machine, you can install the Back Film on different types of mobile phone back shells, including mobile phones, tablets and other electronic products. With just one click, the customization can be completed in 30 seconds.

If you want to know more about Regular Back Sticker products, please click the product details to view the parameters, models, pictures, prices and other information about Regular Back Sticker products.

Whether you are a group or an individual, we will try our best to provide you with accurate and comprehensive information about Regular Back Sticke!

Leather Back Sticker, Aurora Back Sticker, Back Skin Sticker, Brushed Metal Back Sticker, Mobile Phone Sticker, Back Sticker,Mobile Skin Sticker

Shenzhen Jianjiantong Technology Co., Ltd. , https://www.tpuscreenprotector.com