Chapter 16 Study of infrared communication and DS18B20 temperature sensor

Publisher:真诚友谊Latest update time:2020-07-24 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

16.1 Basic Principles of Infrared Light

Infrared is an electromagnetic wave with a wavelength between microwaves and visible light, ranging from 760 nanometers to 1 millimeter. It is a non-visible light with a longer waveform than red light. All objects in nature, as long as their temperature is higher than absolute zero (-273 degrees), have irregular motion of molecules and atoms, and their surfaces will continuously radiate infrared rays. Of course, although they all radiate infrared rays, the infrared intensity radiated by different objects is different, and we use this point to apply infrared technology to our actual development.


Infrared emitting tubes are very common and can be seen on our remote controls. They are similar to light-emitting diodes, but they emit infrared light, which is invisible to the naked eye. In Lesson 2, we learned that the brightness of light-emitting diodes increases as the current increases. Similarly, the intensity of infrared emitting tubes increases as the current increases. A common infrared emitting tube is shown in Figure 16-1.

1.JPG

Figure 16-1 Infrared emitting tube


The infrared receiving tube has a PN junction with infrared light sensitivity inside, which is a photosensitive diode, but it only responds to infrared light. When there is no infrared light, the photosensitive tube is not turned on. When there is infrared light, the photosensitive tube is turned on to form a photocurrent, and within a certain range, the current increases with the increase of the intensity of the infrared light. A typical infrared receiving tube is shown in Figure 16-2.

2.JPG

Figure 16-2 Infrared receiving tube


This infrared transmitting and receiving tube pair is used in cars, robot obstacle avoidance and infrared tracking cars. This part is not implemented on our KST-51 development board, but it belongs to the infrared part, so I provide a schematic diagram for everyone to learn, as shown in Figure 16-3.

3.JPG

Figure 16-3 Schematic diagram of infrared obstacle avoidance and tracking


In the schematic diagram of Figure 16-3, both the transmit control and receive detection are connected to the IO port of our microcontroller.

Transmitter part: When the transmission control output is high level, transistor Q1 is not turned on, and infrared transmitting tube L1 will not emit infrared signals; when the transmission control output is low level, transistor Q1 is turned on to allow L1 to emit infrared light.


Receiving part: R4 is a potentiometer, which is the "legendary" sliding rheostat. We adjust this sliding rheostat to give a threshold voltage to pin 2 of LM393. The value of this voltage can be determined according to the actual situation. When the infrared photodiode L2 receives infrared light, it will generate current, and as the infrared light becomes stronger, the current will increase from small to large. When there is no infrared light or the infrared light is very weak, the voltage of pin 3 will be close to VCC. If the voltage of pin 3 is higher than that of pin 2, the receiving detection pin will output a high level after passing through the LM393 comparator. As the light intensity increases, the current increases, and the voltage value of pin 3 is equal to VCC-I*R3, the voltage will become smaller and smaller. When it is smaller to a certain extent, smaller than the voltage of pin 2, the receiving detection pin will become a low level.


When this circuit is used for obstacle avoidance, the transmitting tube first sends an infrared signal, which will gradually attenuate as the transmission distance increases. If an obstacle is encountered, infrared reflection will be formed. When the reflected signal is relatively weak, the infrared light received by the photodiode L2 is relatively weak, the voltage of pin 3 of the comparator LM393 is higher than the voltage of pin 2, and the receiving detection pin outputs a high level, indicating that the obstacle is relatively far away; when the reflected signal is relatively strong, the receiving detection pin outputs a low level, indicating that the obstacle is relatively close.

When used for tracking, there must be black and white tracks. When the infrared signal is sent to the black track, the infrared signal will be absorbed after it is sent out because black has a stronger light absorption capacity, and the reflected part is very weak. The white track will return most of the infrared signal. Usually, a tracking car needs to use multiple infrared modules to detect at the same time, judge the track from multiple angles, and adjust the car according to the judgment results to make it move forward according to the normal tracking.


16.2 Principle of Infrared Remote Control Communication

In the actual communication field, the signals sent out generally have a wide spectrum, and a large amount of energy is distributed in a relatively low frequency band, so it is called a baseband signal. This signal is not suitable for direct transmission in the channel. In order to facilitate transmission, improve anti-interference ability and effectively use bandwidth, it is usually necessary to modulate the signal to a frequency range suitable for the channel and noise characteristics for transmission, which is called signal modulation. At the receiving end of the communication system, the received signal must be demodulated to restore the original baseband signal. You can just learn about this part of the communication principle. If you want to learn more, you can search for "infrared" on 51hei.com and you will find a lot of detailed information.


