Do-it-yourself IR receiver, trainable. A simple DIY remote control system for IR beams. Using TSOP as a sensor

Hi all! Here we will talk about how to make the simplest IR control (). You can even control this circuit with a regular TV remote control. I warn you right away, the distance is not great - about 15 centimeters, but even this result will please a beginner in the work. With a homemade transmitter, the range doubles, that is, it approximately increases by another 15 centimeters. Making the remote control unit is simple. We connect the IR LED to the 9-volt “crown” through a 100-150 ohm resistor, while installing a regular button without locking, glue it to the battery with electrical tape, and the electrical tape should not interfere with the infrared radiation of the IR LED.

The photo shows all the elements that we need to assemble the circuit

1. Photodiode (almost any one is possible)
2. Resistor for 1 ohm, and for 300-500 ohms (For clarity, I placed resistors for 300 and 500 ohms in the photo)
3. Trimmer resistor for 47 kom.
4. Transistor KT972A or similar in current and structure.
5. You can use any low-voltage LED.

Schematic diagram IR control receiver on one transistor:


Let's start making a photodetector. His diagram was taken from one reference book. First we draw the board with a permanent marker. But you can do this even by hanging installation, but it is advisable to do it on PCB. My board looks like this:


Well, now, of course, let's start soldering the elements. Soldering the transistor:



Solder a 1 kOhm resistor (Kilohm) and a construction resistor.


And finally we solder the last element - this is a 300 - 500 Ohm resistor, I set it to 300 Ohms. I placed it on the back side of the printed circuit board, because he did not allow me to place it on the front side, because of his mutation paws =)


We clean the whole thing with a toothbrush and alcohol in order to wash off the remaining rosin. If everything is assembled without errors and the photodiode is working properly, it will work immediately. A video of this design in action can be seen below:

In the video, the distance is small, since you had to look at both the camera and the remote control at the same time. Therefore, I could not focus the directions of the remote control. If you put a photoresistor instead of a photodiode, it will react to light, I have personally verified that the sensitivity is even better than in the original photoresistor circuits. I supplied 12V to the circuit, it works fine - the LED lights up brightly, the brightness and sensitivity of the photoresistor is adjusted. Currently, using this circuit, I am selecting elements so that I can power the IR receiver from 220 volts, and the output to the light bulb is also 220V. Special thanks for the diagram provided: thehunteronghosts . Material provided by:

Spy and security equipment

Radio 1 magazine, 2 issue 1998
Y. VINOGRADOV, Moscow

When laying wire lines turns out to be impossible, and the use of radio is difficult for one reason or another, infrared (IR) technology is often turned to when creating security systems. This article describes IR transmitter, which can be made by a radio amateur who does not have much experience in designing this kind of devices, Description of the IR receiver and useful tips The editors plan to publish information on organizing an IR communication line in one of the subsequent issues of our magazine.

Large interference in radio channels permitted in Russia for security systems (26,945 kHz and 26,960 kHz), ease of blocking, various administrative and financial obstacles that arise when using radio in devices burglar alarm, force us to look for other means of wireless communication. With the advent of semiconductor emitters capable of generating powerful IR flashes, this possibility has become a reality.

IR transmitter circuit

A clock generator operating at a frequency of 32,768 Hz is assembled on elements DD1.1 and DD1.2. DD3 is a counter, at output 11 of which there are pulses with a frequency of 16 Hz, and at output 14 - 2 Hz. Elements DD2.1-DD2.4 form a switch. At its output (DD2.4) pulses appear with a frequency of 2 or 16 Hz, depending on the voltage level at pin 5 of the DD2.1 element.

In standby mode, the security loop is closed and pin 5 of DD2.1 is low. A high level from the output of element DD2.2 allows the passage of pulses with a frequency of 2 Hz through element DD2.3. The output of DD2.1 is also high, so the pulses also follow through the element DD2.4. When the security loop breaks, a high level appears at pin 5 of DD2.1 and pulses with a frequency of 16 Hz pass through this element. The output of element DD2.2 is low, so the passage of pulses through DD2.3 is prohibited. The output of DD2.3 is high, and pulses with a frequency of 16 Hz pass through the element DD2.4. The P1C1 circuit eliminates the influence of interference on the security loop.

