Author Email:
Abstract : This paper briefly introduces the principle of infrared remote control transmitting and receiving system, gives a clever implementation method of using 89C2051 as the remote control receiving system decoder, and complete 51 assembly program code. Including the schematic diagram of the transmission and reception and the main program of programming, the serial port transmission program, the reception program, and the timing interruption program, so as to complete the main points of this design, referring to the conception process of the flow block diagram, you can write application software The serial port remote control code and its verification function are used to prevent the interference of other remote control codes and improve the reliability of the product. The infrared remote control device has the characteristics of small size, low power consumption, strong function and low cost.
Infrared remote control is currently the most widely used means of communication and remote control. Because infrared remote control has the characteristics of small size, low power consumption, strong function and low cost. Therefore, infrared remote control has also been adopted in other small devices such as color TVs, video recorders, audio equipment, air conditioners, toys, doorbells and remote control car street signs. In order to change the defect of the front street sign indicator light (hereinafter referred to as the car number device) on the current car, which cannot be flexibly changed, infrared remote control is used in it, so that it can easily achieve the purpose of changing the car number at a long distance and non-contact, Thereby changing the old model of manual flop.
1. Infrared remote control system of car number device
The number plate on the car was originally controlled by a simple LED digital tube, which is very inconvenient to use. In order to control it remotely, infrared remote control is used. Infrared remote control system is usually composed of two parts: transmitting and receiving, and the application of special integrated circuit chip for coding / decoding circuit to control operation. As shown in Figure 1, the transmitting part includes keyboard matrix, code modulation, infrared transmitter. The receiving part includes photoelectric conversion amplifier, demodulation and decoding circuit. Infrared transmission Each coded transmission is a key value, that is, a hexadecimal data. In order to be able to send a group of data at a time (such as the car number, usually a three-digit decimal number), we can use the software encoding / decoding method of 89C2051, first enter a group of car numbers at a time, press the send key, and send all Out; at the same time, when receiving, use the continuous receiving method to decode all the data at once.
Second, the remote control transmitter and its code
There are many special chips for remote control transmitters, but in the remote control of car number devices, the 89C2051 chip is used. Use the P1 port to form a matrix scan feedback to obtain the key value, use the internal timer 1 to generate a 38K software timer interrupt, and drive P1.0 to generate a 38K square wave, which is used as the modulated infrared fundamental wave and the data to be sent. In serial mode, with a baud rate of 1200, with parity check, send directly to the TXD serial port transmitter, and then after the logical AND of TXD and P1.0, after 40106 shaping, use the triode to drive the infrared emission tube directly issue. The schematic diagram is as follows:
3. Infrared remote control receiver and its display
The receiver part is mainly composed of CX20106 and 89C2051, display driver 4094, 2803 and data memory and watchdog 25045. After filtering the 38K carrier wave with the decoder chip CX20106, a set of waveforms is obtained, that is, a serial port with a baud rate of 1200 The data is sent directly to the RXD receiver of 89C2051, read the serial port with software, input the buffer, get a set of data, and store it in the non-volatile EEPROM25045 after judgement is correct, and directly use the pulse shift method to send the data to 4094 It is displayed after being driven by 2803, and the watchdog timer of 25045 is used at the same time to ensure that it can return correctly without causing erroneous reception in the case of program out of control. Due to the serial port transmission, it has parity check and start-stop check, which can greatly improve the reliability of the data. At the same time, the cumulative sum check is added to the data group, which improves the reliability again. In the application, even in the harsh environments of open air, direct sunlight, and strong light, it can ensure that the data will not be received by mistake and cause display errors. The schematic diagram is as follows:
Four, software programming
The single-chip 89C2051 software includes three parts: the main program, the serial port interrupt service program and the timer interrupt service program, and the corresponding working unit and flag bit are established in the internal RAM area of ​​the 2051 single-chip computer.
(1) Sending procedure: SEND-BUFO∽SEND-BUF3 is a four-character sending buffer, and SEND-MARK is a request sending mark. When the keyboard scans to send request, start the timer, output a 38K square wave at P1.0, and start the serial port at the same time, send the data from SEND-BUFO to SEND-BUF3 to SBUF, send it after synthesis . The procedure flow is as follows:
Send the main program: set the timer, watchdog and serial port during initialization, and clear the display, and then scan the keyboard. If a key is pressed, the key is processed; if it is a send key, the serial port sending flag is set, the timer and the serial sending program are started, and then the display program in the main program is returned, and the display data is sent to the buffer.
Serial port interruption program: on-site protection, take the sending data to the sending buffer, start the software to generate a 38K square wave regularly, and then judge whether the data is sent, and then clear the sending flag, otherwise, return to continue sending data.
Timed interruption program: the on-site protection backfills the length of the timing, starts the counting timing, and inverts at the designated pin P1.0, becomes the inverted level, and returns.
(2) Receiving procedure: REC-BUFO∽REC-BUF4 is a four-character receiving buffer, and REC-MARK is a complete mark for data reception. When the serial port interrupt is generated, the data is received in order from REC-BUF0 to REC-BUF3. After the data is full, the cumulative sum is calculated. If correct, set the REC-MARK flag; otherwise, clear the buffer data. If the REC-MARK mark is judged in the main program, the data is processed and sent to the external storage 25045 and displayed in the display buffer. At the same time, because the reception is performed in the car, there are many power supply voltages and other interferences, including possible generations. Serial port misjudgment, etc. Therefore, in order to ensure that the program can run normally, the watchdog circuit in 25045 is started to refresh regularly every 500ms. The procedure flow is as follows:
Receiving main program: set timer, watchdog, clear display and external memory 25045 to judge whether there is a data receiving flag during initialization. If there is data judgment, write it to the data external memory correctly and send it to the display area for display, otherwise, Return to the main program display program and refresh the watchdog.
Serial port interrupt receiving program: after on-site protection, judge whether the received data is the head or tail data, store the buffer when the corresponding processing is normal data, and increase the pointer by one, when the complete set of data is received normally, set the received data Return after sign.
The timed interrupt procedure is consistent with sending, but the watchdog is refreshed regularly.
V. Conclusion
The above method very simply realizes the receiving and decoding of infrared remote control signals, which greatly saves the resource overhead of hardware implementation. The design of the infrared remote control system has been applied to the bus, which has improved the service quality of the bus system and the working efficiency.
References: 1. Li Hua. Practical Interface Technology of MCS-51 Series Single Chip Microcomputer. Beijing University of Aeronautics Press, 1993
2. Sun Yucai. MCS-51 series single-chip microcomputer and its application. Southeast University Press, 1991
GMSK Radio Modem,High-speed Radio Modem,Long Distance Transmission
Shenzhen PuFang Technology Co., Ltd. , https://www.hytelus.com