Home >
Microcontroller >Microcontroller Production > Production of infrared receiving controller based on AT89C2051
Production of infrared receiving controller based on AT89C2051
Source: InternetPublisher:拿铁三分糖 Updated: 2013/09/20
Production of Infrared Receiver Controller In our daily life, we often use infrared to control various electrical appliances, such as color TVs, air conditioners, electric fans, etc. It brings us more convenience. But sometimes we still feel inconvenienced. For example, after watching TV, you can only turn off the main power of the TV with the remote control, while the TV is still in standby mode. The user still has to walk to the TV. Just press the power switch of the small TV to feel at ease. If you want to watch TV. I still have to move to turn on the TV, which seems very troublesome. Especially in winter, it is deeply inconvenient to lie in bed and watch TV, going up and down. This article takes the production method of using an infrared remote control to remotely control a fan as an example (you can choose an infrared remote control. It can adjust the speed, and the software can be slightly changed to add a timing function, etc.) to introduce the production method of the infrared receiving controller. If you make a TV AC power on and off controller, you can share a remote control with the TV, and the production is simpler. Production idea: Infrared remote control transmitter uses infrared rays as a carrier to transmit information, and transmits modulated serial codes with different periods. The serial code generally consists of a boot code, a user identification code, and an operation code. After decoding by the infrared receiver, a series of rectangular waves with different periods are obtained. As shown in diagram 1. Different models of remote control transmitters have different waveform widths. That is, the periods T1, T2... are different. Without knowing the waveform period of the remote control transmitter at hand. First, make a tool to detect infrared cycles. Make an infrared receiving controller based on the measured periodic rules. Manufacturing method: Manufacturing of a device for detecting infrared cycles. See Figure 2. When the infrared receiving head does not receive the infrared ray sent by the transmitter. Its output terminal outputs high level (about +5V). When infrared is received, the output level becomes low. Send the external interrupt 1 port of the microcontroller AT89C2051, namely INT1, to cause an interrupt and enter the interrupt service: start timer 1 and open MI-number. It is equivalent to point A in Figure 1. One cycle later is point C. The microcontroller interrupts for the second time. Turn off the timer 1. Write down the period T1 (actually only the value of TH1 is recorded. The value of TL1 can be discarded). Then clear TH1 and TL1, and then start timer 1 to count again. After the second cycle, it will also cause an interrupt to the microcontroller. Then write down the cycle T2"...one, write down 40-50 cycles like this (generally infrared encoding is 4 bytes. That is 32BIT. There is a pilot code before it. And because the infrared data received does not necessarily start from the pilot code, To analyze a complete serial code, you should write down as many infrared rectangular wave cycles as possible). After receiving, press the touch switch to display the recorded THl of each cycle on the digital tube for analysis (each time). Press the touch switch once to display the next cycle number). The programming method is to enable the interrupt 1. That is, EA=I; EX1=1: IT1=1; TRI=I: In the external interrupt 1. Write the following language name in the service program: #defineCNT50 // Predict 50 infrared cycles DATA Byte value_h: // Variable (array) for recording cycles DATA Byte count = 0; // Number of cycles received void int1 (void) interrupt 2 { if(TH1==TL1%26;amp;%26;amp;TL1==0) // Determine whether it is the first time to receive infrared data { TR1=1: }elseI TRl=0; value_h: THl; THl =TLl=0; TRI=I:count++; if(count==CNT) { EXl=0:count=u; l} l Assume that the value of TH received is: 30,50.04,08,08,08 , 04,04,04,04, 04, 08,08,08, 04,04,04,04. 08,04,04,08, 04,04,04,04,04, 04,08,08,04 .08,08,3f,50..A little analysis shows that the effective number of high and low levels is: 04 is set as high level. Discard other data and get 4 bytes of data: 01110000. 01110000, 10010000. 01101111. After converting to hexadecimal, we get: 70h, 70h, 90h, 6fh. At this point, we get the key value code of the remote control transmitter just pressed. Use. The same method can be used to measure other key value codes. Assume: 70h, 70h, 0x6f. // 0x00, 0xff. 0xd0, 0x2f. According to the above data analysis, each key code is 4 bytes, the first 2 bytes are fixed, and the last 2 bytes are different, which is the operation code of each key on the remote control. Finally, programming can be performed based on these data. Because the key value code is 4 bytes, which is not conducive to programming, each key value needs to be converted into the corresponding 1-byte data, such as: 70h, 70h. ,0x90,0x6f,corresponds to O,70h,70h,0x00,0xff corresponds to 1. . ...· Conversion method: Create an array, and put the key codes measured above into the array in order (remove the user identification code) code Byte arr[]= { 0x90,0x6f. //0, press key 0 and key 1 as much as possible. . ·... are placed in order to conform to the customary 0x00, 0xff, // 1... Oxl0, 0xef. //9
Latest Microcontroller Circuits
- Application circuit of CSJ-R05B and single chip microcomputer
- Use microcontroller to make simple timing controller for electric fan
- p4 478 chip pin distribution diagram
- Use PC’s RS232 port to control LED lights
- 815ept motherboard
- Use printer port to make programmable frequency generator circuit
- Circuit diagram: 8515 extended RAM
- 3 IO scan 16 buttons
- Interface circuit between digital measuring tool and 51 microcontroller
- Microcontroller test board circuit 5