Share this

Design of a microcontroller-based remote control switch system

2026-04-06 05:59:51 · · #1

Abstract : This paper proposes a microcontroller-based remote control switch system. The system uses an AT89C2051 microcontroller as the control chip to create a remote control. The keypad employs a row-column layout, the remote control transmitter uses infrared pulse counting encoding, and another AT89C52 microcontroller controls the system to be remotely operated. Through microcontroller software decoding, the system achieves dimming of a light bulb and control of a relay.

1 Introduction

With the rapid development of electronic technology and the continuous emergence of new large-scale remote control integrated circuits, remote control technology has undergone tremendous changes. The central control component of remote control devices has gradually evolved from early discrete components and integrated circuits to today's single-chip microcomputers, greatly improving the level of intelligence. In recent years, remote control technology has been increasingly widely used in industrial production, household appliances, security, and people's daily lives.

This paper presents an intelligent remote control switch system designed based on a microcontroller. The system uses the AT89C2051 microcontroller as the control chip to create a remote control. The keyboard employs a matrix-based operation, and the key interrupt scanning method improves CPU efficiency. The remote control transmitter uses infrared pulse count encoding to determine which key is pressed based on the pulse count, and then transmits the corresponding signal to control the dimming of the light. When no key is pressed, it is in a low-power idle mode. Another microcontroller-controlled system can be remotely operated, using software decoding to achieve dimming of a light and control of a relay.

2. System Structure and Working Principle

Make an infrared remote control using a microcontroller that can control eight control relay switches and one light switch, and also adjust the brightness of the light.

The structure of the infrared emitting section is shown in Figure 2.1 below.

When the remote control button is pressed, the microcontroller generates a corresponding control pulse, which is emitted by the infrared LED.

The structure of the infrared receiver is shown in Figure 2.2 below:

Infrared remote control does not affect the surrounding environment or interfere with other electrical appliances. Because it cannot penetrate walls, household appliances in different rooms can use a common remote control without mutual interference; circuit debugging is simple, as long as the given circuit is connected correctly, it can generally be put into operation without any debugging; encoding and decoding are easy, making it suitable for multi-channel remote control.

3 Hardware Circuit Design

3.1 Remote Control Transmitter Circuit Design

The circuit mainly consists of an AT89C2051 microcontroller, a matrix operation keyboard, a low-power idle mode control circuit, an infrared emitting circuit power supply, and other components.

The main chip of the remote control circuit uses the AT89C2051 Flash microcontroller from Atmel Corporation. It is a low-voltage, high-performance CMOS 8-bit microcontroller with 2KB of rewritable Flash program memory and 128 bytes of random access memory (RAM); a power supply voltage of 2.7–6V; two 16-bit timers/counters; six interrupt sources; 15 I/O pins; a precision analog comparator; an on-chip oscillator and clock circuit; direct LED driver output; and idle and power-down modes. The remote control is powered by two 1.5V batteries connected in series to provide 3V power. In the remote control system design, the on-chip analog comparator interface is used only as a general I/O.

A matrix keypad, also known as a row-and-column keypad, uses I/O lines to form rows and columns. Keys are located at the intersections of rows and columns, and the row and column lines are connected to the two ends of a push-button switch. Whether a key is pressed is determined by scanning characters sent to the column lines and reading the row line status. To improve CPU efficiency and conserve battery power, the remote control uses a key interrupt scanning method. When no key is pressed, the microcontroller is in a low-power idle standby mode. When a key is pressed, an external interrupt is triggered to retrieve the key and execute the key function program.

The AT89C205l CPU has two power-saving modes: idle mode and power-down mode. The remote control uses the idle power-saving mode. After the CPU executes the instruction to set IDL=1 (PCON.0=1), the system enters the idle mode. In this mode, the internal clock does not supply power to the CPU, but only to the interrupt, serial port, and timer sections. The remote control's exit from low-power idle mode is implemented using an AND gate composed of IN4148 diodes. When a key is pressed, the AND gate triggers external interrupt 1, causing the microcontroller to exit the idle mode and enter the keyboard and infrared transmission program. After completion, it enters low-power idle standby mode. During use, the microcontroller is basically in idle mode, with very low power consumption, thus ensuring the use of battery power.

The infrared transmitter and indicator circuit utilizes the remote control information code, modulated by Timer 1 of the AT89C2051 microcontroller into a 38.5kHz infrared carrier signal. This signal is output from port P3.5, amplified by a 9013 transistor, and then transmitted by an infrared transmitter. The value of resistor R1 can change the transmission distance. An LED is used as the indicator light for the buttons. Timer 1 operates in mode 2, i.e., in automatic 8-bit reload mode. When used as a timer, it increments by 1 in each machine cycle, thus accumulating machine cycles. One machine cycle consists of 12 oscillation cycles, so the counting frequency is one-twelfth of the oscillation frequency. When M1M0 is 10, the timer/counter operates in mode 2. In this mode, an 8-bit counter is set up with an automatic initial value recovery function. Taking T1 as an example, TL1 is used as the counter, and TH1 is used as a register to store the initial count value. When TL1 increments by 1 until it overflows, in addition to setting the overflow flag TF1 to 1, the initial count value in TH1 is also loaded into TL1, causing TL1 to start counting again from the initial value. The initial count value in TH1 is loaded by software programming, and TH1 remains unchanged during the constant reloading process. In mode 2, T0 and T1 have exactly the same operation function and can be used freely.

