Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

AT89C2051 controller based infrared receiver circuit

Published on Oct 26 2010 // Micrcontroller circuits

AT89C2051 controller based infrared receiver

The production of infrared receiver controller

In life, we often use the infrared control various appliances, such as color televisions, air conditioners, electric fans and so on. Bring us more convenience. But sometimes we are inconvenienced. Such as watching TV, you use the remote control can turn off the TV main power supply, television is still in standby mode. Users have gone to the TV. Press the power of small As the power switch can only be assured. If you want to watch TV. Have to leave the TV, looked very troublesome. Especially in the winter watching TV in bed, up and down, deeply inconvenience. In this paper, infrared remote control to remote control the production method of the fan case (can choose an infrared remote control. To speed, the slightest change in the software can increase Timing, etc.), to introduce the method of making infrared receiver controller, AC power if the production of television and off the controller, can be shared with a television remote control, production is also relatively simple.

Production Ideas

Infrared remote control transmitter is to use infrared to transfer information for the carrier, and launch cycle modulated by varying the serial code. The serial code is usually the boot code, user identification code, operation code composition. The infrared receiving decoded by a string of rectangular wave ranging cycle. Such as the diagram 1.

Different types of remote control transmitter waveform width different. Ie, the period T1, T2 … … different. I do not know remote control transmitter in hand the case of the waveform cycle. Make a first cycle of infrared detection tools. According to the measured period to produce the infrared receiver control laws.

Production Method

Infrared detection device fabrication cycle. Figure 2. When the infrared receiver is not sent to receive the infrared transmitter. The output of the output high (about 5V). When receiving the infrared, the output level low. AT89C2051 microcontroller to the external interrupt 1 is INT1, to enter the interrupt service interruption occurred: Start Timer 1 and MI-opening number. Equivalent to point A in Figure 1. C points after one period. The second microcontroller interrupt. Off Timer 1. Down cycle T1 (actually only a note of the value TH1. TL1 value can be discarded.) Then clear TH1, TL1, and then re-start the timer 1 count after the second cycle, the same interruption will cause microcontroller. Then write Next cycle T2 ‘… First, this note of 40-50 cycles (typically infrared codes is 4 bytes. The 32BIT. Preceded by the boot code. Because of the received infrared data is not necessarily start from the boot code, to analyze A complete serial code, should be down as much as IR square wave cycles). After receiving, by pressing the touch switch to the write down of the cycle THl out in the digital display for analysis (each time the touch switch to display the next number of cycles).


In the main () in the opening break. Start timer 1. That EA = I; EX1 = 1: IT1 = 1; TRI = I:

External interrupt 1 service routine to write the following words were: # defineCNT50 / / predicted 50 IR cycle DATA Byte value_h [CNT]: / / recording cycle variables (arrays) DATA Byte count = 0; / / receive cycle the number of void int1 (void) interrupt 2 {
if (TH1 == TL1TL1 == 0) / / is the first time to determine whether the received infrared data
TR1 = 1:
} ElseI
TRl = 0; value_h [count]: THl;
THl = TLl = 0; TRI = I: count;
if (count == CNT)
EXl = 0: count = u;
l} l

Assuming the value received for the TH: 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,08,08,3 f, 50. . . .
A little analysis shows. That the effective number of high-low: 04,08. If 04-made low. 08-made high. Discard the other data, the 4 bytes of data that is: 01110000. 01110000,10010000. 01,101,111. Hex conversion after that: 70h, 70h, 90h, 6fh, thus get the remote control transmitter codes just press the key. Use the same method can be measured by other key key code. Consider: 70h, 70h, 0x90, 0x6f.

/ / 0 key 70h, 70h. 0x00, 0xff. / / 1 key 70h, 70h. 0xd0, 0x2f / / power button
Data analysis was based on the above. Each key code is 4 bytes. The first 2 bytes fixed, for the user ID. After the 2 bytes are different, the operating code. Will be the keys on the remote control key code detected, the basis of these data can create the need for programming. 4-byte key code for too long. Is not conducive to programming, you need to key into the key that corresponds to 1 byte of data, such as: 70h, 70h, 0x90, 0x6f, corresponding to O, 70h, 70h, 0x00, 0xff corresponds to 1. . … *

Conversion method:

Create array of all the above measured key code sequence into an array (remove the user ID)
code Byte arr [] [2] =
0x90, 0x6f. / / 0, as key 0, key 1. . * … Placed the order to conform to customary
0x00, 0xff, / / 1
… …
Oxl0, 0xef. / / 9
0xd0, Ox2f / / power 13

In the infrared receiver in the external interrupt a function to write the following code conversion key statement:

DATA Byte arrtmp [4];
DATA Byte Keytmp; / / converted key storage variables
DATA Byte Keyval = NOKEY;
bit KeyOk; / / key sign of conversion is completed or not
bit d_Ok; / / receive a full key code signs
void Ex_int (void) interrupt 2
Byte i;
Byte (* p) [2];
… …
if (d_Ok) / / If the key code received to complete
d_Ok = 0: / / Clear
if (arrtmp [0] == 0x70arrtmp [1]
== 0x70) {/ / key code conversion
for (p = arr, bO: i14: i. p)
{If (arrtmp [2 ]==*(* p 0) & arrtmp [3]
==*(* P 1))
{Keytmp = i: KeyOk = 1; / / key
Converted successfully logo
} Else {Keytmp = NOKEY; l / / is not
Received a complete key
} EIse {Keytmp = NOKEY;}
} L
After converted Keytmp as 0,1,2 … … integer. And then write the main function, speed function (see source). For fan speed control.

Some explanations on the circuit: Microcontroller U1 (AT89C2051) P37 pin low through R13 control the output of high silicon optocoupler MOC3041 off. Off time by controlling the fan speed control than to achieve.