The differentiating circuit Р5СЗ and elements DD1.4-DD1.6 form short pulses with a duration of 10 μs from the meander coming from the output DD2.4. The current arising in the collector circuit of transistor VT1 excites the IR diode BI1, and short IR flashes are emitted into space. So, the transmitter always emits something: either rare pulses, if there is no reason for alarm, or frequent ones in alarm mode.

The most important parameter of an IR transmitter, like any element of security equipment, is its efficiency in standby mode. In table Figure 1 shows the dependence of the current consumed by the transmitter, Ipot, on the power supply voltage Upit. In the alarm signal transmission mode, Ipot increases by approximately 10%.

Low power consumption allows you to insert a backup power source directly into the transmitter housing without increasing its dimensions. These could be, for example, six-volt batteries GP11A, E11A (diameter 10.3 and height 16 mm) or GP476A, KS28, K28L. (diameter 13 and height 25 mm), etc. The duration of continuous operation with such a source will be several hundred hours. Shown in table. 1, the dependence of the current through the IR diode Iimp on the supply voltage allows us to judge the power of the IR flashes emitted by the transmitter, and, accordingly, its “range”.

The transmitter printed circuit board is made of double-sided foil fiberglass laminate with a thickness of 1.5 mm. In Fig. 2a shows the configuration of the conductors, and in Fig. 2b shows the placement of parts. The foil on the parts side (shown in blue) is used only as a common wire. The places where the leads of resistors, capacitors, etc. are soldered to it are shown as blackened squares, and the connections of the “grounded” pins of the microcircuits or the positions of the wire jumpers are shown as squares with light dots in the center.

A hole is drilled in the center of the board for the IR diode, its leads are soldered to the corresponding broadenings on the printed conductors on an overlay.

Capacitors C1, C2, C5 are of the KM-6 type (terminals in one direction), and SZ - KM-5a (terminals in different directions). Electrolytic capacitors C4 and C6 are of any type, but the diameter of capacitor C6 should be no more than 10 mm. All resistors are MLT-0.125.

Commercially available IR diodes are designed to operate in devices remote control household radio devices and have a fairly wide radiation pattern - up to 25...300. To increase the “range” of such an emitter, you need to use a condenser lens (Fig. 3). Here: 1 - printed circuit board; 2 - IR diode; 3 - transmitter housing (impact-resistant polystyrene 2...2.5 mm thick); 4 - holder of a standard five-fold hour magnifying glass (it should have a “x5” icon on it); 5 -lens. The magnifying glass is glued to the front wall of the case, in which a hole with a diameter of 30...35 mm is made. Glue - pieces of polystyrene dissolved in solvent 647. They also use it to glue the body itself. With the distance indicated in the drawing between the base of the magnifying glass and printed circuit board The IR diode appears approximately at the focus of the lens and the transmitter radiation is compressed into a narrow beam. This greatly increases the power of the IR signal at the other end of the communication line.

When placing the transmitter, you need to remember about the very narrow directional pattern of its radiation - the mounting unit must allow precise aiming of the transmitter and its rigid fixation in the best position. You can use, for example, a hinged head from a camera or movie camera, installing it on a wall, window frame, etc. Or you can make this unit as shown in Fig. 4. The fastening unit consists of a piece of copper wire with a diameter of 1.5..2.5 mm with brass circles soldered at the ends (these could be, for example, old five-kopeck coins). One of them is attached with screws to the side wall of the emitter (the thread is in the wall), the other is attached to the support. The wire is bent so that the emitter takes the desired position. To avoid significant vibrations, the wire should be shorter.

Tests have shown that with a supply voltage of 6 V, the transmitter is capable of providing communication at a distance of 70 m. But this is not the limit. The dependence of the distance r on the current Iimp, all other things being equal, has the form: r = KVIimp where K is a coefficient taking into account “other conditions”. Thus, at Upit = 10 V r = 100 m. The current in the IR diode can be increased by selecting resistor R7: Iimp = (Upit-4)/R7. But this must be done with caution: in any combination of Upit and R7, the current amplitude in the IR diode should not exceed 2 A to avoid damage. Unfortunately, the maximum permissible value of the pulse current in IR diodes has to be established experimentally; as a rule, this information is not available in the reference literature.

