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 the high-end PIC18F series microcontroller 66J11 of Microchip Company, which has a very high cost performance; the LCD screen controller is the ST7565R of Sitronix Company, with a resolution of 128x64; the Chinese character dot matrix font library is made of 262KB Flash of Atmel Company, and its interface with LCD and microcontroller is SPI interface; the keyboard has 49 keys. It adopts 7x7 matrix mode, 7 row lines are connected to the RBI~RB7 external interrupt pins of the B port of the microcontroller, and the column lines are connected to the RE1-RE7 of the E port of the microcontroller 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 configure the WDTPS bit in register 2H in MPLAB IDE to control a multiplexer to select the output of the WDT post-division ratio. 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 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, both of 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 obtain 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 pressing the key twice (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 code is 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 sequence
const unsigned char *PY: //Pinyin encoding string
coast unsigned char *pY_mb; //The Chinese character code table address 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:Design of wireless communication module test board based on PIC microcontroller
Next article:Analysis of the Basic Programming Methods of PIC Microcontrollers
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Collaborative SI-PI-EMI Simulation of Chip-Package-System (CPS)
- Use stm32l452 to drive hts221 and stts751 routine
- [National Technology N32WB452 Review] + Basic Function Usage
- Will demand for SiC FETs increase in the future?
- Problems with pressure maintenance of testing machine
- When TMS320F28377D runs CLA, it shows that Cla1Task2 does not contain frame information
- Application and precautions of Hall elements
- Which one is better to use, the Type-C interface or the MicroUSB interface for mobile phone data cables?
- Showing goods + development board and multimeter
- Why is the GaN device [G-level is negative voltage powered]