Infrared is an electromagnetic wave with a wavelength of 750nm to 1mm. Its frequency is higher than microwaves but lower than visible light. It is a kind of light that is invisible to human eyes. Infrared communication generally uses near-infrared in the infrared band with a wavelength of 0.75μm to 25μm. At present, radio waves and microwaves have been widely used in long-distance wireless communications. However, due to the short wavelength of infrared and poor diffraction ability to obstacles, it is more suitable for applications where short-distance wireless communication is required for point-to-point linear data transmission. From the perspective of application areas, infrared communication is mainly used in remote control and data communication. The general data transmission rate of the infrared communication port can reach 2400bit/s to 115.2kbit/s, and some can even reach 4Mbit/s.
This design realizes communication between single-chip microcomputers through an infrared interface. The two parties in communication agree that the sender is machine A and the receiver is machine B. Machine A sends a set of data to machine B. If the data received by machine B is correct, it sends 0x55 to machine A; if the data received by machine B is incorrect, it sends 0xFF to machine A. After receiving 0xFF, the receiver A retransmits the data.
Infrared communication technology mainly uses infrared transmitters and infrared receivers to complete the wireless transmission and reception of signals. At the transmitting end, the transmitted digital signal is appropriately modulated and sent to the electro-optical conversion circuit to drive the infrared light emitting diode to emit infrared light pulses; at the receiving end, the infrared receiver performs photoelectric inverse conversion on the received infrared signal, and performs corresponding demodulation to restore the original signal, as shown in the figure below.
The hardware circuit of infrared communication consists of two parts: the transmitting circuit and the receiving circuit. As shown in the figure below, the upper part of the figure is the transmitting circuit, and the lower part is the receiving circuit. Of course, as the other party of the communication, there is also a similar set of transmitting and receiving circuits.
Since the light response frequency of the infrared receiving module TSOP1838 used in the system is 38kHz, in order to reduce the bit error rate of data exchange, the carrier frequency of the infrared transmitting part should also be adjusted to 38kHz. The carrier signal is generated by the internal timer of the single-chip computer 89C51. The carrier signal is output from the Pl.0 pin and modulated by the 74HC08 and gate to the data output terminal TXD. After being amplified by the transistor T1, the transmitting tube TSAL6200 emits pulsating infrared light. Its transmission power can be changed by adjusting its current limiting resistor R3.
In order to improve the waveform of the received signal, the infrared receiving circuit will perform two-stage inversion shaping on its output signal. The purpose of using an AND gate in this receiving circuit is that if the system has other communication interfaces, the data receiving end of the communication interface can also send data to the RXD pin through the AND gate. Of course, users can also use the AND gate circuit instead of the second-stage NOT gate to directly connect the output of the RXD pin.
Compared with conventional wired communication, infrared communication only uses different transmission media, so the communication procedure is similar to the above description. The only difference is that infrared communication still has the problem of carrier wave. Therefore, the procedure only includes serial port initialization, timer initialization, timer interrupt service program, communication receiving and sending program, etc.
1. Serial port initialization program init() The
serial port initialization program is as follows. The serial port works in mode 1 with a baud rate of 9600 bit/s. The timer T0 of the microcontroller generates a 38 kHz carrier signal through a timer interrupt, and the T1 timer is used as a baud rate generator.
The program uses timer T0 to generate interrupts of a certain frequency , and controls the pin output high and low levels .
In this way, the carrier signal is generated. The interrupt service program code of timer TO is as follows:
Note: When writing the program, the timing interrupt for generating the carrier frequency is only turned on when sending. When the sending is completed, turn off the interrupt and set Pl.0 to 0.
2. Machine A sends subroutine voidsend()
Machine A sends subroutine send0 to complete the function of machine A sending data. Calculate the checksum and send the data, wait for machine B to respond, if machine B responds correctly, return from the subroutine, otherwise send the data again and wait for machine B to respond. The program code is as follows:
3. The receiving program of machine B voidrecv()
The receiving program of machine B receives data according to the specified communication signal. It receives data and calculates the checksum. If the checksum is correct, it sends 0x55 to indicate that the data is correct. Otherwise, it sends 0xFF to indicate that the data is received incorrectly. The program code is as follows:
When designing and using infrared communication, the following issues should be noted:
Distance and power issues: The distance of infrared communication mainly depends on the intensity (current) of the emission.
·The speed of communication: Since the carrier frequency of the modulation is 38kHz, in order to receive the transmitted signal well, it is recommended that the data transmission rate set by the single-chip microcomputer should not exceed 9600bit/s.
·When using, the angle between the transmitting tube and the receiving tube should be considered. The larger the angle, the closer the receiving distance will be, or even no reception.
·For the simplex mode, the sender only retains the sending part of the circuit, and the receiver only retains the receiving part of the circuit. For example, an active remote control that does not need to return information has only a sending circuit, while a passive receiving controller has only a receiving circuit.
·The carrier frequency can also be obtained by other circuits that can generate oscillating square wave signals, such as the 555 circuit.
·At present, there are also dedicated infrared modules that transmit and receive, transmitting modules that only transmit but not receive, and receiving modules that only receive but not transmit on the market. Most of these modules integrate modulation, drive, demodulation and other circuits. Users only need to choose a good model and master its interface relationship.
Previous article:Using data frames to realize multi-machine communication between single-chip microcomputers
Next article:Serial communication between multiple microcontrollers
- Popular Resources
- Popular amplifiers
- Mission-oriented wireless communications for cooperative sensing in intelligent unmanned systems
- CVPR 2023 Paper Summary: Embodied Vision: Active Agents, Simulation
- ICCV2023 Paper Summary: Fairness, Privacy, Ethics, Social-good, Transparency, Accountability in Vision
- Introduction to Artificial Intelligence and Robotics (Murphy)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- BK3432 development board user guide, BK3432 BLE4.2 chip development board
- EuroPython will be held online on July 26, 2021
- [RISC-V MCU CH32V103 Review] Real-time marking of file creation time
- Ultrasound imaging technology
- The IDMA interface bootstrap design of ADSP-218X
- Use itop4412 development board to compile driver module separately
- Diodes and Potentials
- Application of C language in single chip microcomputer development
- Problems with making the digital tubes flash simultaneously
- EEWORLD University ----TI Precision Labs - Operational Amplifiers: 15 Comparator Applications