Infrared communication technology is a point-to-point data transmission protocol. It is an alternative technology for connecting cables between traditional devices. It is a short-range wireless transmission technology commonly used internationally. It is often used in intelligent community control systems and telephone teaching interactive remote control systems. However, current home appliances (such as air conditioners, video recorders, VCD players, etc.) have various brands and models, and their infrared remote control codes and transmission formats are not the same. In order to be able to control a variety of different models of home appliances with a universal controller, this paper uses a powerful single-chip microcomputer and programming software VB to design a universal intelligent infrared logic analyzer based on a computer serial port. It can identify, store and reproduce the control signals emitted by infrared remote controllers of various electrical appliances. It can also identify infrared signals through infrared hardware interfaces and send them to single-chip microcomputers for processing. Then, the collected infrared signal waveforms can be displayed in real time on the computer screen using virtual software developed by VB, which is convenient for designers to "visualize" and study infrared signals of various modulation methods.
1 Hardware Design
1.1 Basic principles of serial communication
The serial port is essentially a code converter between the computer's CPU and external serial devices. When data is sent from the CPU through the serial port, the byte data is converted into serial bits. When receiving data, the serial bits are converted into byte data. In the Windows environment, the serial port is part of the Windows system resources. If you want to use the serial port for communication, the application must submit an application to the operating system for the use of serial port resources (create and open the serial port) before use, and then configure the corresponding serial port parameters. Only then can the serial ports of both parties communicate. After the communication is completed, the system resources must be released (the serial port must be closed). The process of the serial port communication program is shown in Figure 1.
1.2 89C51 serial port
There is a full-duplex serial port in 89C51, which has four working modes: Mode 0, the serial interface is shift register I/O mode; Mode 1, the serial interface is controlled as an 8-bit asynchronous communication interface. In fact, the transmission of a frame should be 10 bits, of which 1 is the start bit, 8 are data bits, and 1 is a stop bit. In this mode, the baud rate is variable; Mode 2 and Mode 3 are defined as 9-bit asynchronous communication interfaces. At this time, the transmission of a frame of information is 11 bits, of which 1 is a start bit, 8 are data bits, 1 is a programmable data bit, and 1 is a stop bit. The selection of the working mode is determined by the special function register SCON (serial port control register) in the chip.
1.3 Interface Circuit
In order to enable the microcontroller to communicate with the PC, they must follow the same communication protocol. Since the serial port input/output of 89C51 is TTL logic level, the high level is about 3.8V and the low level is about 0.3V, so the anti-interference performance of this method of transmitting data at TTL level is poor. The RS-232C serial port inside the computer uses ±12V and -12V level mode. In this mode, the level difference between signal 0 and signal 1 increases, thereby enhancing the anti-interference performance. However, in order to solve this contradiction of inconsistent levels, an RS-232C level converter must be used. The MAX232 used in this article has its own power supply voltage converter, which can convert the +5V voltage into the ±10V voltage required for the RS-232 output level. Therefore, this method of serial communication has better performance and low price. If the communication distance is far, you can also connect MAX232 by adding a MAX485 converter to meet the requirements. The principle of its hardware interface circuit is shown in Figure 2.
2 Software Design
2.1 Infrared remote control coding and transmission format
The basic principle of infrared communication is to modulate the baseband binary signal into a series of pulse train signals at the transmitting end, and then transmit the infrared signal through the infrared transmitting tube. Commonly used methods include pulse width modulation (PWM) that realizes signal modulation through pulse width and pulse modulation (PPM) that realizes signal modulation through the time interval between pulse trains. This system adopts the pulse time modulation method. In the modulated pulse width encoding method, "0" is represented by an idle state of a series of 38.5kHz carrier pulses with a time interval of T plus a carrier-free pulse with a time interval of T0; and "1" is represented by an idle state of a series of 38.5kHz carrier pulses with a time interval of T plus a carrier-free pulse with a time interval of T1, where T1 is greater than T0.
In order to improve anti-interference ability and communication reliability, most infrared remote control transmitters insert various guide codes before sending binary codes for the receiver to identify. In order to distinguish different types of remote controllers, it is also necessary to send address codes and check codes. In addition, the code lengths sent by different remote controllers are also different. The general transmission format is shown in Figure 3. [page]
2.2 MCU Software Programming
The programming of the MCU (lower computer) part is mainly to complete the serial communication between the MCU and the computer. The software is mainly composed of three modules: serial port initialization sub-function, MCU internal timer T0 interrupt sub-function, infrared signal sending sub-function. The specific program is as follows:
#include>at89x52.h)
#define byte unsigned char
#define WAR_0 P1_1 //define the receiving pin
#define LED_RECEIVE P1_0 //Define indicator pin
//Crystal 22.1184MHz
//Baud rate = ((xtal/12/t1_over_rate)/32)*2^pcon
byte bdata buffer=0;
sbit way0=buffer^0;
byte i=0;
bit start=0;
void send char(unsigned char word) //Serial port sending subfunction
{
TI=0;
SBUF=word;
While(TI==0);
TI=0;
}
void t0_service(viod) interrupt 1 using 1 //T0 interrupt sub-function
{
way0=WAY_0;
I++;
If(I=8)
{
TI=0;
SBUF=buffer;
I=0;
}
buffer=buffer<<1;
}
void main(void) //main function
{
SCON=0x40; //Set the serial port mode
TMOD=0x22; //Set timer mode
TH1=0xff; //Timer loads initial value
TH1=0xff;
PCON=0x80; //57600bps *2 22.1184M
115200bps
TR1=1; //Start the timer
TH0=0xdb; //Timer 0 loads initial value
TL0=0xfd;
EA=1;
WAY_0=1;
ET0=1; //The above is serial initialization
While(1) //Main loop
{
if(! WAY_0)
{
TR0=1; //Turn on timer T0 interrupt
LED_RECEIVE=0; //LED indicator lights up
}
}
}
2.3 Host computer software design
The function of the host computer (computer) software is to collect the signals received by the computer serial port (i.e. the signals sent by the single-chip microcomputer) in real time, and at the same time realize the real-time display of the collected infrared signals through VB software programming for easy analysis.
Generally, IBM PC compatible microcomputers are provided with 1 to 2 25-pin or 9-pin RS-232C standard serial ports, referred to as COM1 and COM2. In some applications, additional RS-232C standard serial ports can be obtained by inserting communication cards. With these serial ports, microcomputers can perform general data communications with other digital devices (including computers).
The MSComm control provided by Visual Basic can be used to implement serial communication through applications in a simple and portable manner, or to create a fully functional, advanced communication tool with event-driven functions. Compared with serial communication programs compiled in assembly or C language in DOS environment and serial communication programs compiled in Visual C in Windows environment, when using the MSComm control of Visual Basic to implement serial communication, programmers only need to care about the interface of the MSComm control to the API function of the Windows communication driver. In other words, they only need to set and monitor the properties and events of the MSComm control.
There are two main methods to implement serial communication using VB: one is to call Windows API communication function; the other is to use VB communication control (MSComm). This article adopts the second method, that is, using communication control plus a timer control (Timer) to implement simple serial communication.
References:
[1]. TTL datasheet http://www.dzsc.com/datasheet/TTL_1174409.html.
[2]. MAX232 datasheet http://www.dzsc.com/datasheet/MAX232_1074207.html.
[3]. RS- 232 datasheet http://www.dzsc.com/datasheet/RS-232_584855.html.
[4]. MAX485 datasheet http://www.dzsc.com/datasheet/MAX485_859396.html.
Previous article:Introduction to the structure and principle of virtual oscilloscope spectrum analyzer F-24U
Next article:Analyzing broadband and pulsed signals with the new R&S FSW85
- Popular Resources
- Popular amplifiers
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- In what situations are non-contact temperature sensors widely used?
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- 【2022 Digi-Key Innovation Design Competition】Material Unboxing
- DCDC isolated voltage regulated power supply module supports electric vehicle transmission and conversion, and configures high power supply system!
- Programmable linear constant current source circuit leakage current type: based on PAC chip GP8102, GP8202
- 1.2 PB Raspberry Pi Disk Array
- TI's GaN high-efficiency 1MHz CrM totem-pole PFC converter reference design
- Popular Science | Power Management Knowledge
- C Language Zone (4) Continuously Printing Dynamics
- The difference between multilayer PCB and LTCC
- Circuit output grounding problem.
- When AD software needs to drill vias to connect the network in the inner electrical layer segmentation, what is the minimum distance between the vias and the inner electrical layer segmentation edge?