A significant increase in the power of IR pulses can be achieved by using an IR diode of the AL123A type and rebuilding the “high-current” part of the amplifier as shown in Fig. 5. In this case, a pulse current Iimp = 10 A can be obtained - permissible for an IR diode of the AL123A type. Resistor R4 is homemade, wound from wire with high resistivity. The length of the wire is determined using a digital ohmmeter or in accordance with the table. 2. The amplitude and shape of the current exciting the IR diode is controlled by connecting an oscilloscope to resistor R4. The emitting head can be manufactured as a separate block. Printed circuit board powerful amplifier shown in Fig. 6. All other elements of the IR emitter can be included in electronic part security system as a fragment connected to the IR head with a three-wire cable.

IR receiver circuit

The schematic diagram of the IR receiver is shown in Fig. 7. The DA1 microcircuit converts current pulses arising in the BL-1 photodiode under the influence of IR flashes into voltage pulses. A one-shot device made on elements DD1.1 and DD2.1 expands this pulse to tф1 = 5 ms (tф1 - R2С5). One-shot DD1.3, DD2.3 generates a pulse with a duration tф2= 1.5 s (tф2~ R4С6), allowing unhindered counting of pulses by the counter DD3 only in this time interval. Assembled on elements DD2.5 and DD2.6 sound generator.

The receiver is activated by the front of the first IR flash. The one-shot DD1.1, DD2.1, as well as the one-shot DD1.3, DD2.3 are launched. At the same time, the DD2.2C7R6 circuit generates a pulse at the R input of the DD3 counter (its duration is tR = 7 μs, tR - R6C7). setting the counter to the zero state As soon as the one-shot DD1.1, DD2.1 operates, a low level appears at the output of element DD1.1 and the first counting pulse arrives at counter DD3.

If the photodetector receives pulses with a frequency of 2 Hz (with this frequency, we recall, IR flashes follow in standby mode), then output 4 of the DD3 counter remains low, since the front of the fourth pulse (it will appear after 0.5x4 = 2 s - at the end of the counting-permitting interval tф2= 1.5 s) DD3 will be returned to the pre-start state (diagram 4 in Fig. 8).

The receiver behaves differently if it receives IR pulses with a repetition period of 62.5 ms, i.e. an alarm signal. Since four periods of 62.5 ms each is 250 ms, which is significantly less than the interval tf2 = 1, 5 s, then the fourth pulse will move the DD3 counter to state “4” (high level at pin 5). The counter in this state will be blocked (due to the low level at output DD1.2), the HL1 LED will turn on and the sound generator will emit an intermittent signal. This will continue for approximately 1.25 seconds, after which there will be a 0.25 second pause and the alarm will repeat.

When the connection is lost, the receiver behaves differently. If the receiver does not detect an IR flash within about 1.5 s, capacitor C8 is discharged through the VD6R11DD2.3 circuit. Transistor VT1 enters saturation, the voltage across resistor R8 increases to the supply voltage, output DD1.4 is set to a low level, and the sound generator emits tone frequency 1 kHz. With the appearance of the first IR flash, capacitor C8 will quickly charge through the R10VD5 circuit, the tone signal will stop and the receiver will begin to analyze the incoming signals.

The receiver printed circuit board (Fig. 9) is made of double-sided foil fiberglass laminate with a thickness

1.5 mm. The photo head of the IR receiver (photodiode BL1, microcircuit DA1, etc.), which is highly sensitive to electrical interference in a wide range of frequencies, must be shielded. The screen is made of tin, its cutting is shown in Fig. 10. The folds are shown with dashed lines. The bent screen is soldered in the corners and, having been installed in the desired position on the board, soldered to it at two or three points.

Appearance The IR receiver is shown in Fig. 11. Structurally, the receiver can be designed as shown in Fig. 12. Here: 1 - receiver body (black polystyrene 2...215 mm thick): 2 - holder of a seven-fold hand magnifying glass (handle cut off); 3 - its lens; 4 - printed circuit board; 5 - photodiode. The magnifying glass clip is glued to the front wall of the case, which has a hole with a diameter of about 35 mm (the glue is polystyrene pieces dissolved in solvent 647). The distance between the coaxial photodiode and the lens should be close to the focal length of the lens. This will concentrate the incoming light flux on the photodiode and significantly increase the sensitivity of the photodetector to weak signals.