3.2 Remote Control Receiver Circuit Design

The receiving control system mainly consists of an AT89C52 microcontroller, a power supply circuit, an infrared receiving circuit, a 50Hz AC zero-crossing detection circuit, a lamp dimming control circuit, and a control relay circuit.

The AT89C52 microcontroller has 40 pins, 32 external bidirectional input/output (I/O) ports, and includes 2 external interrupt ports, 3 16-bit timers/counters, 6 interrupt sources, low-power idle and power-down modes, 2 full-duplex serial communication ports, and 2 read/write lines. The AT89C52 can be programmed using conventional methods or via in-system programming. It combines a general-purpose microprocessor with Flash memory, and the rewritable Flash memory effectively reduces development costs. The control system uses a 5V power supply and an external 12MHz crystal oscillator.

The power supply circuit consists of a bridge rectifier, capacitor filter, 7805 voltage regulator, and a power indicator light. AC power is rectified into DC power by the bridge rectifier, then filtered by the capacitor, and finally regulated to a stable +5V power supply by the 7805 integrated voltage regulator. A single LED indicator light shows the power supply status.

The infrared remote control receiver is modular, typically with three pins, and outputs a detected and shaped square wave signal. The infrared receiver circuit is shown in Figure 3.1. An infrared filter at the receiver's front end removes visible light, allowing infrared light to pass through. An infrared photodiode is used to monitor the receiver, maximizing the light-receiving area. An electrical filter is added at the amplifier end to eliminate low-frequency and high-frequency interference. Data detection typically uses a peak monitor and a general-purpose signal comparator circuit, outputting a new level to the processor.

The AC zero-crossing detection circuit is shown in Figure 3.2. The circuit mainly consists of two NPN transistors. The base of Q1 is current-limited by a 200K resistor, and the other end of the resistor is the detected terminal. After full-bridge rectification, the current is a full-wave output, which can trigger twice within one cycle. The detected terminal is rectified by a transformer. This power supply mainly powers the AT89C52. The circuit design only uses electrolytic capacitors for filtering at the input and output terminals. To mitigate high-frequency noise, it is best to add a 104/50V tantalum capacitor to make the power supply cleaner and better prevent interference. A diode is connected in series after the bridge to prevent reverse power connection; this is typically found on the CPU circuit board.

The schematic diagram of the SCR lamp dimming control circuit is shown in Figure 3.3. Lamp dimming is controlled by the conduction angle of the SCR. The AT89C52 generates a phase-shifting pulse controlled by the SCR. Changing the phase shift angle changes the conduction angle; that is, when the phase shift angle is large, the conduction angle of the SCR is small, the voltage across the lamp is low, and the lamp is dim; when the phase shift angle is small, the conduction angle of the SCR is large, the voltage across the lamp is high, and the lamp is bright; when the conduction angle is not 0, the lamp is lit; when the conduction angle is 0, the lamp is off. When the P0.0 bit of the AT89C52 is low, the 9012 transistor is turned on, and the current of the transistor's electrodes drives the optocoupler to turn on, causing a pulse signal to be generated at the gate of the thyristor to trigger the thyristor to turn on. When the P0.0 bit of the AT89C52 is high, the 9012 transistor is turned off, and both the optocoupler and the thyristor are in the off state.

This design has eight control relay circuits, but only one control relay circuit is shown on the infrared receiver schematic. Figure 3.4 shows the schematic of the HK4100F relay driver circuit. The base (B) of transistor Q5 is connected to the P0.7 port of the AT89C52 microcontroller, and the emitter (E) of the transistor is connected to one end of the relay coil. The other end of the coil is connected to the +5V power supply VCC. A diode IN4148 is connected in parallel across the relay coil to absorb and release the reverse electromotive force generated when the relay coil is de-energized, preventing the reverse electromotive force from damaging transistor Q5 and interfering with other circuits. R14 and LED9 form a relay status indicator circuit. When the relay is energized, LED9 lights up, allowing for a direct visual indication of the relay status.

4.1 Programming of the Remote Transmitter

4.1.1 Initialization program and main program  

The initialization flowchart is shown in Figure 4.1. The initialization program mainly sets ports P1 and P3 to a high-level reset state, disables the remote control output of port P3.5, sets the stack pointer SP to #70H, disables the global interrupt source, sets the interrupt priority IP, selects Timer/Counter 1, and sets the operating mode to automatic 8-bit reload mode 2. Mode 2 is an 8-bit timer/counter with a crystal oscillator frequency of 12MHz, so the machine cycle is f/12 = 12/12 = 1μs. The counting function initializes the count value X = 28 - the count value (count value = T × f/12).

