Hardware and software setup

Do-it-yourself IR receiver is trained. IR remote control

IR receiver - remote control commands to control household appliances can be easily done using CD4017 decimal counter, NE555 timer and TSOP1738 infrared receiver.

Using this IR receiver circuit, you can easily control your household appliances using the TV remote control, DVD player, or using the remote control circuit described at the end of the article.

IR receiver circuit for remote control

Pins 1 and 2 of the TSOP1738 IR receiver are used to power it. Resistor R1 and capacitor C1 are designed for stable operation and suppression of various interferences in the power circuit.

When IR beams at 38kHz hit the TSOP1738 IR receiver, its output 3 goes low, and when the IR beams disappear, it goes high again. This negative pulse is amplified by transistor Q1, which sends an amplified frequency signal to the input of the CD4017 decimal counter. Counter outputs 16 and 8 are designed to power it. Pin 13 is connected to ground, allowing it to work.

The output of Q2 (pin 4) is connected to the reset pin (pin 15) to make the CD4017 work as a bistable multivibrator. During the first pulse, Q0 goes log 1, the second clock signal causes Q1 to go log 1 (Q0 goes low), and the third clock causes Q0 to log 1 again (Q2 is connected to MR, so the third clock signal resets the counter).

Let's assume the counter has reset (Q0 is high and the rest are low). When you press the remote control button, the clock signal affects the counter, which leads to a high level on Q1. Thus, LED D1 lights up, transistor Q2 turns on and the relay is activated.

When the remote control button is pressed again, a log 1 appears at the Q0 output, the relay turns off and LED D2 lights up. LED D1 indicates when the fixture is on and LED D2 indicates when the fixture is off.

You can use your TV remote control to control it, or you can assemble a separate one according to the diagram below.

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

You will need:

  • IR receiver TSOP1738;
  • com port cable;
  • resistors for 10 KΩ, 4.7 KΩ;
  • silicon diode (any);
  • capacitor 10 microfarad 16 V;
  • wires.

DIY IR receiver

The TSOP1738 photodiode at the output gives 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 with a canopy. In this assembly, a KD105G diode was used. As you can see in the photo, the anode is marked with yellow paint. If you use another diode, then the polarity must be found in the reference books. You should also observe the polarity of the capacitor (the negative terminal is marked on the case).

Back side.

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

To reduce the size of the circuit, it can be gently bent. Make sure that the leads and the parts themselves do not touch each other, otherwise you will get a short circuit.

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

Spy and security equipment

Magazine Radio 1, 2 number 1998
Yu. VINOGRADOV, Moscow

When the laying of wire lines is impossible, and the use of radio is difficult for one reason or another, when creating security systems, they often turn to infrared (IR) technology. This article describes IR transmitter, which can be made by a radio amateur who does not have much experience in designing such devices, Description of the IR receiver and helpful tips on the organization of the IR communication line, the editors plan to publish in one of the subsequent issues of our journal.

Large interference in the radio channels allowed in Russia for security systems (26 945 kHz and 26 960 kHz), the ease of their blocking, various administrative and financial obstacles that arise when using radio in security alarm devices, 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

On the elements DD1.1 and DD1.2, a clock generator is assembled, operating at a frequency of 32,768 Hz. DD3 - a counter, at the output 11 of which there are pulses with a frequency of 16 Hz, and at the 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 at pin 5 DD2.1 - low level. A high level from the output of the element DD2.2 allows the passage of pulses with a frequency of 2 Hz through the element DD2.3. The output of DD2.1 is also high, so the pulses follow through the element DD2.4. When the security loop breaks, a high level occurs at pin 5 of DD2.1 and pulses with a frequency of 16 Hz pass through this element. The output of the element DD2.2 is a low level, so the passage of pulses through DD2.3 is prohibited. At the output of DD2.3 - a high level, and pulses with a frequency of 16 Hz pass through the element DD2.4. The P1C1 circuit eliminates the influence of pickups on the security loop.

The differentiating circuit P5SZ and the 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 the transistor VT1 excites the IR diode BI1, and short IR flashes are emitted into space. So, the transmitter always emits something: either rare impulses, if there are no grounds for alarm, or frequent ones in alarm mode.

The most important parameter of the IR transmitter, as well as any element of security equipment, is its efficiency in standby mode. In table. 1 shows the dependence of the current consumed by the transmitter, Icont, on the voltage of the power supply Upit. In the alarm transmission mode, Iload increases by about 10%.