The housing must provide space to accommodate the piezo emitter BF1 and the LED HL1. The receiver mounting assembly is subject to the same requirements as the transmitter mounting: convenient aiming and reliable fixation in the best position must be ensured.

If, according to communication conditions, the IR receiver must be placed outside (for communication, for example, with a car parked at the end of the house), then in order to avoid side light from extraneous sources that can reduce sensitivity, the lens is

The lens hood needs to be pulled up. This could be, for example, a piece of plastic or metal tube 100...150 mm long, blackened inside, and having a suitable internal diameter. In this case, measures must be taken to protect the entire structure from moisture.

The warning devices (piezo emitter, LED) and power source are, of course, left indoors. But in an “all-weather” version, it is better to make an IR receiver of two parts: the outer one, in which only the lens and photo head are placed in a waterproof housing-hood, and the inner one with everything else. These parts are connected with a thin three-wire cable.

If necessary, the receiver can be supplemented with an acoustic emitter of higher power, for example, a dynamic head, turned on as shown in Fig. 13, or piezo siren AST-10 (Fig. 14). The piezo siren retains sufficient power even at a reduced supply voltage (for it to emit a nominal 110 dB, the supply voltage of this unit must be increased to 12 V).

As preliminary tests have shown, the length of the IR communication line with such a receiver and transmitter reaches 70 m. A significant increase in it can be achieved by switching to tunable optics - if instead of fixed lenses with their approximate focusing, lenses from old cameras with focusing are used. The divergence angle of the rays in the lens of the IR transmitter, its so-called aperture, must be at least 25...300 along the IR diode blade, then the lens uses its radiation completely. In a receiver, the diameter of the lens is more important - as it increases, the distance from which the IR flash of the emitter can be detected increases. The "range" of the transmitter can be increased by another 1.5...2 times or more by increasing the brightness of the IR flash.

On the other hand, in communication lines not exceeding 20...25 m (a car or a “shell” under the windows of a three- or four-story building, a house on the other side of the street, etc.), optics may not be required at all, during at least in the IR receiver.

It’s more convenient to listen to music and watch movies on the computer if you are not on a chair in front of the monitor, but on the sofa, and you don’t need to get up to control it, you just need to press a button on the remote control. But where can I get the remote control with the receiver? You can buy it in a store, but the cost of such a kit is quite high. However, fortunately, making an IR receiver for any remote control (almost) is quite simple.

You will need:

  • IR receiver TSOP1738;
  • com port cable;
  • resistors 10 KOhm, 4.7 KOhm;
  • silicon diode (any);
  • capacitor 10 uF 16 V;
  • wires.

DIY IR receiver

The TSOP1738 photodiode at the output produces ready-made bits that are sent to the com port, so we do not need to solder complex circuits using controllers.

As you can see, nothing complicated. The receiver circuit is so simple that it can be assembled using a canopy. This assembly used a KD105G diode. As you can see in the photo, the anode is marked with yellow paint. If you use a different diode, then you need to find out the polarity from reference books. You should also observe the polarity of the capacitor (the negative terminal is marked on the body).

Back side.

Solder the other end of the wire to the com port connector.

To reduce the size of the diagram, you can carefully bend it. Make sure that the leads and the parts themselves do not come into contact with each other, otherwise a short circuit will result.

You can fill it with epoxy resin or, as in this case, Glue Gun plastic. This will protect the device from external influences.

A single-channel receiver module with a relay, to be triggered by any standard infrared remote control, provides remote control of any load via an invisible IR channel. The project is based on PIC12F683 microcontroller and TSOP1738 is used as the infrared receiver. The microcontroller decodes the RC5 serial design data coming from the TSOP1738 and provides output control if the data is valid. The output can be set to various desired states using a jumper on the board (J1). There are 3 LEDs on the printed circuit board: power indicator, transmission presence and relay activation. This circuit works with any RC5 remote control for a TV, center, etc.

