DIY Infrared Control Device: Simple Principles for Appliance Control

Infrared is a type of electromagnetic wave with a wavelength longer than red light. Since it exceeds the range visible to the human eye, it cannot be seen by humans; however, sensors can detect it, with wavelengths generally between 760nm and 400nm. We can utilize this to create an infrared controller.

Infrared remote controls are quite common in our daily lives, found in devices such as televisions, air conditioners, DVD players, and even smartphones. It is said that the national brand Huawei P10 also features an infrared module, and due to low production costs, its application is widespread.

First, let’s take a look at the schematic to understand how infrared control works.

DIY Infrared Control Device: Simple Principles for Appliance Control

The left image shows the infrared receiver. From the schematic, we can see that two pins of the infrared receiver are connected to the power supply, and the last pin is connected to a resistor in series with the microcontroller’s P3.2. This is not difficult to understand.

DIY Infrared Control Device: Simple Principles for Appliance Control

The infrared transmitter is slightly more complex. One end of the infrared transmitter is directly connected to VCC, while the other end connects to a PNP transistor. The B pin of the transistor is connected to a resistor leading to the microcontroller’s P1.5 port. There is no confusion about this connection; it is designed for better control. Of course, there are other connection methods, but we can say that the hardware part is relatively simple.

DIY Infrared Control Device: Simple Principles for Appliance Control

Next, let’s understand the microcontroller control protocol. If you’re doing DIY, the most common protocol you’ll encounter is the NEC protocol. There are many types of protocols, and some may wonder why this one is used. I can only tell you that it is standard. If you have the capability, you can define your own protocol. But for now, let’s understand the NEC protocol specifications.

Protocol Specifications

1. The low bit is sent first. A series of information starts with a 9ms AGC (Automatic Gain Control) high pulse, followed by a 4.5ms low level. Then, four bytes of address code and command code are sent, which are: address code; address code inverse; command code; command code inverse. If you keep pressing that button, the information can only be sent once. If you hold it down, the signal is sent as a repeating code with a period of 110ms. A notable feature of this protocol is that the received signal is the inverse of the sent signal.

DIY Infrared Control Device: Simple Principles for Appliance Control

2. The format of the repeat code consists of a 9ms AGC high level, a 4.5ms low level, and a 560us high level.

DIY Infrared Control Device: Simple Principles for Appliance Control

3. A logical 1 is represented by a pulse consisting of a 560us high level and a 1.69ms low level.

DIY Infrared Control Device: Simple Principles for Appliance Control

4. A logical 0 is represented by a pulse consisting of a 560us high level and a 565us low level.

DIY Infrared Control Device: Simple Principles for Appliance Control

After understanding the protocol, we can write the program. The program is written step by step according to the protocol specifications. First, the microcontroller checks for a falling edge, then enters the external interrupt 0 function. After a delay, it checks whether the IO port is still low. If it is, it waits for the 9ms low level to pass, then waits for the 4.5ms high level to pass, and then receives the four sets of data sent (first waiting for the 560us low level to pass, then checking the high level time. If it exceeds 1.12ms, it is considered a high level). Finally, it compares the received data with the inverse data to see if they are equal.

The above is the content to be controlled by the program. Once you learn the infrared control part, you will realize that controlling appliances is that simple.

DIY Infrared Control Device: Simple Principles for Appliance Control

END
Evaluation Center Free Application

DIY Infrared Control Device: Simple Principles for Appliance Control

DIY Infrared Control Device: Simple Principles for Appliance Control

👆Long press the image, scan the code to apply👆

Leave a Comment