4520 views|2 replies

224

Posts

0

Resources
The OP
 

Simulate serial port infrared transmitter [Copy link]

I haven't posted anything on the forum for a long time , so I'll share a method for sending infrared data that I used in a recent project. This solution is not suitable for sending and receiving infrared data encoded as RC5 or NEC , but is suitable for sending and receiving pure data.

Without further ado, there is nothing special about the infrared transmitting and receiving circuits. Both infrared transmitting and receiving use 38K carrier mode, and receiving uses VS1838B . When VS1838B receives a 38K carrier signal, IR_OUT will output a low level, and when no signal is received, it will output a high level. The circuit is shown below:

IR_IN should be connected to the PWM signal output pin, and IR_OUT should be connected to the serial port receiving pin. Since the serial port is used to receive infrared signals, the serial port must be used to send infrared signals. I use the IO port to simulate the serial port, and this IO port must be a PWM signal output pin.

Next, let's talk about the principle of infrared signal transmission. First, the single-chip hardware needs to have two timers, one of which must have a PWM output function and be configured as a signal with a frequency of 38KHz and a duty cycle of 50% . Since the serial port is used for transmission, the baud rate is of course required. At present, the baud rate I use is 600 , which has a good effect. It is recommended not to set the baud rate to more than 1200 , otherwise the transmission distance will become shorter; the lower the baud rate, the greater the transmission distance. Another timer is used for precise delay, which is used for the transmission delay of each data bit, T = 1000 / baud rate. Different single-chip microcomputers have different characteristics, so the value of T will have co-deviation. Fine-tuning the T value will have better results.

Finally, let's talk about the data transmission method. The serial port data transmission format here is: use 8 data bits, 1 stop bit, no parity bit, and the low bit is sent first. When the data bit is 1 , the carrier signal is not sent (turn off the PWM signal output); when the data bit is 0 , the carrier signal is sent (turn on the PWM signal output). After the transmitted signal is processed by VS1838B , it will get high and low level signals, and finally be parsed out by the serial port. The receiving end sometimes receives some garbled codes. I use double-byte transmission here. The first byte is used for identification and the second byte is data. This will have a better effect. There is another method of data transmission: a hardware serial port is required, and the serial port baud rate setting must not be higher than 1200 ; a timer is also required for PWM signal output, which is also used for 38K carrier generation; an analog switch chip is also required to control the PWM signal output. In this way, just fill the data into the serial port and it can be sent. The circuit is as follows:

At the end of the article, there is the infrared data transmission code, which you can refer to. I will not upload the receiving part, just set the serial port to receive mode, and the baud rate, data bit, stop bit, etc. are consistent with the sending end. Well, you can try it yourself and see if you can DIY a new function .


This content is originally created by EEWORLD forum user ilovefengshulin . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

UART_IR.rar

6.08 MB, downloads: 700

This post is from stm32/stm8

Latest reply

Hello, your 38K seems to be incorrect.  Details Published on 2021-5-17 21:32
 

1

Posts

0

Resources
2
 
Hello, your 38K seems to be incorrect.
This post is from stm32/stm8
 
 

224

Posts

0

Resources
3
 

Yes, I have used it in my project, no problem. This solution is not suitable for sending and receiving infrared data encoded as RC5 and NEC, but is suitable for sending and receiving pure data.

This post is from stm32/stm8
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list