1 Design Concept and Principle
1.1 Design Concept
With the rapid development of technology in the field of digital home, there will be more and more value-added services on multimedia terminals. Browsing web pages, searching, and sending text messages all require input via remote control. However, as an important peripheral connecting users and terminals, the design concept of remote control is still stuck in the era of analog TV, and the user experience is poor. At present, the solution for user input is to call out the built-in input method of the terminal, which brings two problems: First, terminals from different manufacturers need to have their own built-in Chinese and English input methods, which takes up resources and must be used with their own remote controls, which is not very universal; second, when users input, they must look at the remote control while looking at the screen to confirm the input. If there are many words, it will cause the trouble of frequently looking up and down, which is unbearable. Based on the above shortcomings, this paper proposes the concept of building the input method into the remote control. After entering the text on the remote control, the text code is uniformly sent to the terminal by infrared. After receiving it, the terminal translates the code into text and displays it in the input area.
1.2 Working principle of infrared remote control
The remote control code is a string of binary digital signals, which is formed into a pulse sequence through pulse coding, modulated onto a fixed frequency carrier, and finally transmitted in the form of light pulses through the infrared transmitting tube. Pulse coding is to mark "1" and "0" with a pulse. This design uses the NEC infrared protocol, with a pulse width of 560us and a period of 4x560us representing binary "1"; and a pulse width of 560us and a period of 2x560us representing binary "0" (as shown in Figure 1, dense vertical lines represent 38KHz carrier).
Figure 1 Modulation of NEC protocol infrared remote control signal
2 Hardware Design
2.1 Overall design principles
Following the design concept of high performance, low power consumption and small size of embedded systems, the overall design principles are: components use low-power chips; try to use software to implement hardware functions to reduce the number of components; the keyboard uses an interrupt method, and once the system is idle for a timeout, it immediately enters a sleep state and can be awakened by pressing the key again.
2.2 Hardware Composition
The hardware composition is shown in Figure 2. Among them: the main chip is Microchip's PIC18F series high-end single-chip microcomputer 66J11, which has a very high cost performance; the LCD screen controller is Sitronix's ST7565R, with a resolution of 128x64; the Chinese character dot matrix font library is made of Atmel's 262KB Flash, and its interface with the LCD and the single-chip microcomputer is SPI interface; the keyboard has 49 keys. It adopts a 7x7 matrix method, with 7 row lines connected to the RBI~RB7 external interrupt pins of the single-chip microcomputer B port, and the column lines connected to the RE1-RE7 of the single-chip microcomputer E port as digital output ports.
Figure 2 Hardware composition of infrared remote control based on PIC microcontroller
3 Software Design
3.1 System operation process
The remote controller has no power on/off process, so the system hardware is initialized and enters sleep mode when the battery is inserted. When the key is interrupted, the main program is entered. The system operation process is shown in Figure 3, which is divided into two modes: ordinary remote control and text input. The watchdog inside the microcontroller is responsible for timing the idle state (no key is pressed). After the timeout, the system resets and enters sleep mode again.
Figure 3 System operation flow chart
3.2 Power management design
PIC18F series devices provide three main working modes: running mode, idle mode and sleep mode. In practice, only running mode and sleep mode are used. According to the operation process of the remote control, the watchdog (WDT: Watchdog Timer) is responsible for realizing the timing of idle time. The 4ms WDT timeout overflow period is multiplied by the 16-bit post-division ratio. You can control a multiplexer to select the output of the WDT post-division ratio by configuring the WDTPS bit in register 2H in MPLAB IDE. The available timeout overflow period ranges from 4ms to 135 seconds (2.25 minutes). In the code, you need to feed the dog after each key press to ensure that the watchdog is re-timed.
3.3 Driver Design
3.3.1 Keyboard Driver
Port B of the PIC microcontroller is an external interrupt port, with four INT interrupts and four KBI interrupts. This design reserves RB0 for expansion, and sets RBl/INTl, RB2/INT2 and RB3/INT3 as falling edge-triggered interrupts; KB14 ports (RB4-RB7) are level change interrupts (double edge), and only falling edge interrupts are processed in the program.
The key scan uses row and column scanning to obtain the key value. The row lines are all configured to be weakly pulled up, and the column lines are all output to 0; when a key (row and column intersection) is pressed, the row line where this key is located will have a falling edge; after entering the interrupt processing, each column line is output to 0 in turn, and the rest are 1, and the row lines are scanned to see which row line input is 0, so as to get the position of the key.
3.3.2 SPI Driver
PIC microcontroller has two master synchronous serial port modules, which can be configured as SPI mode by software, which is very convenient to use. Data reading and writing only need to read and write its cache, and there is no need to simulate the timing like 51 microcontroller. This design uses two SPI interface devices: LCD and FLASH font library, they are slave devices, and the microcontroller is the master device. After configuring the registers related to the SPI clock frequency, the master and slave devices can communicate. When the master device reads data from the slave device, the SSPxlF (x=1, 2) flag register is 0, indicating that data is being received, and when it is 1, it means that a byte has been received; when the master device writes data to the slave device, SSPxlF is 1, indicating that a byte has been sent.
3.3.3 PWM drive
The infrared carrier used for transmission is implemented with a standard pulse width control module (PWM). The carrier frequency is 38KHz, so the PWM period is 1/38KHz. The calculation formula for the PWM period is:
PWM period = [(_PR2) + 1]. 4. TOSC (TMR2 prescale value).
The crystal oscillator in this design is 12MHz, that is, TOSC=1/12MHz. After calculation, the PR2 register is set to 78. The TMR2 pre-division value is 1, which can get a square wave with a frequency of 38Km.
You can also set the duty cycle of the square wave to 1:3 to reduce power consumption. The duty cycle has 10 bits. The register CCPRxL stores the upper 8 bits of the duty cycle, and CCPxCON<5:4> stores the lower 2 bits. CCPRxL:CCPxCON<5:4> represents this 10-bit value. The formula for calculating the duty cycle is:
PWM duty cycle = (CCPRxL: CCPxCON<5:4>).TOSC.(TMR2 prescale value)
Set the frequency and duty cycle. Turn on the PWM function, TMR2 (timer 2) starts timing, PWM outputs high level, and when the timing reaches 1 and 3 of the cycle, PWM outputs low level. When the timing reaches one cycle, PWM restarts another cycle, and TMR2 starts timing from 0. So it is very simple to stop the output of the carrier, just set the duty cycle to 0 or stop TMR2 timing. Therefore, it is easy to get the output shown in Figure 1.
3.4 Input method design
3.4.1 Function
Use the remote control to input Chinese, English, numbers, and symbols. The function is similar to mobile phone text messages. The Chinese input is similar to the pinyin input method of the mobile phone T9 input method. The English input method only requires two key presses (the first time to call out candidate characters, the second time to select characters) to input a letter. Press the "Input Method" key to switch from remote control mode to input mode. The operation is the same as that of a mobile phone. The "Switch Key" is used to switch between Chinese and English input, "1" is used to enter punctuation, and "0" is used to call out the digital input method. After input, press the "Transmit Key" to transmit the encoding of all the characters on the LCD. Chinese characters are machine codes, and English, numbers and symbols are ASCII codes. If you want to return to remote control mode, press the "Input Method" key again.
3.4.2 Design Principles of Pinyin Input Method
Pinyin input method is the core of this design. It is responsible for converting the digital sequence input by the keyboard into Chinese characters. The search of Chinese characters adopts the table lookup algorithm. Pinyin input method can be roughly divided into two steps: converting the digital sequence into Pinyin code, and then searching for the Chinese character code corresponding to the Pinyin code. The selected Chinese character will be displayed in the text area of the LCD, and its code will be recorded in the text array to be transmitted.
3.4.3 Important structures of index tables
1. The pinyin codes are stored in PY_Index.h in the form of an index table. The data structure of each pinyin code is:
eonst struct T9PY_IDX
{
const unsigned char *t9: // key number sequenceconst
unsigned char *PY: // pinyin encoding stringcoast
unsigned char *pY_mb; // address of the Chinese character code table corresponding to the pinyin
};
All pinyin codes form an array constant T9PY_index[], and each pinyin code exists as an element in the array, such as: const struct T9PY_IDX
PY_index[]{"9468", "zhou", PY_mb_zhou},
2. Pinyin input method Pinyin combination query code table, T9 digital letter index structure is as follows:
const struct PY_arrange
{
cormt unsigned char *nums;
const unsigned char *arra;
};
Previous article:The following factors affect the power consumption of PIC microcontrollers:
Next article:Using PIC microcontroller design to make electric fan send out natural wind
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
- ST60 Short Range Contactless 60GHz Millimeter Wave Connector Unboxing and Analysis
- Free Review: Pengfeng Artix 7 FPGA Development Kit
- C2000 CLA FAQ
- Hardware Engineer Recruitment
- [Sipeed LicheeRV 86 Panel Review] 5. WAFT First Experience
- Ultra-small packaged IC chips VKD233DS and VKD233DR for wireless Bluetooth headsets
- PCB board level shielding design
- DSP Basics--Fixed-point Decimal Operations
- "Chat and Laugh" has opened another thread to discuss the issue of nuclear energy. I hope everyone can express their opinions.
- Types of EMI filter components and filters