1 design concept and principle

1.1 design concept

With the rapid development of digital home technology, there will be more and more value-added services on multimedia terminals. Browsing web pages, searching, SMS and so on all need remote control input. However, as an important peripheral connecting users and terminals, the design concept of remote controller still stays in the era of analog TV, with a poor sense of experience. At present, the solution of user input is the built-in input method of outgoing terminal, which brings two problems: first, terminals of different manufacturers need to build their own Chinese and English input methods, which occupies resources, and must be used with their own remote controller, which is not universal; 2、 When inputting, the user must look at the remote control input and the screen to confirm the input. If there are many words, it will cause the trouble of frequently raising and lowering the head, which is unbearable. Based on the above shortcomings, this paper puts forward the idea that the input method is built into the remote control. After inputting the text on the remote control, the text code is uniformly sent to the terminal with 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 controller

The remote control code is a string of binary digital signals, which forms a pulse sequence through pulse coding, is modulated to a fixed frequency carrier, and finally transmitted in the form of optical pulses through the infrared transmitting tube. Pulse coding is to identify “1” and “0” with one pulse. This design uses NEC infrared protocol, with pulse width 560us and cycle 4x560us to represent binary “1”; Pulse width 560us and period 2x560us represent binary “0” (as shown in Figure 1, dense vertical lines represent 38kHz carrier).

Hardware control design of infrared remote controller for multimedia terminal based on Pic18F series single chip microcomputer

Fig. 1 modulation of infrared remote control signal of NEC protocol

2 hardware design

2.1 overall design principle

Following the design idea of high performance, low power consumption and small volume of embedded system, the overall design principle is: low power chip is adopted for components; Try to use software to realize hardware functions and reduce the number of devices; The keyboard adopts interrupt mode. Once the system is idle and timeout, it will immediately enter the sleep state, and press the key again to wake up.

2.2 hardware composition

The hardware composition is shown in Figure 2. Among them: the main chip is Pic18F series high-grade MCU 66j11 of microchip company, with high cost performance; The LCD controller is 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 MCU is SPI interface; The keyboard has 49 keys. The 7×7 matrix mode is adopted. Seven row lines are connected to the RBI ~ RB7 external interrupt pin of port B of the single chip microcomputer, and the column lines are connected to re1-re7 of port e of the single chip microcomputer as the digital output port.

Hardware control design of infrared remote controller for multimedia terminal based on Pic18F series single chip microcomputer

Fig. 2 hardware composition of infrared remote controller based on PIC MCU

3 software design

3.1 system operation process

The remote control has no on-off process, so the system hardware will initialize and enter sleep when the battery is put in. When the key is interrupted, enter the main program. 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 MCU is responsible for timing the idle state (no key is pressed). After timeout, the system resets and enters the sleep state again.

Hardware control design of infrared remote controller for multimedia terminal based on Pic18F series single chip microcomputer

Fig. 3 system operation flow chart

3.2 power management design

Pic18F series devices provide three main working modes: operation mode, idle mode and sleep mode. In practice, only operation mode and sleep mode are used. According to the operation process of the remote control, the watchdog (WDT: watchdog timer) is responsible for timing the idle time. The 4ms WDT timeout overflow period is multiplied by the 16 bit post division ratio. A multiplexer can be controlled by configuring the wdtps bit in register 2h in MPLAB ide to select the output of WDT rear frequency divider. The timeout overflow cycle range can be obtained is 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 timed again.

3.3 driver design

3.3.1 keyboard drive

The B port of PIC MCU is an external medium fracture, with four int interrupts and four KBI interrupts. In this design, RB0 is reserved for expansion standby, and RBL / Intl, Rb2 / INT2 and RB3 / int3 are set as falling edge to trigger interrupt; Kbl4 ports (rb4-rb7) are level change interrupts (double edges). In the program, only falling edge interrupts are processed.

Key scanning adopts row column scanning to obtain key values. Configure weak pull-up for row lines and 0 for column lines; When a key (row column intersection) is pressed, the line where the key is located will appear a falling edge; After entering the interrupt processing, successively set the output of each column line to 0 and the rest to 1. Scan the row line to see which row line input is 0, so as to obtain the position of the key.

3.3.2 SPI drive

PIC MCU has two main control 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 timing like 51 MCU. This design uses two SPI interface devices: LCD and flash font. They are slave devices and MCU is the master device. After configuring the registers related to SPI clock frequency, the master and slave devices can communicate. When the master device reads data from the slave device, sspxlf (x = 1, 2) flag register is 0, indicating that data is being received, and when it is 1, indicating that a byte has been received; When the master device writes data to the slave device, sspxlf is 1, indicating that one byte has been sent.

3.3.3pwm drive

The infrared carrier port for transmission is realized by standard pulse width eight system module (PWM). The carrier frequency is 38kHz, so the PWM cycle is 1 / 38kHz. The calculation formula of PWM cycle is:

PWM cycle = [()_ PR2) + 1]. 4. TOSC (tmr2 prescaled value)

