Application of infrared remote controller in single chip microcomputer control system

Publisher:hxcp18Latest update time:2011-10-22 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Overview

Single-chip control systems are widely used in electrical equipment and electronic products, and the external operations to achieve control are mostly completed by keyboards or computers, which have certain limitations. For example, for the modification of the displayed data of some electronic products, when the installation position is high, key control is very inconvenient. If a PC is used, in addition to the circuit being more complicated, the cost is also increased accordingly. For this reason, we have developed a single-chip control system that uses an infrared remote control used for ordinary TVs as a controller.

2 Hardware Design

Use MCS251 series single-chip microcomputer, select Zhonghe brand TV remote control, reset the button function, connect the output end of infrared receiver to the external interrupt (INT 0 or INT1) of single-chip microcomputer, when the remote control is operated, the receiver has signal output, and the single-chip microcomputer generates interrupt.

2.1 Introduction to infrared remote control

2.1.1 Basic composition

The core of the infrared remote control is the remote control transmitter integrated circuit. The integrated chip used in Zhonghe brand TV remote control is M50462AP, and its internal structure is composed of the circuits in the dotted box in Figure 1.

Figure 1 Remote control transmitter integrated circuit

2.1.2 Working principle

When a key on the remote control is pressed, the oscillation circuit is immediately connected and starts to oscillate. The scanning signal generator then sends out 8 scanning timing pulses with different timings to scan the keyboard matrix in turn. The keyboard encoder determines the position of the pressed key based on the received feedback signal and outputs the corresponding code to the decoder. The signal after code element conversion by the decoder is re-encoded and modulated for output.

2.1.3 Instruction code

The output signal of the integrated chip M50462AP is a pulse position modulation code, and its carrier frequency is a square wave signal with a center frequency of 40kHz and a duty cycle of 3.

A single-bit pulse position modulation code is shown in Figure 2. When the pulse width is 1ms, it represents a binary number / 00; when the pulse width is 2ms, it represents a binary number / 10.

Figure 2 Pulse position modulation code

Each transmission instruction consists of 16 bits of /00, /10 codes. The first 8 bits of the 16-bit code are the user code, and the user code is formed as 1110xx10. The remote control manufacturer can set /x0 to /10 or /00. The user code of Zhonghe brand remote control is 11100010, which is E2H; the last 8 bits of the 16-bit code are the data code, that is, the key function operation code, and the encoding is listed in Table 1.

Table 1 Key function operation code encoding table

The functions of the new keys in Table 1 can be set as needed. The ones given here are designed for the electronic clock.

The time it takes for the remote control to send a set of commands is 44ms, so the remote control can send multiple sets of command codes at one time for the receiving head to receive.

The control system we designed needs to extract 3 sets of data from it. [page]

2.2 Use of receiving header

The infrared receiver head is commonly known as the remote control preamplifier, which converts the received pulse position modulation code into the receiving code shown in Figure 3. The receiver head is easy to use, and its three pins only need to be connected to the ground, +5V power supply and INT 0 or INT 1 of the CPU.

Figure 3 Receive code

3 Software Design

This system is designed to identify instruction codes and implement new key functions based on instruction information. Our idea is to identify instruction codes and save data in the interrupt service program, and use the main program to compare and process the data to achieve various functions.

3.1 Interrupt Service Routine

3.1.1 Code judgment

The code is judged by counting and comparing. When the interrupt is entered, the timer T1 is immediately turned on to start counting. The counting time of the code /00 and /10 is determined by their pulse widths, which are 1ms and 2ms respectively. The theoretical counting values ​​A0 and A1 can be obtained by the following formulas:

A0= 1ms/one machine cycle

A1= 2ms/ one machine cycle

When the microcontroller uses crystal oscillators of different frequencies, the theoretical count value will also be different.

Taking into account the error between the remote control and the microcontroller reference frequency, it is difficult to ensure that the actual count value is completely consistent with the theoretical count value. For this reason, a window should be opened for the actual count values ​​of /00 and /10 to avoid data loss. At the same time, in order to enhance anti-interference, the window width should be moderate. After experiments, we determined the window width to be 0.224ms. The specific values ​​are listed in Table 2.

Table 2 Count window values

When the actual count value is between A0L and A0H, we consider the received code to be /00; when the actual count value is between A1L and A1H, the code is recorded as /10.

3.1.2 Instruction recognition

The received instruction code is stored bit by bit in the 2AH~2FH unit of the MCU RAM area, and a total of 3 groups of 48-bit instruction codes can be stored. The effective storage methods are listed in Table 3.

Table 3 Storage method

In Table 3, jjH represents the function operation code of any key in Table 1. Only when 2A= 2C= E2H and 2B= 2D=jjH, this instruction code is considered valid. The operation code represented by jjH is stored in the data temporary storage unit 1EH, and the main program can be used.

3.1.3 Interrupt service program flow

In the program, each received code is first judged as /00 or /10 and then stored. After 48 bits are stored, it is judged whether the data is valid, and finally the valid instruction code is stored. The program flowchart is shown in Figure 4.

In Figure 4, the shift processing refers to the overall shift of the 6 bytes from 2AH to 2FH to the left. The purpose is to prevent data loss caused by the receiving head starting to receive data from the middle of a group of instructions. If no valid instruction code appears after shifting 16 times, this group of data is considered invalid.

Figure 4 Interrupt service program block diagram

3.2 Main program

To cooperate with the interrupt service routine, set INT 0 or INT 1 to negative edge trigger mode in the main program initialization, and set timer T1 to working mode 2, and do not allow interrupts.

The control function can be realized by continuously taking out data from the instruction code temporary storage unit 1EH and then comparing it with the key function operation code in Table 1 one by one, and attaching other function realization subroutines.

4 Conclusion

When other models of remote controls or microcontrollers are selected, the method described in this article is still applicable, except that the command code type of the remote control and the counting speed of the microcontroller need to be re-determined.

The single-chip microcomputer system using infrared remote controller is not only cheap, but also simple and practical in circuit, easy to operate, stable in performance and easy to promote. It has been used in many automatic control systems we have made.

Reference address:Application of infrared remote controller in single chip microcomputer control system

Previous article:Design of infrared remote control LED electronic clock controlled by 51 single chip microcomputer
Next article:Charger circuit controlled by 51 single chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号