Infrared Communication Interface in Single Chip Microcomputer System

Publisher:亚瑟摩根Latest update time:2011-02-27 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: This paper combines the design practice of infrared communication in multi-rate electric energy meter, introduces the software and hardware design method of infrared communication in single-chip microcomputer system, and gives the specific circuit principle and communication source program.

Keywords: single-chip microcomputer, infrared communication, remote control

In many application systems based on single-chip microcomputer, the system needs to realize remote control function, and infrared communication is a method that is widely used. The remote control protocol on the market is simple, the confidentiality is not strong, and the anti-interference ability is weak. Here, we introduce an infrared remote control system based on byte transmission, which can be suitable for various complex applications.

The basic principle of infrared communication

The basic principle of infrared communication is that the transmitter modulates the baseband binary signal into a series of pulse train signals and transmits the infrared signal through the infrared transmitting tube. Commonly used methods are pulse width modulation (PWM) that realizes signal modulation by pulse width and pulse time modulation (PPM) that realizes signal modulation by the time interval between pulse trains. This system adopts the permanent time system method. The transmission of data bits imitates RS232 communication without odd-side check. First, a synchronization header is generated, followed by 8 data bits.


Hardware circuit design

The multi-rate energy meter system can be divided into two parts: the handheld remote control and the multi-rate energy meter. The handheld remote control is the transmitting part, and its basic circuit is shown in Figure 2. The plastic-encapsulated SE303ANC-transmitting diode is used, and the wavelength is 940nm. The CPU turns on or off the transmitting diode according to the protocol, thereby generating a transmitting signal of a specific frequency. The frequency selected here is 38.9kHz. The basic circuit of the infrared receiving part of the multi-rate energy meter is shown in Figure 3. The receiving tube uses the PIC-12034 of Japan Optoelectronics Company, and its receiving frequency is 37.9kHz. It directly demodulates the 37.9kHz modulated signal into a baseband signal and provides a ribbon receiving CPU. The chip has high receiving sensitivity and stable performance. Its basic working process is: when receiving a 37.9kHz signal, it outputs a low level, otherwise it outputs a high level. The energy meter part uses a 51 series single-chip microcomputer, which detects the received signal in an interrupt mode. The NOT gate here plays a shaping role on the received signal.


Software Design

The program of the transmitting part is relatively simple, mainly producing 37.9kHz pulse train signals with different time intervals to control the on and off of the transmitting tube. At the transmitting end, the CPU continuously scans the keyboard. Once a key is pressed, the transmitting subroutine is started to send out the corresponding value. In our design, a 4×4 small keyboard is used. Just as it corresponds to the 0~F code, in order to improve reliability, the simplest error correction code is used-sending each digit repeatedly, that is, the code corresponding to the keyboard number is 00~FF. In this way, a key value needs to send 8 bits. After the receiving end receives the full 8-bit signal, it will perform error correction processing, and incorrect codes are considered invalid. After receiving the specified number, the number analysis program is called for processing. When a pulse train signal is received, a timer is started. When the next interrupt occurs, the count value of the timer is used to determine whether it is 0 or 1. If the timer overflows, the number received this time is cleared and restored to the initial state of reception. The basic program flow of the receiving part is shown in Figure 4.

When designing the program, it should be noted that the MCU interrupt mode uses falling edge triggering: the receiving end uses the T0 count value to determine the transmitted bit, and generally uses hard judgment, that is, the average value of the 0 and 1 bit widths is taken as the decision threshold A. When the T0 value is greater than A, the received signal is judged to be 0, and when it is less than A, it is judged to be 1.

The infrared receiving program in the multi-rate electric energy meter (MCU is Intel 8052, written in C language) is shown in the program list.

Conclusion

The above design scheme has been applied to the multi-rate electric energy meter, and the effect is good, meeting the design requirements. The whole system has few peripheral components, which is convenient for debugging; the software workload is also small. If it is used to transmit a large amount of data, the corresponding encoding form can be changed as needed to increase the data transmission rate.

Communication source program
#include
#include
#include
#pragma OPTIMIZE(5,SPEED)
sbit RECV=P3^3;
bdata unsigned char SIGN,RECVBYTE;
sbit RECVBG=SING^0;
sbit US1AT=SIGN^6;
sbit RECVBITO=RECVBYTE^0;
unsigned char RECVBIT;

timer0() interrupt 1 ∥ entry:8*n+3=0Bh;
{
IE=0x8d; ∥ 1(EA)0(X)0(X)0(X)-1(ET1)1(EX1)0(ET0)1(EX0)
RECVBG=0;
}

EX-INT1() interrupt 2 ∥ receive infrared signal
{
TCON=0x45; ∥0(TF1)1(TR1)0(TF0)1(TR0)-0(IE1)1(IT1)0(IE0)1(IT0)
If(RECVBG==0) {RECVBG=1;
RECVBIT=8;
}
eles{BECVBYTE=RECVBYTE<<1;
if(TH0<=4)RECVBIT0=1;
else RECVBIT0=0;
RECVBIT--;
If( IT==0) {RECVBG=0;
US1AT=1;
}
}
TH0=0;
TL0=0; TCON=0x55; ∥0(TF1)1(TR1) 0
(TF0)1(TR0)-0(IE1)1(IT1)0(IE0)1(IT0) IE =
0x8f; RECVBYTE=O; SIGN=O; TMOD=0x11; TCON=0x55; ∥0(TF1)1(TR1)0(TF0)1(TR0)-0(IE1)1(IT1)0(IE0)1(IT0) IP=0x00; IE=0x8d; ∥1(EA)0(X)0(X)0(X)-1(ET1)1(EX1)0(ET0)1(EX0) ∥Basic loop program while(1) {











..
(Omitted)

if(US1AT==1{∥Infrared receiving processing

.(Omitted)

}
}
}

Reference address:Infrared Communication Interface in Single Chip Microcomputer System

Previous article:Introduction to MCU and its development history
Next article:The basic principle of stepper motor

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号