The infrared communication in the infrared remote control we usually use is usually modulated using a carrier wave of about 38K. Below I will briefly introduce the principle to you. To understand it, let's first look at the principle of the sending part.


Modulation: It is the process of using the signal to be transmitted to control the amplitude, phase, frequency and other parameters of a high-frequency signal, that is, using one signal to load another signal. For example, when our infrared remote control signal is to be sent, it is first modulated by 38K, as shown in Figure 16-4.

4.JPG

Figure 16-4 Infrared signal modulation  


The original signal is a data "0" or a data "1" that we want to send, and the so-called 38K carrier is a square wave signal with a frequency of 38K. The modulated signal is the waveform we finally transmit. We use the original signal to control the 38K carrier. When the signal is data "0", the 38K carrier is sent out without reservation. When the signal is data "1", no carrier signal is sent.


In principle, how do we implement this function from a circuit perspective? See Figure 16-5.

5.JPG


Figure 16-5 Infrared emission principle diagram


For 38K carrier, we can use 455K crystal oscillator, and get 37.91K after 12 frequency division. It can also be generated by time base circuit NE555, or by PWM of single chip microcomputer. When the signal output pin outputs high level, Q2 is cut off. No matter how the 38K carrier signal controls Q1, the vertical branch on the right will not be turned on, and infrared tube L1 will not send any information. When the signal output is low level, the 38K carrier will be released through Q1, and a 38K carrier signal will be generated on L1. It should be noted here that the duty cycle of 38K of most home appliance remote controllers is 1/3, and there are also 1/2, but it is relatively less.


In normal communication, the receiving end must first process the signal through a series of circuits such as monitoring, amplification, filtering, demodulation, etc., and then output the baseband signal. However, the integrated infrared communication receiving head HS0038B has integrated all these circuits together. We only need to connect this circuit to directly output the baseband signal we want, as shown in Figure 16-6.

6.JPG

Figure 16-6 Infrared receiving schematic diagram


Since the gain of the internal amplifier of the infrared receiver is very large, it is easy to cause interference. Therefore, a filter capacitor must be added to the power supply pin of the receiver. The value given in the official manual is 4.7uF. We directly use 10uF here. The manual also requires a 100-ohm resistor to be connected in series between the power supply pin and the power supply to further reduce interference.


The circuit shown in Figure 16-6 is used to receive the waveform sent by the circuit in Figure 16-5. When HS0038 detects a 38K infrared signal, it will output a low level at the OUT pin. When there is no 38K, the OUT pin will output a high level. Then we connect the OUT pin to the IO port of the microcontroller, and through programming, we can obtain the data sent by infrared communication.


Think about it, has the data output from the OUT pin been restored to baseband signal data? So when our microcontroller receives this baseband signal data, how can we determine what data is received and what protocol should we follow? The communication protocols such as UART, I2C, SPI, etc. that we learned before are all baseband communication protocols, while the infrared 38K only modulates and demodulates the baseband signal to make the signal more suitable for transmission in the signal.


Since our infrared modulation signal is half-duplex and only one signal source is allowed in the space at the same time, our infrared baseband signal is not suitable for I2C or SPI communication protocols. We mentioned earlier that although UART has two lines, one line is actually enough for communication, so infrared can communicate in UART. Of course, this communication is not without restrictions. For example, the data sheet of HS0038B states that if HS0038B wants to recognize 38K infrared signals, the 38K carrier must be greater than 10 cycles, which limits the bit rate of our infrared communication baseband signal to no higher than 3800. If the serial port output signal is directly modulated with 38K, the baud rate cannot be higher than 3800. Of course, there are many other baseband protocols that can be modulated using infrared. Below we introduce an infrared communication protocol commonly used in remote controls - the NEC protocol.

[1] [2] [3] [4] [5]
Reference address:Chapter 16 Study of infrared communication and DS18B20 temperature sensor

Previous article:Chapter 17 A/D and D/A Learning
Next article:Chapter 15 Real Time Clock DS1302

Latest Microcontroller Articles
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号