Low power consumption allows you to enter a backup power supply directly into the transmitter housing without increasing its dimensions. These can be, for example, six-volt batteries GP11A, E11A (diameter 10.3 and height 16 mm) or GP476A, KS28, K28L. (13 mm in diameter and 25 mm high), 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 makes it possible to judge the power of the IR flashes emitted by the transmitter, and, accordingly, its "range".

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

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

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

Commercially available IR diodes are designed to work in remote control devices for household radios and have a fairly wide radiation pattern - up to 25 ... 300. To increase the "range" of such an emitter, it is necessary to use a condenser lens (Fig. 3). Here: 1 - printed circuit board; 2 - IR diode; 3 - transmitter case (high-impact polystyrene 2...2.5 mm thick); 4 - clip of a standard five-time 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 glue the body itself. With the distance indicated on the drawing between the base of the magnifying glass and printed circuit board The IR diode is 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 a very narrow radiation pattern of its radiation - the attachment point must allow precise aiming of the transmitter and its rigid fixation in the best position. You can use, for example, a swivel head from a camera or movie camera, installing it on a wall, window frame, etc. Or you can make this assembly 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 can be, for example, old five-kopeck coins). One of them is fixed with screws to the side wall of the emitter (thread - in the wall), the other - 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 able to provide communication at a distance of 70 m. But this is not the limit. The dependence of the distance r on the current Iimp ceteris paribus has the form: r=KVIimp where K is a coefficient that takes into account "other conditions". Thus, at Upit=10 V r=100 m. The current in the IR diode can be increased by selecting the 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 in order to avoid damaging it. Unfortunately, the maximum allowable value of the pulsed 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 AL123A type IR diode and rebuilding the "high-current" part of the amplifier as shown in Fig. 5. In this case, the current in the pulse Iimp = 10 A can be obtained - permissible for an IR diode of the AL123A type. Resistor R4 - homemade, wound from wire with high resistivity. The length of the wire is determined by a digital ohmmeter or in accordance with the table. 2. The amplitude and shape of the current that excites the IR diode is controlled by connecting the oscilloscope to the resistor R4. The emitting head can be made as a separate unit. Printed circuit board powerful amplifier shown in fig. 6. All other elements of the IR emitter can enter the electronic part of the security system as a fragment connected to the IR head with a three-wire cable.

IR receiver circuit

circuit diagram The IR receiver is shown in fig. 7. The DA1 chip converts the current pulses that occur in the BL-1 photodiode under the action of IR flashes into voltage pulses. The single vibrator, made on the elements DD1.1 and DD2.1, expands this pulse to tf1 = 5 ms (tf1 - R2C5). Single vibrator DD1.3, DD2.3 generates a pulse with a duration tf2= 1.5 s (tf2~ R4C6), allowing unimpeded counting of pulses by the counter DD3 only in this time interval. A sound generator is assembled on the elements DD2.5 and DD2.6.

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