In this design, the crystal oscillator is 12Mhz, that is, TOSC = 1 / 12Mhz. After calculation, the PR2 register is set to 78. When tmr2 prescaled value is 1, a square wave with a frequency of 38km can be obtained.

The duty cycle of ccx1: con can be set to be low, and the duty cycle of px5: con can also be set to be low. 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 prescaled value)

Set the frequency and duty cycle. Turn on the PWM function, tmr2 (timer 2) starts timing, PWM outputs high level, PWM outputs low level when timing to 1 and 3 of the cycle, PWM restarts another cycle when timing to one cycle, and tmr2 starts timing from 0. Therefore, it is very simple to stop the output of the carrier. Just make the duty cycle 0 or tmr2 stop timing. Therefore, the output shown in Fig. 1 can be easily obtained.

3.4 input method design

3.4.1 functions

The function of inputting Chinese and English, numbers and symbols with the remote control is similar to mobile phone SMS. The Chinese input is a Pinyin input method similar to the mobile phone T9 input method. The English input method is that you can input a letter by pressing the key twice (calling out the candidate character for the first time and selecting the character for the second time). Press the “input method” key to switch from remote control mode to input mode. The operation is the same as that of the mobile phone. “Switch key” is used to switch Chinese / English input, “1” is used to input punctuation, “0” is used to call out digital input method. After input, press the “transmit” button to transmit the codes of all characters on the LCD. Chinese characters are internal 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 principle of Pinyin input method

Pinyin input method is the core content of this design. It is responsible for converting the number sequence input by the keyboard into Chinese characters. The search of Chinese characters adopts look-up table algorithm. The Pinyin input method can be roughly divided into two steps: convert the digital sequence into pinyin code, and then search the Chinese character code corresponding to the pinyin code. The selected Chinese character will be displayed in the text area of LCD, and its code will be recorded in the text array to be transmitted.

3.4.3 important structure of index table

1. Pinyin code is saved in py in the form of index table_ In index. H, the data structure of each pinyin code is:

eonst struct T9PY_ IDX

{

Const unsigned char * T9: / / key digit sequence

Const unsigned char * py: / / Pinyin encoded string

coast unsigned char *pY_ mb;// The address of the Chinese character code table corresponding to the Pinyin

};

All Pinyin Codes form an array constant t9py_ Index [], 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 alphabet index structure is as follows:

const struct PY_ arrange

{

cormt unsigned char *nums;

const unsigned char *arra;

};

For example: const struct PY_ arrange PY_ arr []={“726”,“pan pao ran rao san sao”}

3. Example of Chinese character code table:

const unsigned char PY_ mb_ Zhou [] = {“Zhou Zhouzhou’s curse on the world’s day suddenly”}

3.4.4 use of Chinese font library

The display of Chinese characters is represented by dot matrix on LCD: with stroke (I) and without stroke (o). The binary code set describing dot matrix information is called font, and all dot matrix information forms a font library. GB2312-80 specifies the information exchange code of Chinese characters, referred to as the national standard code, which uses two byte codes to represent a Chinese character. There are also two concepts of location code and internal code in microcomputer. The area and bit are 94 (1-94) respectively, which are represented by two 2-digit decimal numbers after the area; The internal code is the code of Chinese characters stored in the computer.

In this design, each Chinese character is displayed in 16×16 graphic dot matrix. The hzk16.dat binary file can be found in UCDOS and other Chinese character operating systems, which is a standard 16×16 dot matrix font library. Take 94 Chinese characters as a group. A total of 87 groups, 8178 words. Based on 16×16 dot matrix Chinese characters, the actual space occupied by each Chinese character is 32bytes, and the total capacity is 8178×32 = 262kb. Burn hzk16.dat into flash with a tablet burner.

Taking the Chinese character “electricity” as an example, its internal code is oxb5e7. What is needed in the single chip microcomputer system is its absolute position in the memory, so it needs to be converted into location code first. The summary formula is:

((high byte of internal code – Oxa1) x94 + low byte of internal code – 0xal) X32

Then the address of “dian” in the font is ((oxb5 Oxal) x94 + 0xe7-0xal) X32. AT45DB021B is stored in pages with 264bytes per page. Therefore, the quotient of the above address divided by 264 specifies which page to read, and the remainder specifies which byte of the page to read from.

4 Conclusion

The future multimedia terminal will bring consumers the enjoyment of information, entertainment, learning and shopping. This remote control has strong universality and wide application range. It can support a variety of value-added services such as search and SMS, bringing users a revolutionary sense of experience. The BOM cost of the remote controller is less than 100 yuan, the ordinary remote controller is 20 yuan, and the price difference is 80 yuan. If it is used for the bundle sales of high-end VOD business, assuming that the monthly tariff is 20 yuan, the investment can be recovered in less than 4 months, with excellent economic benefits and huge market potential.

The author’s Innovation: in view of the shortcomings of poor user experience in multimedia terminal input, this paper introduces a new infrared remote controller that can send text information to the terminal, and gives a solution based on pic8 bit single chip microcomputer. Its design concept is more in line with the future development direction of digital family, which has a certain reference significance.

Source; 21ic

Leave a Reply

Your email address will not be published. Required fields are marked *