The main program flowchart is shown in Figure 4.2. The main program first calls the initialization program, then enters the main program loop. The loop primarily performs two tasks: calling the keyboard program and entering a low-power idle standby mode. After completing the keyboard query program, the system enters the idle node mode, which continues until an external interrupt 1 or hardware reset occurs, at which point the CPU returns to the loop.

The transmission program first loads the number of transmission pulses. When the first code interval (start code) is 3ms, high-frequency timer interrupt modulation is enabled (P3.7 port is set to high level). Then, a software trap is set to improve the microcontroller's reliability and prevent crashes. A loop instruction is then executed. When the first code interval of 3ms is completed (R0 is 0), the code interval is 1ms. If the subsequent pulse count is zero, the signal is inverted, high-frequency interrupt modulation is disabled (P3.7 is set to low frequency), and the system exits the transmission program. If there are still pulses remaining, the transmission loop continues. When P3.7 is inverted to low frequency, the indicator light is on; when high frequency, the indicator light is off. A 500ms delay is included in the program to ensure the accuracy of the remote control transmission. The transmission program flowchart is shown in Figure 4.3.

4.2 Programming of the Remote Control Receiver

The initialization flowchart is shown in Figure 4.4. The initialization program mainly puts the system into a reset and initialization state. Specifically: ports P1, P2, and P3 are set to high level, making them input ports. The working register area is selected, the stack pointer SP is set, the interrupt priority IP is set, external interrupt 0 and timer 1 are enabled, and global interrupt enable is enabled. A delay value with a zero conduction angle is set, and a flag indicating that the lights are off by default is set.

The main program first calls the initialization program, then enters the main program loop. The main task in the loop is zero-crossing detection of the 50Hz AC current. If a zero-crossing is detected, a delay subroutine is called to generate an on-conduction angle pulse, followed by a 256μs delay program. Then, the pulse is turned off, and the program returns to the zero-crossing detection state. Figure 4.5 shows the main program flowchart.

5 Performance Indicators

The system performance indicators after debugging are as follows:

1. Maximum remote control distance: 10m;

2. Maximum receiving angle: 90 degrees;

3. Remote control operating current during transmission: 8mA;

4. Remote control quiescent current: 0.6mA;

5. Maximum output voltage of the dimming control system (5 dimming levels): AC 200V;

6. Slowest output voltage of the dimming control system (dimming level 1): AC 50V;

7. Dimming control system stop output voltage: 0V;

8. The relay is working normally.

When using infrared remote control, the effectiveness is limited by factors such as distance and angle. However, if frequency modulation (FM) or frequency modulation (FM) transmitters and receivers are used, the transmission distance will be much greater, and the reception will be unaffected by angle. This microcontroller-based remote control encoding and decoding scheme is suitable for all electrical systems requiring remote control and is the ideal solution for designing self-controlled systems with remote control functionality.

6. Conclusion

With the increasingly widespread use of remote control technology, intelligent control has become a trend. This design proposes a microcontroller-based remote control switch system. Test results of the prototype show that this system, using a microcontroller for remote control system design, offers advantages such as flexible and diverse programming and the ability to arbitrarily set the number of operation codes. General equipment systems use dedicated remote control encoder and decoder integrated circuits. While this approach is simple and easy to manufacture, its application scope is limited due to specific limitations on the number of function keys and functions, restricting its suitability for specific electrical products. This system eliminates this problem, significantly improving its intelligence. Through debugging and operation of the prototype, excellent energy-saving performance was demonstrated, indicating extremely broad application value and promising prospects.

References:

[1] Liang Yangui, Remote Control Circuits, Thyristor Trigger Circuits, Voice Circuits (Volume 1), Beijing: Science and Technology Literature Press, 2002, 60-90.

[2] Yu Yongquan, Application Technology of ATMEL89 Series Microcontrollers. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002, 90-150.

[3] Zhang Yumei, Qu Shiru, Bai Shulin. Infrared remote control switch controller based on single-chip microcomputer. Journal of Xi'an University of Engineering and Technology, December 2005, Vol. 19, No. 4, pp. 1-5

[4] Yang Ying, Design of a single-chip microcomputer infrared remote control. Jiangsu. Electronics & Packaging, November 2005. Vol. 5. No. 11, 1-4

[5] Forsyth, AJ. Extended fundamental frequency analysis of the LCC resonant converter . Power Electronics [J], 2003, 6(18): 1286- 1292.

[6] Doolla, S. A GUI based simulation of power electronic converters and reactive power compensators using MATLAB/SIMULINK. 2004 International Conference on Power System Technology.2004, 2(21-24): 1710-1715.

Read next

CATDOLL 123CM Sasha TPE

Height: 123cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/54/70cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22