Features of the circuit

  • Receiver power supply 7-12V DC
  • Receiver current consumption up to 30 mA
  • Range up to 10 meters
  • RC5 signal protocol
  • Board dimensions 60 x 30 mm

Although in Lately It has become fashionable to use a radio channel, including Bluetooth; making such equipment yourself is not at all easy. In addition, radio waves are subject to interference, and it’s easy to intercept them. Therefore, the IR signal will be preferable in some cases. Firmware, drawings printed circuit boards and full description in English -

Yakorev Sergey

Introduction

There are many on the Internet simple devices based on controllers of the PIC16F and PIC18F family from Microchip. I bring to your attention a rather complex device. I think this article will be useful to everyone who writes programs for the PIC18F, since you can use the source code of the program to create your own real-time system. There will be plenty of information, starting from theory and standards, ending with hardware and software implementation of this project. The assembler source codes are provided with full comments. Therefore, it will not be difficult to understand the program.

Idea

As always, everything starts with an idea. We have a map of the Stavropol Territory. There are 26 districts of the region on the map. The size of the map is 2 x 3 m. It is necessary to control the illumination of the selected areas. Control must be carried out remotely via an infrared control channel, hereinafter referred to simply as IR or IR remote control. At the same time, control commands must be transmitted to the PC-based control server. When you select an area on the map, the management server displays additional information on the monitor. Using commands from the server, you can control the display of information on the map. The task has been set. In the end, we got what you see in the photo. But before all this was realized, we had to go through some stages and solve various technical problems.


View from the installation side.

Device operation algorithm

From the remote control, the information display control system should be no more difficult than selecting a program on TV or setting a track number on a CD. It was decided to take a ready-made remote control from a Philips VCR. The selection of a district number is set by sequentially pressing the remote control buttons “P+”, then two numeric buttons for the district number, ending with “P-”. When you select an area for the first time, it is selected (the LED backlight turns on), and when you select it again, the selection is removed.
Protocol for managing the card from the PC control server.

1. Outgoing commands, i.e. commands coming from the device to the PC:

1.1. When you turn on the power on the device, the PC receives the command: MAP999
1.2. When turning on an area: MAP(area number)1
1.3. When turning off an area: MAP(area number)0
1.4. When the entire map is turned on: MAP001
1.5. When turning off the entire map: MAP000

2. Incoming commands:

2.1. Enable entire map: MAP001
2.2. Turn off entire map: MAP000
2.3. Include area: MAP(area number)1
2.4. Disable area: MAP(area number)0
2.5. Receive information about included areas: MAP999 In response to this command, data about all included areas is transmitted in the format of clause 1.2 (as if all included areas are being turned on again).
2.6. Receive information about disabled areas: MAP995 In response to this command, data about all disabled areas is transmitted in the format of clause 1.3 (as if all disabled areas are switched off again).

When turning off the last enabled area, the command “turn off the entire map” should also be received.
When turning on the last unincluded area, the command “turn on the entire map” should also be received.
The area number is ASCII digit characters (0x30-0x39).

From idea to implementation

Anticipating that making your own housing for the remote control could be a rather difficult problem, it was decided to take a ready-made remote control from a serial device. The IR control command system of the RC5 format was chosen as the basis for the IR control system. Currently, infrared remote control (RC) is widely used to control various equipment. Perhaps the first type of household equipment to use IR remote control was televisions. Nowadays, remote control is available in most types of household audio and video equipment. Even portable music centers Recently, they are increasingly equipped with a remote control system. But household appliances are not the only area of ​​application for remote control. Devices with remote control are quite widespread both in production and in scientific laboratories. There are quite a lot of incompatible IR remote control systems in the world. The most widely used system is the RC-5. This system is used in many televisions, including domestic ones. Currently, different factories produce several modifications of RC-5 remote controls, and some models have quite a decent design. This allows you to get a homemade device with IR remote control at the lowest cost. Skipping the details of why this particular system was chosen, let’s consider the theory of building a system based on the RC5 format.

Theory

To understand how the control system works, you need to understand what the signal at the output of the IR remote control is.

