DIY Infrared Control Device: Simple Principles for Controlling Appliances

Infrared is a type of electromagnetic wave with a wavelength longer than that of red light. Since it exceeds the range observable by the human eye, it is invisible to us. However, sensors can detect it, with wavelengths typically ranging from 760nm to 400nm. We can take advantage of this to create an infrared controller.

Infrared remote controls are quite common in our daily lives, found in devices like televisions, air conditioners, DVD players, and even smartphones. It is said that the national brand Huawei P10 also features an infrared module. Due to the low production cost, this technology is widely used.

Let’s first take a look at the schematic diagram to understand how infrared control works.

DIY Infrared Control Device: Simple Principles for Controlling Appliances

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, while the last pin is connected in series with a resistor to the microcontroller P3.2. This is not difficult to understand.

DIY Infrared Control Device: Simple Principles for Controlling Appliances

The infrared transmitter is slightly more complex. One end of the infrared transmitter is directly connected to VCC, while the other end is connected to a PNP transistor. The base of the transistor is connected in series with a resistor to the microcontroller P1.5. There is no confusion here; this connection allows for better control. Of course, there are other connection methods, but the hardware part is relatively simple.

DIY Infrared Control Device: Simple Principles for Controlling Appliances

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

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 starting low level. Next, four bytes of address code and command code are sent. These four bytes 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, it sends a repeated code with a cycle of 110ms. A notable feature of this protocol is that the received signal is the exact inverse of the sent signal.

DIY Infrared Control Device: Simple Principles for Controlling Appliances

2. The format of the repeated 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 Controlling Appliances

3. Logic 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 Controlling Appliances

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

DIY Infrared Control Device: Simple Principles for Controlling Appliances

After understanding the protocol, we can write the program. The program is written step by step according to the specifications of the protocol. First, the microcontroller checks whether a falling edge is produced, then enters the interrupt function of external interrupt 0. 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. Next, it receives the four sets of data sent (first waiting for the 560us low level to pass, then checking the high level duration; if it exceeds 1.12ms, it is high level), and finally compares the received data with the inverse data to see if they match.

This is the content that the program is supposed to control. Once you learn the infrared control part, you will know that controlling appliances is that simple.

DIY Infrared Control Device: Simple Principles for Controlling Appliances

END
Evaluation Center Free Application

DIY Infrared Control Device: Simple Principles for Controlling Appliances

DIY Infrared Control Device: Simple Principles for Controlling Appliances

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

Leave a Comment