📜 ⬆️ ⬇️

IR remote control


Good day everyone!


As part of my project:
Create a robot at home
The robot control module was made via IR channel. That's about it, I would like to write in more detail. Since this application can be found very much.

Actually, what is IR control - I think it is not necessary to explain. Now control over Wi-Fi, Bluetooth, ZigBee is more common. But if you need a simple device that can be assembled “on the knee” at minimal cost, then this article is for you. =)


I will not bind this article to a specific microcontroller, but I will describe the general principles of operation of the IR transmitter from the AVR MK.
')
1. What is required

When creating a simple IR control, the unwritten standard is to use a Vishay TSOPxxxx receiver and a TSALxxxx diode as a transmitter.

Datasheet on TSOP17xx
Datasheet on TSAL6200

In the designation of TSOP receivers, the last two digits indicate the frequency (in kHz) at which the transmitted signal is perceived. There are no difficulties in working with these components. You can write your transfer protocol, you can use ready-made solutions. In my case, I decided to connect two microcontrollers with an IR channel using USART. The principle is the same as if we connected two MKs with ordinary wires. Nuance only in modulating the carrier frequency and setting the timer.

2. Schemes

In order not to fence gardens, let's use the TSOP inclusion scheme from its datasheet:


TSOP output must be connected directly to the (RX) input of the USART MK.

With the connection of the transmitter, the situation is slightly different. Since the receiver works only at a certain frequency, then you need to set the same frequency on the radiator. It is not difficult to do this by programming the timer. For ATmega16, it will look like this:
TCCR1A=0x40;
TCCR1B=0x09;
OCR1AH=0x00;
OCR1AL=0x84;


The desired frequency can be expressed from the formula:

OCRn - will be the desired value, which must be converted to hexadecimal format and recorded in the register OCR1A (for the case with ATmega16 MK).

Now TSOP will receive our signal. But in order to be able to use USART, you need to modulate our signal. To do this, we connect the IR diode according to the following scheme:


3. Some code

I wrote the firmware in CodeVision AVR.

This is what the code for the transmitter will look like:
#include <mega8.h>
#include <stdio.h>

void main(void)
{
PORTB=0x00;
DDRB=0x02;

DDRC=0x00;
PORTC=0xFF;

TCCR1A=0x40;
TCCR1B=0x09;
OCR1AH=0x00;
OCR1AL=0x84; //

// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Mode: Asynchronous
// USART Baud Rate: 2400
UCSRA=0x00;
UCSRB=0x08;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0xCF;

while (1)
{

if (PINC.4 == 0x00) { putchar('S');}/* , PINC.4 'S'. .*/
};
}


I do not cite the receiver code, because It takes a lot of space, and I think it’s enough for the perception of the general principles of the transmitter code.

In addition to remote control (although this is already a vast area of ​​application), you can use this method for sensors of obstacles / passing objects, and if you have a lot of sensors, and they work on the same frequency, you can send different packets so that they do not light up each other.

Good luck! I will be glad to any question \ criticism \ sentences;)

UPD. I decided to post a photo of the console itself so that it was clear that the device works not only as Chinese receivers that connect to a PC. The possibilities are much wider and more versatile.
Photobucket

Source: https://habr.com/ru/post/82383/


All Articles