The RC-5 infrared remote control system was developed by Philips for the needs of controlling household appliances. When we press the remote control button, the transmitter chip is activated and generates a sequence of pulses that have a filling frequency of 36 KHz. LEDs convert these signals into infrared radiation. The emitted signal is received by a photodiode, which again converts the IR radiation into electrical impulses. These pulses are amplified and demodulated by the receiver chip. They are then fed to the decoder. Decoding is usually done in software using a microcontroller. We will talk about this in detail in the section on decoding. The RC5 code supports 2048 commands. These teams make up 32 groups (systems) of 64 teams each. Each system is used to control specific device such as TV, VCR, etc.

At the dawn of the development of IR control systems, signal generation took place in hardware. For this purpose, specialized ICs were developed, and now, increasingly, remote controls are made based on a microcontroller.

One of the most common transmitter chips is the SAA3010 chip. Let's briefly look at its characteristics.

  • Supply voltage - 2 .. 7 V
  • Current consumption in standby mode - no more than 10 µA
  • Maximum output current - ±10 mA
  • Maximum clock frequency- 450 KHz

Structural scheme The SAA3010 chip is shown in Figure 1.

Figure 1. Block diagram of the SAA3010 IC.

The description of the pins of the SAA3010 chip is given in the table:

Conclusion Designation Function
1 X7 Button matrix input lines
2 SSM Operating mode selection input
3-6 Z0-Z3 Button matrix input lines
7 MDATA Modulated output, 1/12 cavity frequency, 25% duty cycle
8 DATA Output
9-13 DR7-DR3 Scan outputs
14 VSS Earth
15-17 DR2-DR0 Scan outputs
18 O.S.C. Generator input
19 TP2 Test input 2
20 TP1 Test input 1
21-27 X0-X6 Button matrix input lines
28 VDD Supply voltage

The transmitter chip is the basis of the remote control. In practice, the same remote control can be used to control several devices. The transmitter chip can address 32 systems in two different modes: combined and single system mode. In combined mode, the system is selected first, and then the command. The number of the selected system (address code) is stored in a special register and a command related to this system is transmitted. Thus, to transmit any command, successive pressing of two buttons is required. This is not entirely convenient and is only justified when working simultaneously with big amount systems In practice, the transmitter is more often used in single system mode. In this case, instead of the matrix of system selection buttons, a jumper is mounted, which determines the system number. In this mode, transmitting any command requires pressing only one button. By using the switch, you can work with multiple systems. And in this case, only one button press is required to transmit the command. The transmitted command will refer to the system that is in given time selected using the radio button.

To enable the combined mode, the SSM (Single System Mode) transmitter pin must be applied low. In this mode, the transmitter IC operates as follows: During rest, the X and Z lines of the transmitter are driven high by internal p-channel pull-up transistors. When a button in the X-DR or Z-DR matrix is ​​pressed, the keyboard debounce cycle is initiated. If the button is closed for 18 clock cycles, the “generator enable” signal is fixed. At the end of the debouncing cycle, the DR outputs are turned off and two scan cycles are started, turning on each DR output in turn. The first scan cycle detects the Z address, the second scan detects the X address. When the Z-input (system matrix) or X-input (command matrix) is detected in the zero state, the address is latched. When you press a button in the system matrix, the last command is transmitted (i.e., all command bits are equal to one) in the selected system. This command is transmitted until the system select button is released. When a button is pressed in the command matrix, the command is transmitted along with the system address stored in the latch register. If the button is released before transmission begins, a reset occurs. If the transfer has begun, then regardless of the state of the button, it will be completed completely. If more than one Z or X button is pressed at the same time, the generator will not start.

To enable single system mode, the SSM pin must be high and the system address must be set with the appropriate jumper or switch. In this mode, the X-lines of the transmitter are in a high state during rest. At the same time, the Z-lines are turned off to prevent current consumption. In the first of two scan cycles, the system address is determined and stored in a latch register. In the second cycle, the command number is determined. This command is sent along with the system address stored in the latch register. If there is no Z-DR jumper, then no codes are transmitted.

If the button is released between code transmissions, a reset occurs. If the button is released during the debounce procedure or while the sensor is being scanned, but before the button is detected, a reset also occurs. Outputs DR0 - DR7 have an open drain, and the transistors are open at rest.

