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.
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
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Development data of National Technology N32G455
- What is IoT
- [SC8905 EVM Review] + Found an error in the User Guide
- What communication technology is needed for the interactive transmission of RFID information?
- [Ready to use] LIS2DTW12 functional demonstration project (STM32G474)
- Code migration process of MSPBoot
- Why is there a 2 in the denominator when calculating the baud rate of the serial port communication of the 51 single-chip microcomputer? I have always wondered why it is divided by 2
- Please share the basic principles of 5G
- Why does the g2553 circuit board omit the external 32.768k crystal oscillator?
- [Xingkong Board Python Programming Learning Main Control Board] LED and light sensor usage experience-automatic light controller implementation