If the photodetector receives pulses that follow with a frequency of 2 Hz (with this frequency, we recall, IR flashes follow in standby mode), then the output 4 of the counter DD3 remains low, since the front of the fourth pulse (it will appear after 0.5x4 = 2 c - at the end of the counting-allowing interval tf2= 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 much less than the interval tf2 = 1, 5 s, then the fourth pulse will transfer the counter DD3 to the state "4" (high level at pin 5). The counter in this state will be blocked (due to the low level at the DD1.2 output), 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 interrupted, the receiver behaves differently. If the receiver does not detect an IR flash for about 1.5 seconds, the capacitor C8 is discharged through the VD6R11DD2.3 circuit. The transistor VT1 enters saturation, the voltage across the resistor R8 rises to the supply voltage, the output DD1.4 is set to a low level, and the sound generator emits a tone signal with a frequency of 1 kHz. will stop and the receiver will begin to analyze the incoming signals.

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

1.5 mm. The photo head of the IR receiver (photodiode BL1, microcircuit DA1, etc.), which is highly sensitive to electrical pickups in a wide frequency range, must be shielded. The screen is made of tin, its cutting is shown in Fig. 10. Places of folds are shown by dashed lines. The bent screen is soldered in the corners and, having installed it 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 made as shown in fig. 12. Here: 1 - receiver body (black polystyrene 2 ... 215 mm thick): 2 - clip of a seven-fold hand magnifier (the handle is cut off); 3 - its lens; 4 - printed circuit board; 5 - photodiode. The holder of the magnifying glass is glued to the front wall of the housing, which has a hole with a diameter of about 35 mm (glue pieces of polystyrene 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.

In the case, it is necessary to provide a place for placing the BF1 piezoelectric emitter and the HL1 LED. The same requirements are imposed on the receiver mount as on the transmitter mount: convenient aiming and reliable fixation in the best position must be provided.

If, according to the conditions of communication, the IR receiver must be taken out into the street (for communication, for example, with a car standing at the end of the house), then in order to avoid side illumination from extraneous sources that can reduce sensitivity, the lens

the lens needs to be hooded. It can be, for example, a segment of a plastic or metal tube blackened inside, 100 ... 150 mm long, having a suitable inner diameter. In this case, measures must also be taken to protect the entire structure from moisture.

Alert devices (piezo emitter, soetodiode) and power source are, of course, left indoors. But in the "all-weather" version, it is better to make an IR receiver from two parts: an external one, in a waterproof case-hood of which only the lens and a photo head are placed, and an internal 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, included as shown in Fig. 13, or piezo siren AST-10 (Fig. 14). The piezo siren maintains sufficient power even at a reduced supply voltage (for its nominal 110 dB to emit, the supply voltage of this node 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 adjustable optics - if instead of fixed lenses with their approximate focusing, lenses from old cameras with focusing are used. The angle of divergence of rays in the lens of the IR transmitter, its so-called aperture, must be at least 25 ... 300 along the petal of the IR diode, then the lens uses its radiation completely. In the receiver, the diameter of the lens is more important - with its increase, the distance from which you can fix the IR flash of the emitter 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-four-story house, a house on the other side of the street, etc.), optics may not be required at all, during anyway in the IR receiver.

Yakorev Sergey

Introduction

AT Internet networks lot simple devices based on PIC16F and PIC18F family controllers from Microchip. I bring to your attention a rather complicated device. I think this article will be useful to everyone who writes programs for PIC18F, since you can create your own real-time system by taking the source code of the program. There will be plenty of information, ranging from theory and standards to hardware and software implementation this project. Assembly source code is 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 map size is 2 x 3 m. It is necessary to control the highlighting of selected areas. Control should be carried out remotely via an infrared control channel, hereinafter simply 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. By 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, it was necessary to go through some stages and solve various technical problems.


View from the mounting side.

Device operation algorithm

From the remote control, the information display control system should be controlled no more difficult than selecting a program on TV or setting a track number on a CD. It was decided to take the remote ready from the Philips VCR. The choice of the number of the district is set by successive pressing of the buttons of the remote control "P +", then two numeric buttons of the number of the district, we finish entering "P-". The first time you select an area, it is highlighted (the LEDs turn on), and the second time you select it, the selection is removed.
Card management protocol from a PC management server.

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

1.1. When the power is turned on on the device, the PC receives the command: MAP999
1.2. When including area: MAP(number of area)1
1.3. When disabling region: MAP(number of region)0
1.4. When including the whole map: MAP001
1.5. When turning off the whole map: MAP000

2. Incoming commands:

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

When turning off the last included area, the command "turn off the entire map" should also be received.
When you include the last non-included area, the command "enable the entire map" must also be received.
The district number is ASCII digit characters (0x30-0x39).

From idea to implementation

Anticipating that it might be a rather difficult problem to manufacture our own case for the remote control, it was decided to take a ready-made remote control from a serial device. The system of IR control commands of the RC5 format was chosen as the basis of the IR control system. Currently, to control various equipment is very widely used remote control(DU) on IR rays. Perhaps the first type of household equipment that used IR remote control was televisions. Now remote control is available in most types of household audio and video equipment. Even portable music centers Recently, more and more often they are equipped with a remote control system. But household appliances are not the only scope of 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 the RC-5 remote controls, and some models have quite a decent design. This allows for the lowest cost homemade device with IR remote. Omitting 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 home appliances. When we press a button on the remote control, the transmitter chip is activated and generates a sequence of pulses that have a fill 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. Then they are fed to the decoder. Decoding is usually done in software by a microcontroller. We will talk about this in detail in the section on decoding. 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 formation of IR control systems, the signal was formed in hardware. For this, specialized ICs were developed, and now more and more remote controls are made on the basis of a microcontroller.

One of the most common transmitter ICs is the SAA3010 IC. Let's briefly consider 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 Operation mode selection input
3-6 Z0-Z3 Button Matrix Input Lines
7 MDATA Modulated output, 1/12 resonator frequency, 25% duty cycle
8 DATA Output
9-13 DR7-DR3 Scan Outputs
14 VSS Earth
15-17 DR2-DR0 Scan Outputs
18 OSC 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 heart of the remote control. In practice, the same remote control can be used to control multiple devices. The transmitter chip can address 32 systems in two different modes: combined mode and single system mode. In combined mode, the system is selected first, and then the command. The selected system number (address code) is stored in special register and a command relating to that system is transmitted. Thus, to transmit any command, successive pressing of two buttons is required. This is not entirely convenient and is justified only when working simultaneously with large quantity 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, only one button press is required to send any command. Using the switch, you can work with several systems. And in this case, only one button press is required to transmit the command. The transmitted command will refer to the system currently selected with the switch.

To enable the combined mode, the output of the transmitter SSM (Single System Mode) must be applied low. In this mode, the transmitter chip 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 is pressed in an X-DR or Z-DR matrix, the keyboard debounce cycle is initiated. If the button is closed for 18 cycles, the "generator enable" signal is fixed. At the end of the debounce cycle, the DR outputs are turned off and two scan cycles are started, turning on each DR output in turn. In the first scan cycle, the Z-address is found, in the second - the X-address. When the Z-entry (system matrix) or the X-entry (instruction matrix) is found to be in the zero state, the address is latched. When a button is pressed in the system matrix, the last command (i.e., all command bits are equal to one) is transmitted 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 starts, a reset occurs. If the transfer has started, 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 transmitter X-lines 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 scans, the system address is determined and stored in a latch. In the second cycle, the command number is determined. This command is sent along with the system address stored in a latch. If there is no Z-DR jumper, then no codes are transmitted.

If the button was released between sending the code, then a reset occurs. If the button is released during the debounce routine or during the sensor scan, but before a button press is detected, then a reset also occurs. Outputs DR0 - DR7 have an open drain, at rest the transistors are open.

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 or a new press has occurred. The control bit is inverted only after a fully completed send. Scanning cycles are performed before each message, so even if you change the pressed button to another during the transmission of the package, the system number and commands will still be transmitted correctly.

The OSC pin is the input/output of a 1-pin oscillator and is designed to connect a ceramic resonator at a frequency of 432 kHz. In series with the resonator, it is recommended to include a resistor with a resistance of 6.8 Kom.

Test inputs TP1 and TP2 must be connected to ground during normal operation. A high logic level on TP1 increases the scan rate, and when high level on TP2 - the frequency of the shift register.

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

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


Figure 2. Data word format of the RC-5 code.

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, the data word is transmitted at 64 clock intervals, i.e. 113.778 ms (Fig. 2).

The first two pulses are start pulses and both are logical "1s". Note that half of the bit (empty) passes before the receiver determines the real start of the message.
The extended RC5 protocol uses only 1 start bit. The S2 bit is transformed and added to the 6th command bit, making 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 is periodically pressed.
The next 5 bits represent the address of the IR device, which is sent with the first LSB. The address is followed by 6 command bits.
The message contains 14 bits, together with the pause, have a total duration of 25.2 ms. Sometimes the message may be shorter due to the fact that the first half of the start bit S1 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 be repeated every 114ms. The control bit will remain the same in all messages. This is a signal for the receiver program 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 the RC-5 code.

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

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 allows you to design transmitters that allow you to 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 household appliances are listed below:

0 - TV
2 - Teletext
3 - Video data
4 - Video player (VLP)
5 - Video Cassette Recorder (VCR)
8 - Video tuner (Sat.TV)
9 - Camcorder
16 - Audio preamplifier
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 - Numerical values ​​0-9
12 - Standby mode
15 - Display
13-mute
16 - volume +
17 - volume -
30 - search ahead
31 - search back
45 - ejection
48 - pause
50 - rewind
51 - fast forward
53 - playback
54 - stop
55 - record

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 operate in remote controls at pulsed currents of about 1 A. It is very convenient to build an LED driver on a low-threshold (logic level) MOSFET, for example, KP505A. An example of a circuit diagram of the console is shown in fig. 5.

Figure 5. Schematic diagram of the RC-5 console.

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

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 control receiver must recover data with bi-phase encoding, it must respond to large, rapid changes in signal level, regardless of interference. The pulse width at the receiver output should differ from the nominal value by no more than 10%. The receiver must be insensitive to constant external illumination. Satisfying all these requirements is not easy. Old implementations of the IR remote control receiver, even with the use of specialized microcircuits, contained dozens of components. These receivers are often used resonant circuits tuned to 36 kHz. All this made the design difficult to manufacture and adjust, 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 shaper. At the output, a regular TTL signal is formed without filling 36 kHz, suitable for further processing by the microcontroller. Such receivers are manufactured by many companies, these are SFH-506 from Siemens, TFMS5360 from Temic, ILM5360 from Integral and others. At present, there are also more miniature versions of such microcircuits. Since there are other standards besides RC-5 that differ, in particular, in the duty cycle, there are integrated receivers for different frequencies. To work with the RC-5 code, you should choose models designed for a duty cycle of 36 kHz.

As an IR remote control receiver, you can also use a photodiode with an amplifier-shaper, which can serve as a specialized microcircuit KR1568KhL2. A diagram of such a receiver is shown in Figure 6.

Figure 6. Receiver on the KR1568HL2 chip.

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

Figure 7. Integrated receiver RC-5.

RC-5 decoding

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 cycles to generate time delays and measurement intervals. This is not suitable for our case. It was decided to use interrupts on the fall of the signal at the INT input of the PIC18F252 microcontroller, measure the time parameters using TMR0 of the PIC18F252 microcontroller, the same timer generates an interrupt when the next pulse timeout has expired, i.e. when there is a pause between two messages. The demodulated signal from the output of the DA1 microcircuit is fed to the INT0 input of the microcontroller, in which it is decoded and the decoded 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 can see 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 which bit was before. In the program below with detailed comments, this is very clearly visible. The entire project is available for download and use for personal purposes. When reprinting a link is required.

An interesting and informative scheme for a beginner radio designer on organizing sound transmission over a distance in the infrared (IR) range of light. A great starter kit for experimenting and building your own optical phone. Do you want to establish a "closed" communication channel, for example, with your friend who lives in direct line of sight in a nearby high-rise? To start designing, this diagram is for you! Below is the process of assembling two base boards - an IR audio transmitter and an IR audio receiver. The sound receiver has a loudspeaker output. Block diagrams, photo assembly of blocks and video demonstration of performance are presented. DIY purchase price Kit set in an online store will not affect your budget in any way.

How to assemble an infrared receiver and sound transmitter with your own hands

Description:
The kit implements the functions of amplitude modulation by electrical signals of the brightness of the infrared LED and the reception of modulated infrared radiation, its conversion into electrical signal, signal amplification to ensure the operation of the connected speaker. The signal transmission range in this embodiment depends on the accuracy of pointing the diodes at each other and can reach several meters without the use of additional optics.

1. Electrical characteristics of the boards of the set
infrared transmitter
Working voltage: 12V
The size printed circuit board: 19*25mm

infrared receiver
Working voltage: 4~12V
Connected speaker power: 0.5W-10W
PCB size: 17*39mm

2. Working principle
IR transmitter: The audio signal is fed through the 3.5mm jack and the electrolytic capacitor C3 to the transistor Q1 type S8050, the transistor modulates the electrical signal, which leads to the modulation of the IR radiation emitted by the LED D2.
IR receiver: IR LED receives radiation, converts it into an electrical signal, the signal through the capacitor C1 is fed to the input of the ULF assembled on the LM386 microcircuit, the signal from the microcircuit is fed to the speaker.





3. List of components

IR receiver

amount
2 × 620 kΩ, 1K resistor R1 and R2 respectively
3 × 0.22uF, 0.1uF and 0.1uF capacitors C1, C4 and C6 respectively
3 × 10 uF, 100 uF and 100 uF capacitors C2, C3 and C7 respectively
1 × Red LEDs D1
1 × IR receiving LED D2
1 ×
1 × speaker terminal block
1 × LM386 chip U1
1 × printed circuit board

IR transmitter

amount Designation and marking of the part on the diagram
2 × 100 Ohm, 51K resistor R1 and R2 respectively
3 × 0.001uF, 100uF and 4.7uF capacitors C1, C2 and C3 respectively
1 × S8050 transistor Q1
1 × Red LEDs D1
1 × IR transmitting LED D2
1 × power supply pin block
1 × 3.5mm audio input jack
1 × Printed circuit board

Assembling the IR receiver and IR transmitter

The design of the circuits is simple, any novice electronics engineer can handle the assembly. When assembling, you must be careful and accurate.

  • it is necessary to check the contents of the packages and their compliance with the specification;

  • determine the resistor values ​​with a tester or by color code;
  • start installing parts and soldering them to the board, when assembling, you must observe the polarity of the installation of the transistor and the microcircuit block are installed by key on the board, see photos and videos;





    Good luck with your assembly and long-range communication in the IR range

Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!