The RC-5 code has an additional control bit that is inverted each time the button is released. This bit informs the decoder whether the button is being held down or a new press has occurred. The control bit is inverted only after a completely completed transmission. Scanning cycles are carried out before each sending, so even if you change the pressed button to another during the sending of a parcel, the system number and commands will still be transmitted correctly.

The OSC pin is a 1-pin oscillator input/output and is designed to connect a ceramic resonator at a frequency of 432 KHz. It is recommended to connect a resistor with a resistance of 6.8 Kom in series with the resonator.

Test inputs TP1 and TP2 must be connected to ground during normal operation. When the logic level on TP1 is high, the scanning frequency increases, and when the logic level on TP2 is high, the frequency of the shift register is increased.

At rest, the DATA and MDATA outputs are in the Z-state. The pulse sequence generated by the transmitter at the MDATA output has a filling frequency of 36 kHz (1/12 of the clock generator frequency) with a duty cycle of 25%. The same sequence is generated at the DATA output, but without padding. This output is used when the transmitter chip acts as a controller for the built-in keyboard. The signal at the DATA output is completely identical to the signal at the output of the remote control receiver microcircuit (but unlike the receiver, it does not have inversion). Both of these signals can be processed by the same decoder. Using the SAA3010 as a built-in keyboard controller is very convenient in some cases, since the microcontroller uses only one interrupt input to poll a matrix of up to 64 buttons. Moreover, the transmitter microcircuit allows power supply voltage of +5 V.

The transmitter generates a 14-bit data word, the format of which is as follows:


Figure 2. RC-5 code data word format.

The start bits are for setting the AGC in the receiver IC. The control bit is a sign of a new press. The clock duration is 1.778 ms. As long as the button remains pressed, a data word is transmitted at intervals of 64 clock cycles, i.e. 113.778 ms (Fig. 2).

The first two pulses are the start pulses, and both are logical "1". Note that half the bit (empty) passes before the receiver determines the actual start of the message.
The extended RC5 protocol uses only 1 start bit. The S2 bit is transformed and added to the 6th bit of the command, forming a total of 7 command bits.

The third bit is the control bit. This bit is inverted whenever a key is pressed. In this way, the receiver can distinguish between a key that remains pressed or one that is pressed periodically.
The next 5 bits represent the IR device address, which is sent with the first LSB. The address is followed by 6 command bits.
The message contains 14 bits and, together with the pause, has a total duration of 25.2 ms. Sometimes the message may be shorter because the first half of the S1 start bit is left blank. And if the last bit of the command is a logical "0", then the last part of the message bit is also empty.
If the key remains pressed, the message will repeat every 114 ms. The control bit will remain the same in all messages. This is a signal for the receiver software to interpret this as an auto-repeat function.

To ensure good noise immunity, two-phase coding is used (Fig. 3).

Figure 3. Coding "0" and "1" in RC-5 code.

When using the RC-5 code, you may need to calculate the average current draw. This is quite easy to do if you use Fig. 4, which shows the detailed structure of the parcel.

Figure 4. Detailed structure of the RC-5 package.

To ensure that the equipment responds equally to RC-5 commands, the codes are distributed in a very specific way. This standardization makes it possible to design transmitters that allow control various devices. With the same command codes for the same functions in different devices a transmitter with a relatively small number of buttons can simultaneously control, for example, an audio complex, a TV and a VCR.

System numbers for some types of household equipment are given below:

0 - Television (TV)
2 - Teletext
3 - Video data
4 - Video Player (VLP)
5 - Video cassette recorder (VCR)
8 - Video tuner (Sat.TV)
9 - Video camera
16 - Audio preamp
17 - Tuner
18 - Tape recorder
20 - Compact player (CD)
21 - Turntable (LP)
29 - Lighting

The remaining system numbers are reserved for future standardization or experimental use. The correspondence of some command codes and functions has also been standardized.
Command codes for some functions are given below:

0-9 - Digital values ​​0-9
12 - Standby mode
15 - Display
13 - mute
16 - volume +
17 - volume -
30 - forward search
31 - search back
45 - ejection
48 - pause
50 - rewind
51 - fast forward
53 - playback
54 - stop
55 - entry

In order to build a complete IR remote control based on the transmitter chip, you also need an LED driver that is capable of providing a large pulse current. Modern LEDs work in remote controls when pulse currents about 1 A. It is very convenient to build an LED driver on a low-threshold (logic level) MOS transistor, for example, KP505A. An example of a circuit diagram of the remote control is shown in Fig. 5.

Figure 5. Schematic diagram of the RC-5 remote control.

The system number is set by a jumper between pins Zi and DRj. The system number will be as follows:

The command code that will be transmitted when a button is pressed that closes the Xi line with the DRj line is calculated as follows:

The IR remote receiver must recover bi-phase encoded data and must respond to large, rapid changes in signal strength regardless of interference. The pulse width at the receiver output should differ from the nominal by no more than 10%. The receiver must be insensitive to constant external light. Satisfying all these requirements is quite difficult. Older implementations of an IR remote control receiver, even those using specialized chips, contained dozens of components. Such receivers often used resonant circuits tuned to 36 kHz. All this made the design difficult to manufacture and configure and required the use of good shielding. Recently, three-pin integrated IR remote control receivers have become widespread. In one package they combine a photodiode, a preamplifier and a driver. The output generates a regular TTL signal without padding at 36 KHz, suitable for further processing by the microcontroller. Such receivers are produced by many companies, these are SFH-506 from Siemens, TFMS5360 from Temic, ILM5360 from Integral software and others. Currently, there are more miniature versions of such microcircuits. Since in addition to RC-5 there are other standards that differ, in particular, in the fill frequency, there are integrated receivers for different frequencies. To work with the RC-5 code, you should select models designed for a fill frequency of 36 KHz.

As an IR remote control receiver, you can also use a photodiode with a shaper amplifier, which can be a specialized KR1568HL2 microcircuit. The diagram of such a receiver is shown in Figure 6.

Figure 6. Receiver based on the KR1568HL2 microcircuit.

For the information display control system, I chose an integrated IR remote control receiver. A highly sensitive PIN photodiode is installed in the TSOP1736 microcircuit as an optical radiation receiver, the signal from which is fed to the input amplifier, which converts the photodiode output current into voltage. The converted signal goes to an amplifier with AGC and then to band pass filter, which separates signals with an operating frequency of 36 kHz from noise and interference. The selected signal is fed to a demodulator, which consists of a detector and an integrator. In the pauses between pulses, the AGC system is calibrated. This is controlled by a control circuit. Thanks to this design, the microcircuit does not respond to continuous interference even at the operating frequency. The active output level is low. The microcircuit does not require the installation of any external elements for its operation. All its components, including the photodetector, are protected from external interference by an internal electrical screen and filled with special plastic. This plastic is a filter that cuts off optical interference in the visible range of light. Thanks to all these measures, the microcircuit is characterized by very high sensitivity and a low probability of false signals. Still, integrated receivers are very sensitive to power supply noise, so it is always recommended to use filters, for example, RC. The appearance of the integrated photodetector and the location of the pins are shown in Fig. 7.

Figure 7. RC-5 integrated receiver.

Decoding RC-5

Since the basis of our device is the PIC18F252 microcontroller, we will decode the RC-5 code in software. The RC5 code reception algorithms offered on the network are mostly not suitable for real-time devices, such as our device. Most of the proposed algorithms use software loops to generate time delays and measurement intervals. This is not suitable for our case. It was decided to use interrupts based on the signal decline at the INT input of the PIC18F252 microcontroller, measure the timing parameters using TMR0 of the PIC18F252 microcontroller, the same timer generates an interrupt when the waiting time for the next pulse has expired, i.e. when there was a pause between two sendings. The demodulated signal from the output of the DA1 microcircuit is supplied to the INT0 input of the microcontroller, in which it is decrypted and the decrypted command is issued to shift registers for key management. The decryption algorithm is based on measuring the time intervals between interrupts of the PIC18F252 microcontroller. If you look closely at Figure 8, you will notice some features. So if the interval between interrupts of the PIC18F252 microcontroller was equal to 2T, where T is the duration of a single RC5 pulse, then the received bit can be 0 or 1. It all depends on what bit was before it. This is very clearly visible in the program below with detailed comments. The entire project is available for download and use for personal purposes. When reprinting, a link is required.