• IR, infrared control, path, installation, travel. Master kit modules with infrared control

    Most modern household electronic equipment has a remote control remote control, using infrared (IR) radiation as a method of transmitting information. The IR data transmission channel is used in some devices of the " " system that we produce.

    Principle of IR information transmission

    Infrared or thermal radiation is electromagnetic radiation, which is emitted by any body heated to a certain temperature. The IR range lies in the region of the spectrum closest to visible light, in its long-wavelength part and occupies the region from approximately 750 nm to 1000 microns. Infrared radiation makes up most of the radiation from incandescent light bulbs, about half of the radiation from the sun. The optical properties of substances in infrared radiation differ from their properties in visible light. For example, some glasses are opaque to infrared rays, and paraffin, unlike visible light, is transparent to IR radiation and is used to make IR lenses. To register it, thermal and photoelectric receivers and special photographic materials are used. The most commonly used source of IR rays, in addition to heated bodies, is solid-state emitters - IR lasers; photodiodes, phorothesistors or bolometers are used for registration. Some features of infrared radiation make it convenient for use in data transmission devices:

    • IR solid-state emitters (IR LEDs) are compact, practically inertia-free, economical and inexpensive.
    • IR receivers are small-sized and also inexpensive
    • IR rays do not distract human attention due to their invisibility
    • Despite the prevalence of infrared rays and high level"background", sources of pulsed noise in the IR region are few
    • Low power IR radiation does not affect human health
    • IR rays are well reflected from most materials (walls, furniture)
    • IR radiation does not penetrate walls and does not interfere with the operation of other similar devices

    All this makes it possible to successfully use the IR method of transmitting information in many devices. IR transmitters and receivers are used in consumer and industrial electronics, computer technology, security systems, long-distance data transmission systems via fiber optics. Let's take a closer look at the operation of consumer electronics control systems (remotes).

    When you press a button, the IR control panel emits a coded message, and the receiver installed in the controlled device receives it and performs the required actions. In order to transmit a logical sequence, the remote control generates a pulse packet of IR rays, the information in which is modulated or encoded by the duration or phase of the pulses that make up the packet. The first control devices used sequences of short pulses, each of which represented a part useful information. However, later, they began to use the method of modulating a constant frequency with a logical sequence, as a result of which not single pulses, but packets of pulses of a certain frequency are emitted into space. The data is already transmitted encoded by the duration and position of these frequency packets. The IR receiver receives this sequence and demodulates it to produce an envelope. This method of transmission and reception is characterized by high noise immunity, since the receiver, tuned to the transmitter frequency, no longer responds to interference with a different frequency. Today, to receive an IR signal, a special chip is usually used that combines a photodetector, an amplifier with a bandpass filter tuned to a specific carrier frequency, an amplifier with AGC and a detector to obtain the signal envelope. In addition to the electrical filter, such a microcircuit includes an optical filter tuned to the frequency of the received IR radiation, which makes it possible to take maximum advantage of the LED emitter, whose radiation spectrum has a small width. As a result of such technical solutions, it became possible to receive a low-power useful signal against the background of IR radiation from other sources, household appliances, heating radiators, etc. The operation of modern IR control devices is quite reliable, and the range ranges from a few meters to 40 meters or more, depending on the implementation option and the level of interference.

    IR signal transmitter

    The IR signal transmitter, IR remote control, is most often powered by a battery or accumulator. Therefore, its consumption should be as low as possible. On the other hand, the emitted signal must be of significant power to ensure long range transfers. Such problems, which are opposite in terms of energy costs, are successfully solved by the method of transmitting short pulse coded packets. Between transmissions, the remote control consumes virtually no energy. The task of the remote controller is to poll the keyboard buttons, encode information, modulate the reference frequency and output a signal to the emitter. Various specialized microcircuits are produced for the manufacture of remote controls, but modern general-purpose microcontrollers such as AVR or PIC can also be used for these purposes. The main requirement for such microcontrollers is the presence of a sleep mode with extremely low consumption and the ability to sense button presses in this state.

    The IR signal emitter emits infrared rays under the influence of excitation current. The current to the emitter usually exceeds the capabilities of the microcontroller, so to generate the required current, a simple one is installed on a single transistor. To reduce losses, when choosing a transistor, you need to pay attention to its current amplification factor - β or h21. The higher this coefficient, the higher the efficiency of the device. Modern transmitters use field-effect or CMOS transistors, the efficiency of which can be considered marginal at the frequencies used.

    The above scheme is not without its drawbacks, in particular, as the battery charge level decreases, the radiation power will decrease, which will lead to a decrease in range. To reduce dependence on the supply voltage, you can use a simple current stabilizer.

    Most transmitters operate at a frequency of 30 - 50 kHz. This frequency range was chosen historically when creating the first similar devices. The area with the lowest level of interference was selected. In addition, restrictions on element base. Later, as equipment with this control method was standardized and distributed, switching to other frequencies became impractical.

    In order to increase the pulse power of the transmitter, and, accordingly, its range, the fundamental frequency signal differs from the meander and has a duty cycle of 3 - 6. Thus, the pulse power is increased while maintaining or even reducing the average power. The pulse current of the LED is selected based on its nameplate values ​​and can reach one or more Amperes. The pulse current in most IR remote controls does not exceed 100 mA. Moreover, since the reference frequency has a low duty cycle and the duration of the encoded message does not exceed 20-30 ms, the average current when the button is pressed does not exceed one milliampere. Promotion pulse current LEDs are associated with reduced efficiency and reduced service life. Modern infrared LEDs have an efficiency of 100-200 mW of emitted energy at a current of 50 mA. The permissible average current should not exceed 10-20 mA. The LED power supply must have an RC filter, which reduces the impact of pulse noise on the microcontroller power supply. The spectrum of LEDs used for IR remote controls of most household equipment has a maximum in the region of 940 nm.

    Duration of a single reference frequency packet for confident reception is no less than 12-15 and no more than 200 periods. When transmitting an encoded message, the transmitter forms a preamble at the beginning, which is one or more packets of the reference frequency and allows the receiver to set the required level of gain and background. Data in an encoded package is transmitted in the form of zeros and ones, which are determined by duration or phase (the distance between adjacent packets). The total duration of an encoded message most often ranges from several bits to several tens of bytes. The order of occurrence, the beginning sign and the amount of data are determined by the format of the parcel.

    IR signal receiver

    An IR signal receiver usually includes an IR radiation receiver itself and a microcontroller. The microcontroller decodes the received signal and performs the required actions. Since the receiver is in most cases installed in equipment with mains power supply, its consumption is not significant. The microcontroller most often performs other service functions in the device and is its central logical device.

    The IR radiation receiver is most often made in the form of a separate integrated module, which is located behind the front panel of the controlled equipment. The front panel has a window transparent to IR rays. As a rule, such a microcircuit has three outputs - power, common and signal output. Manufacturers of electronic components offer IR signal receivers of various types and designs. However, the principle of their operation is similar. Inside such a microcircuit has:

    • photodetector - photodiode
    • integrating amplifier that separates the useful signal from the background level
    • limiter that drives the signal to a logical level
    • bandpass filter tuned to the transmitter frequency
    • demodulator - a detector that extracts the envelope of the useful signal.

    The body of such a receiver is made of a material that acts as an additional filter that transmits IR rays of a certain wavelength. Modern integrated receivers make it possible to receive a useful signal at a background level that is several tens of times higher than it and at the same time sense frequency messages that have only 4 to 5 periods.

    The radiation receiver must be powered with an RC filter to increase sensitivity. The microcontroller produces broad spectrum noise on the power lines, which can affect receiver operation.

    IR data transmission formats

    Various manufacturers of household equipment use different IR control panels in their products. Because the remote must only communicate with a specific device, it generates a data sequence that is unique to its type of equipment. The transmitted data contains, in addition to the control command itself, the device address, verification data and other service information. Moreover, different manufacturers use different ways of generating data sequences and different ways of transferring logical states. The most common methods of encoding bits of information are changing the duration of the pause between packets (interval method) and encoding by a combination of states (biphase method). However, there are ways to encode bits of information with duration, a combination of duration and pause, etc. The most common transmission formats.


    a robot control module was made via the IR channel. This is what I would like to write about in more detail. Because you can find a lot of applications for this.

    Actually, I don’t think there’s any need to explain what IR control is. Now control via Wi-Fi, Bluetooth, ZigBee is more common. But if you need a simple device that can be assembled “on your knees” at minimal cost, then this article is for you. =)


    I will not tie this article to a specific microcontroller, but will describe the general principles of operation of an IR pre-transmitter with an AVR MK.

    1. What you need
    When creating simple IR control, the unspoken standard is to use a Vishay TSOPxxxx receiver and a TSALxxxx diode as the transmitter.

    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 particular difficulties in working with these components. You can write your own transmission protocol, you can already 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. The only nuance is in modulating the carrier frequency and setting the timer.

    2. Schemes
    In order not to make a fuss, we’ll use the TSOP switching diagram from its datasheet:

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

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

    The required frequency can be expressed from the formula:

    OCRn - there will be the desired value, which must be converted into hexadecimal format and written to the OCR1A register (for the case of the ATmega16 MK).

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

    3. A little code
    I wrote the firmware in CodeVision AVR.

    This is what the code for the transmitter will look like:
    #include
    #include

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

    DDRC=0x00;
    PORTC=0xFF;

    TCCR1A=0x40;
    TCCR1B=0x09;
    OCR1AH=0x00;
    OCR1AL=0x84; // Enter the value for your frequency here

    // 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");)/* In in this case when you press the button that hangs on PINC.4, the MK sends the symbol “S”. Which is transmitted to another controller via IR.*/
    };
    }

    I don’t provide the receiver code, because... It takes up a lot of space, but I think it will be enough to understand the general principles of the transmitter code.

    In addition to remote control (although this is already a wide range of applications), you can use this method for obstacle/object passage sensors, and if you have a lot of such sensors, and they operate at the same frequency, then so that they do not illuminate each other, you can transmit different packets.

    I wish you good luck! I will be glad to have any questions/criticism/suggestions;)

    UPD. I decided to post a photo of the remote control itself so that it can be seen that the device works not only like Chinese receivers that connect to a PC. The possibilities are much wider and more versatile.

    When creating a system home automation It is usually difficult to get by with only original actuators, especially when it comes to working in multimedia scenarios and climate control. We can talk here about TVs, projectors, receivers, media players, air conditioners and other equipment. At the same time, it is not always possible to use the “correct” equipment that supports proprietary control interfaces. Most often, this issue is related to financial considerations.

    In some cases you can count on the presence serial interface, which, when implemented correctly, allows for efficient integration of equipment into the system due to the presence of a documented set of commands and support for feedback, for example, to check the status of the device. In this case, you can use the recently described Global Cache devices as an adapter, not forgetting that each client will require an individual control channel.

    There is some hope for implementing control via an IP network in new models, but now in the situation described we often have to deal with control via IR. Infrared remote controls are the standard way to interact with multimedia equipment today. They are easy to use and inexpensive to manufacture, but they also have certain disadvantages.

    The first of these is the need for line of sight from the remote control to the receiver. The second is the inability to individually address devices (if, for example, several identical amplifiers are used). These problems can be overcome by installing an IR transmitter directly on the receiver window of the required device, as is implemented by Global Cache. The third, the importance of which is budget decisions controversial, let's call it the lack of feedback. The fourth, perhaps the most significant, is the absence in most cases of a documented database of IR codes.

    To solve the last problem, several methods are used, which are also difficult to consider ideal. The first option is to use a "learning" device to write codes from your existing remote control. The second is working with a code database prepared in advance.

    The disadvantage of the first method is the inability to receive commands that are not on the remote control. Most often, this problem occurs in multimedia installations, when it is necessary to switch the receiver or TV to a specific input to switch and display the required signal. Given the wide range of inputs, many devices today have only one or two buttons for selecting it brute-force. At the same time, it is impossible to ensure a guaranteed “hit” at the desired input under any initial conditions. This problem can be solved in different ways, for example, by remembering the input or installing additional switches with “correct” control, but this is inconvenient or expensive. A similar remark applies to power management, where almost always there is only a “switch power” function, and not separate buttons on and off. Another nuance in the described scenario is the measurement error, since the modulation frequency is not fixed and the receiver tries to determine it from the incoming signal, so even one command recorded several times may have different codes.

    Working with ready-made code bases is no less problematic. Often they use sorting not by a specific model of device or remote control, but in the form of manufacturer-equipment type-set of codes. Moreover, there may be more than a dozen of the latter, which will require a lot of time for selection and does not guarantee a successful result.

    True, the presence of such databases provides rich information for analyzing the manufacturer’s possible modifications of commands. Here we also mention the existence of various options for recording IR commands and specialized utilities for converting formats. Ideal option in this case, it is worth considering the description of the commands in the original binary format, and not in the form of “digitizations”. Unfortunately, it is quite rare.

    Note that the control of air conditioners has its own characteristics associated with the presence of simultaneous adjustments of several operating parameters, which makes them even more difficult to control via the infrared port.

    It is worth noting that of course no one will guarantee the presence of the functions described above that go beyond the scope of the standard IR control panel. However, the current level of unification in manufacturing electronic devices gives hope for support for commands not presented on the remote control.

    Thus, we see that to implement the required functions it will be necessary to make serious efforts and with some luck everything can work out, but, unfortunately, there are no guarantees. In this material we specific examples Let's talk about solving this problem. We hope that this information will be useful to our readers.

    Global Cache iTach Flex

    In this material, we used the iTach Flex device from the latest generation of compact Global Cache adapters. The model exists in versions for connecting to wired network and Wi-Fi.

    Device for Wi-Fi option, which we tested, has a case with dimensions of just 31x65x13mm (not including cable connectors), allowing you to install it anywhere. The RJ-45 version will be slightly larger due to the connector.

    The body is made of black plastic. Wireless antenna built-in There is a special metal frame for mounting. It is installed with one or two screws, and the adapter simply snaps onto it.

    On the body there is LED indicator status, a button for connecting to a wireless network via WPS and resetting settings, as well as an IR receiver window for training. At one end there is a power input (standard microUSB) and a 3.5 mm multifunctional minijack for connecting Flex Link cables.

    Thanks to the last element, the model turned out to be uniquely versatile. On present moment The following options are supported: serial port, one IR transmitter, one IR blaster, three IR transmitters (one can be a blaster).

    Like the previously reviewed iTach family, the IR blaster is designed for use at long distances (in a room) and can send commands to different devices. A regular IR transmitter is designed to be mounted on the receiver window specific device. Support for managing dry contacts and connecting sensors is expected. In this material, we connected an IR blaster to the adapter, since we needed to control several devices in the room.

    For control, you can use the TCP version familiar from iTach with sending commands to a specific port, as well as the new HTTP API. Setting the basic operating parameters is carried out through the built-in web server.

    Note that Global Cache has its own online database IR codes, sorted by manufacturer and written as commands to be sent to their own adapters.

    LG TV LM66x series 2012 release

    The model is equipped with a large number of video inputs, supports 3D and network connection, and has USB ports. The standard control panel has one button for turning the power on/off and one button for opening the menu for switching sources. In the latter case, confirmation of the operation will be required, and if there is a network connection, media servers will also be present in the list, which makes it impossible to “blindly” install to a given input.

    The minimum set of requirements for a TV included home theater- turning the power on and off using different commands and setting it to a specific input. Additionally, we can talk about the implementation of viewing terrestrial television, where channel selection and volume adjustment will be needed.

    First, we use the sensor built into the iTach Flex to record the codes of the standard remote control. We don’t need all the buttons now; it’s enough to decide only on the main ones. After launching the iLearn program and connecting to the adapter, you need to bring the remote control to the receiver and press the buttons

    Now you can analyze the results. As we can see, each command, if we do not take into account the part “sendir,1:1,1,37914,1,1,” necessary for the adapter itself, has the prefix “341,170,” followed by thirty-two pairs of numbers and the suffix “ 22.1520.341.85.22.3700.” In this case, we will be interested in just these pairs of numbers. They encode the command in binary format, where "22,21," is "0" and "22,63," is "1," with the least significant bit first. Please note that due to the nature of digitization, some numbers may be slightly different, for example “20” instead of “21” or “65” instead of “63”. But this does not change the essence and it is more convenient to immediately bring everything to the same form using search and replace.

    Decoding the instruction gives us four bytes. A similar option, usually called the “NEC protocol,” is used quite often and is a combination of two address bytes, one command byte and its repetition in inverse form (“0” are replaced by “1” and vice versa).

    In particular, for our example we get: 04 FB 44 BB, 04 FB 02 FD, 04 FB 03 FC. Interestingly, here the second byte of the address is the inverse of the first. Then there are two options: knowing the address, compose lines for each of the possible command values ​​and check them on the device - or look for ready-made commands on the network. The second approach leads us to the website, where we can find a manufacturer’s document with a detailed description of the control commands for televisions of series similar in year of release. Comparing the table in it with our records shows a perfect match for the recorded commands. Now we need to find the codes for the operations we require and recode them in the opposite direction into commands for the iTach Flex. For example, from 04 FB C4 3B and 04 FB C5 3A we get, respectively
    "sendir,1:1,1,38004,1,1,341,171,22,21,22,21,22,65,22,21,22,21,22,21,22, 21,22,21,22,65 ,22,65,22,21,22,65,22,65,22,65,22,65,22,65,22,21,22,21,22, 65,22,21,22,21,22 ,21,22,65,22,65,22,65,22,65,22,21,22,65,22,65,22,65,22, 21,22,21,22,1523,341,86 ,22.3800"
    And
    "sendir,1:1,1,38004,1,1,341,171,22,21,22,21,22,65,22,21,22,21,22,21,22, 21,22,21,22,65 ,22,65,22,21,22,65,22,65,22,65,22,65,22,65,22,65,22,21,22, 65,22,21,22,21,22 ,21,22,65,22,65,22,21,22,65,22,21,22,65,22,65,22,65,22, 21,22,21,22,1523,341,86 ,22.3800".

    The final stage is checking the functionality of the commands. It will also help if the found table has an ambiguous match. For this task we use the iTest program.

    For convenience and speed up the process, we installed an IP camera near the TV, which allowed us to monitor the process directly from the computer screen. The check showed that the task was completely completed. The result written in normal text format, you can download.

    Note that the use of ready-made databases may not have given results. For example, in the Global Cache database for LG TVs there are seven sets of commands, with explicit points for switching to a given HDMI input they don't have any. Although, most likely, one of the presented options for selecting an input could work.

    Onkyo HTX-22HD Home Theater Kit

    This task will obviously be more difficult - the model is quite old and not very popular, especially in “serious” installations. However, today it still copes with its task as a multi-channel receiver for a media player. As with the TV described above, there are several tasks here - separate commands for turning the power on and off, selecting a specific input and adjusting the volume. WITH latest problems no - you can just copy the codes for these buttons. But to control the power, one button on the remote control is used, and to select an input, two buttons are used to move to the next and previous input. Also potentially interesting are the functions for selecting the multi-channel audio processing mode.

    First, it’s worth clarifying the situation with the inputs. In this device, like many others in this class, the physical input in the receiver settings is set to correspond to the connected equipment. Factory condition looks like this:

    EntranceFunction
    Coaxial Digital InCD
    HDMI 1VCR/DVR
    HDMI 2CBL/SAT
    Line 1Tape
    Line 2Tuner
    Optical Digital In 1DVD
    Optical Digital In 2Game/TV

    Now, as with the TV, let's record some or all of the commands from the existing remote control through the receiver into the iTach Flex. Here we also see a characteristic beginning in the lines - “sendir,1:1,1,38095,1,1,” as parameters for sending the packet and “341,171,” as a prefix. Next come the familiar thirty-two pairs of NEC protocol numbers, but the suffixes are different. It’s difficult to understand how significant this is, but, just in case, let’s write them down in the worksheet.

    In the case of Onkyo, we have two address bytes and one command byte, which is repeated in inverted form by the fourth byte of the packet. The address is probably somehow connected with the suffix, and in total we were able to count three addresses on the main buttons of the remote control - D2 06, D2 07 and D2 08.

    The option of direct search in such conditions clearly requires too much time. So let's try again to the site mentioned above with information about codes different manufacturers, for TV this helped a lot. Unfortunately, in the files found on this resource we could not find any mention of our particular receiver model, and at first glance there were no similar addresses in the table.

    Data analysis showed that if you compare only the commands and do not take into account the address, you can find similarities. For example, to increase the volume, command 02 is used, to decrease - 03, and to mute the sound - 05. In the table with the same addresses as the volume control, a power-on command (04) was found. Modification of the digitized line with address D2 06 to this command (only a couple of numbers need to be corrected) showed that we were on the right track - the receiver turned on and did not change its state when sent again, being already turned on. The power off command in the document had a different address. So we substituted command 47 into the command line, which has the address D2 07 and a different suffix. This worked too.

    Thus, there was very little time left before finding commands to go to the desired input. However, after carefully reviewing the found document again, a table was found on one of the sheets indicating that the receiver and remote control may have alternative replaceable lists of addresses from certain sets. This was done, apparently, to be able to control similar devices in the same room. So after changing our addresses to D2 6D, D2 6C, D2 AC, we were able to check the correspondence with the digitized data and find all the necessary commands to switch to the desired input. After this, taking into account different suffixes, a table of commands for this device was compiled. You can download it from the link. Note that the logical names of the inputs in it were replaced with physical ones based on the factory settings.

    Dune HD media player

    Taking into account the fact that this series of players supports control over the network (information about the API is provided on the manufacturer’s website), in this case the IR remote control may only require functions of separate on and off. Here the manufacturer made a gift by publishing a corresponding document in the support section, adding to it the necessary on and off commands with codes 00 BF 5F A0 and 00 BF 5F A1, respectively. Note that the operation of the second command depends on the player shutdown mode setting. The device can either go into sleep mode (while maintaining network functions) or turn off completely (before sending an IR command to turn it on).

    After digitizing several remote control buttons in iTach Flex, you can get the required “environment” for our codes - the prefix “sendir,1:1,1,38186,1,1,342,170,” and the suffix “22,1547,342,85,22,3800” . The result after adding direct commands can be viewed in a separate text file.

    Using commands in iRiduim

    After finding the required codes, we will try to use them in the automation project. In the first example we took the iRidium product. Even though it has a built-in Global Cache code base, for the reasons described above, it is recommended to use newly found and verified codes.

    To make it easier to work with commands, you can create your own (custom) database for the required devices. This will allow you to use them in several projects. When creating devices in a new database, you specify the name, manufacturer, type and comment. You can then program any number of commands for the device. In this case, you do not need to enter the entire code into the parameters, but only the main part after the frequency, number of repetitions and offset. These parameters will already be specified in the properties of the Global Cache transmitter. Note that, despite the formally slightly different frequency, all three devices worked successfully when specifying a common value of 38000.

    After drawing up a project design with buttons and other elements, you can begin programming actions. The easiest way to do this is by dragging a command from the project device tree onto the buttons. To implement continuous adjustment functions (for example, volume), you need to use not only the “Press” action, but also the “Hold” action. Note that for IR control implement quick installation The volume level slider will not work, since there is no feedback from the controlled device in the system, as well as the ability to specify the desired level as a parameter. But for RS-232, a similar scenario can be realized in some cases.

    In this project, we used the simplest version of remote control - each button corresponds to its own command. But the iRidium system allows you to implement more complex scenarios, for example, you can assign one button to turn on the “Watching a movie” scenario, including appropriate light control, turning on all devices participating in the scenario (and turning off interfering ones), the necessary switching of inputs and outputs, opening a pop-up window for controlling the media player .

    As such an option, we use samples of the Dune player interface and control panels downloaded from the iRidium website. After combining them in one project, we will set up calling the player control menu from one of the main pages. Moreover, we will add the appropriate IR commands to the launch script to enable and configure audio-video equipment.

    In addition, given that the sound is decoded and output through the receiver, for ease of control, you can replace the volume control commands from the player to the receiver from one page. As we wrote above, there is no feedback here, so all that remains is relative control of the “louder” and “quieter” buttons.

    Conclusion

    Using an IR channel to control audio/video equipment and other equipment may be the only way to automate work with it, especially in the low-cost segment. Despite the obvious disadvantages of this method, the main one in this case being the lack of feedback, this method is quite workable and allows you to implement fairly flexible scenarios. In general, we did not encounter any difficulties in implementing the described options, not counting the search for the required codes.

    The process of finding and putting together the required commands can turn into a confusing research process. Significant assistance here is provided by Internet resources that collect information about the IR codes used. Analysis of the presented data and search for analogies often makes it possible to find the teams necessary to implement the project at a relatively low cost.

    As a control adapter, you can use both the ready-made Global Cache devices mentioned in the material, and other similar models, for example those assembled independently based on microcontrollers, projects for which are widely presented on the Internet. As for integration into the control system, the most convenient option seems to be working via a computer network, but in some situations it will be sufficient local connections via USB or serial port. The network option, in particular, is interesting because it can be used with various software, for example, as part of Fibaro solutions and via the Internet.

    Commutator motor controller chip, IR remote control, NRF24L01 radio module, OKI 120A2, SD Card Module, Commutator motor controller chip, M590E GSM GPRS modem, DS 3231/DS 1307 real time clock, Mini 360 on LM2596 circuit, L293D, sensors distances, Real time clock, HC-SR501, Mini 360 power supply on the LM2596 circuit, L298N controller, HC-SR501, GSM GPRS, M590E GSM GPRS modem, DS 3231/DS 1307 real time clock, Wi-Fi module ESP8266-12E, Card Module, Power supply, Mini 360, L293D, Mini 360 power supply on LM2596 circuit, Radio module, IR remote control, Ethernet shield, Brush motor controller chip, Brush motor controller chip, IR remote control, SD Card Module, NRF24L01 radio module, OKI motor, L293D, Stepper motor, Power supply, L293D, Mini 360 power supply on LM2596 circuit, SD memory card, Ethernet shield, HC-SR501 motion sensor, ESP8266-12E Wi-Fi module, OKI stepper motor 120A2, Stepper motor,

    Data exchange in the infrared range

    To ensure reliable reception and guaranteed protection against interference, signal modulation and coding are used. Data transmission is carried out in the near-visible infrared spectrum. The wavelength in most implemented systems varies between 800–950 nm. The easiest way to get rid of background noise- modulate (fill) the signal when transmitting one of the standard frequencies: 30, 33, 36, 37, 38, 40, 56 kHz. All modern integrated receivers are tuned to these frequencies.

    To ensure sufficient range when transmitting a code sequence, it is necessary to generate a powerful signal. The current through the IR LED can reach 1 A - such currents are quite acceptable in pulse mode, while the average power dissipation should not exceed the maximum permissible specified in the documentation.

    Developed large number specialized chips(SAA3010, GS8489, KS51840, etc.), generating a ready-made code sequence and consuming minimal current in standby mode, which is important when powered by batteries. These microcircuits significantly simplify the design of remote controls (RC). When we press the remote control button, the transmitter chip is activated and generates a code sequence with a specified filling. The LED converts 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.

    The IR remote control receiver must recover data with two-phase encoding and respond to large quick changes signal level regardless of interference. The pulse width at the receiver output should differ from the nominal by no more than 10%. The receiver must also 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 the filling frequency. All this made the design difficult to manufacture and configure and required the use of good shielding.

    IN lately Three-pin integrated IR remote control receivers (SFH5110-xx, TSOP17xx, TFMS5хх0, etc.) have become widespread. In one package they combine a photodiode, a preamplifier and a driver. The output generates a regular TTL signal without padding, suitable for further processing by the microcontroller. Most important parameter when choosing a receiver - fill frequency.

    The internal amplifier of the integrated receiver has a high gain, therefore, to eliminate self-excitation and eliminate the influence of noise in the power supply circuits, it is necessary to use an electrolytic capacitor with a capacity of at least 4.7 μF, connected as close as possible to the VCC pin.

    Connecting the IR Receiver

    We use the TSOP31236 microcircuit as an IR remote control receiver. In one package it combines a photodiode, a preamplifier and a shaper. The output generates a regular TTL signal without padding, suitable for further processing by the microcontroller. The carrier frequency is 36 kHz, the output is inverse, i.e., if there is no signal, a logical “1” comes to the pin, and when a signal appears, it sends a logical “0”.

    Library IRremote

    You can find out the protocol of your remote control and write a sketch to receive the codes sent from the remote control. Fortunately, a universal library has already been written for receiving and processing codes from any remote control - IRremote.

    You can find the library files in the libraries/IrRemote folder of the electronic archive accompanying the book. To use the library in our projects, we will place them in the libraries folder of the Arduino installation directory. The sketch for receiving the code and sending it to the serial port is presented in the example.

    #include

    int RECV_PIN = 11;

    IRrecv irrecv(RECV_PIN); decode_results results;

    void setup()

    Serial.begin(9600);

    irrecv.enableIRIn(); // enable receiver

    void loop()

    if (irrecv.decode(&results))

    Serial.println(results.value, HEX); irrecv.resume(); // get next value

    You can also transmit IR commands. Supported protocols: NEC, Sony SIRC, Philips RC5, Philips RC6. The transmitting IR LED must be connected to pin 3. The sketch for sending the IR code is presented in the example.

    #include IRsend irsend;

    void setup()

    Serial.begin(9600);

    void loop()

    if (Serial.read() != -1)

    for (int i = 0; i< 3; i++)

    irsend.sendSony(0xa90, 12); // Sony TV power code delay(100);

    Sketch for receiving IR remote control codes

    The first task is to get a list of key codes for our remote control.

    Let's define a list of remote control keys for control:

    <>- moving forward;

    <↓>- moving backwards;

    <←>- turn left;

    <→>- turn right;

    <–CH>- increase in speed when moving forward/backward;

    - speed reduction when moving forward/backward;

    <–VOL>- circular movement in place to the left;

    - circular movement in place to the right;

    <0>- stopping the robot.

    Run the sketch from the example and get the codes the necessary keys for your remote control. The code values ​​are output to the serial port.

    #include

    void setup()

    // interrupts for IR

    void loop()

    // processing the click code if(ir_kod>0)

    ir_go(ir_kod); Serial.println(ir_kod); ir_kod=0;

    // get the code sent from the IR remote control void get_ir_kod()

    detachInterrupt(0); // disable interrupt 0 if (irrecv.decode(&results))

    if (results.value > 0 && results.value< 0xFFFFFFFF)

    // 1 second has passed?

    if (ir_time2-ir_time1>1000)

    (ir_kod = ir_dt;ir_time1=ir_time2;)

    else

    ir_kod = 0;

    irrecv.resume();

    Let's write them as constants

    #define FORWARD 1936 //

    #define BACK 3984 // ↓

    #define SPEED_UP 144 //ch+

    #define LEFT 3472 // ←

    #define RIGHT 1424 // →

    #define STOP 2320 // 0 - stop

    We will determine the receipt of a command from the remote control by interrupt 0 (on digital pin2). Upon interruption, the get_ir_kod() procedure is launched, which determines the code coming from the remote control and writes it to the ir_kod variable. The loop() procedure checks the ir_kod variable, and if the variable is non-zero (receiving the code from the remote control), it calls the ir_go() action output procedure. On at this stage- this is the output to the serial port of the action expected by pressing a key.

    This sketch is presented in the example.

    The result of the command from the remote control is displayed on the serial port monitor.

    #include

    // IR receiver input int RECV_PIN = 2;

    IRrecv irrecv(RECV_PIN); decode_results results; unsigned long ir_dt, old_ir; long ir_kod;

    unsigned long ir_time1, ir_time2;

    // IR remote key codes (marmitek)

    #define FORWARD 1936

    #define BACK 3984

    #define SPEED_UP 144 //ch+

    #define SPEED_DOWN 2192 //ch-

    #define LEFT 3472

    #define RIGHT 1424

    #define CIRCLE_LEFT 3216 //vol+

    #define CIRCLE_RIGHT 1168 //vol-

    #define STOP 2320 //0

    void setup()

    // serial port Serial.begin(9600);

    // enable the receiver irrecv.enableIRIn(); ir_time1=0;ir_time2=0;

    // interrupts for IR

    // FALLING – calling an interrupt when the voltage level changes

    // from high (HIGH) to low (LOW) attachInterrupt(0, get_ir_kod, FALLING);

    void loop()

    // processing the click code if(ir_kod>0)

    ir_go(ir_kod); ir_kod=0;

    // get the code sent from the IR remote control void get_ir_kod()

    detachInterrupt(0); // disable interrupt 0

    if (irrecv.decode(&results))

    if (results.value > 0 && results.value< 0xFFFFFFFF)

    ir_dt = results.value; ir_time2=millis();

    // 1 second has passed?

    if (ir_time2-ir_time1>1000)

    (ir_kod = ir_dt;ir_time1=ir_time2;) else

    ir_kod = 0;

    irrecv.resume();

    // activate interrupt procedure 0 attachInterrupt(0, get_ir_kod, FALLING);

    // action based on the received code void ir_go(kod)

    switch(code)

    case FORWARD: // forward direction Serial.print("forward\n");

    break;

    case BACK: // backward direction Serial.print("back\n");

    break;

    case SPEED_UP: // speed++ Serial.print("speed++\n"); break;

    case SPEED_DOWN: // speed-- Serial.print("speed--\n"); break;

    case LEFT: // to the left Serial.print("left\n"); break;

    case RIGHT: // to the right Serial.print("right\n"); break;

    case CIRCLE_RIGHT: // circle to the right Serial.print("circle_right\n"); break;

    case CIRCLE_LEFT: // circle left Serial.print("circle_left\n"); break;

    case STOP: // stop Serial.print("stop\n"); break;

    15:45 20.03.2002

    Three ways to control a computer through any IR remote control. This material contains mainly theoretical information regarding the use of infrared remote controls for televisions and other household appliances to control a computer. Finding a real use for such a feature is not that difficult. You can control the launch of programs; move the mouse cursor and imitate pressing its buttons; simulate pressing keyboard keys; manage WinAmp; turn off and restart the computer.

    Three methods will be considered. All of them require an IR receiver connected to the computer. The last two methods contain primitive circuits that are not difficult to solder yourself.

    Let's start with the simplest option - working through ordinary infrared adapters, which are sold in many stores at prices ranging from 15 to 40 dollars. They are connected via a USB bus or an RS-232 serial port (regular COM port). The last option for our idea looks preferable, because The software reviewed most likely will not work with USB versions adapters. In addition, they cost less. In our case, we used the TEKRAM IRmate IR-210B adapter connected via a COM port. We must immediately warn you that the programs we found and described do not require installing drivers for any adapters. The programs themselves work directly with the COM port. Installed drivers will interfere normal operation. If you use USB versions of adapters, then the situation is the opposite - drivers are required, but, as mentioned earlier, the settings of all programs did not include support for devices of this kind.

    The program is distributed under Shareware terms. In demo mode, only four commands from the remote control can be used. Supports various adapters, including those working via WinLirc (this will be discussed separately). AVerMedia TV-tuner remotes are directly supported. Full list Supported devices can be found on the developers' website.

    The program turned out to be quite easy to use. There is support for the Russian language. Let's begin the description of working with the program with the settings.

    They are located in the "File" menu. Initially, you need to indicate which port the adapter is connected to. For our IRMate 210 there was a note in the program description: it only works at a port speed of 2400 bps. We obey the instructions, otherwise, all settings are quite optimal. The logic of working with this program, as well as with the others too, implies that you must first create a source in the program - the control panel. In our example, we named it "Samsung". Then commands are added to the source, they are located under the name of the remote control. When adding them, the program assigns signals from the remote control to their values. To assign an action to a remote control button, just drag the desired command into the “Triggered commands” window with the mouse and specify everything that is necessary in the “List of Actions” tab. An unregistered version of the program will not allow you to create more than four actions on one diagram.

    Let's start describing how to work with this program by setting it up. When you first launch the program, you will be taken to the "General Config" section of the main menu. Here you need to select the type of adapter you are using. In our case, this is Generic Serial IR Receiver. Next, move to the “Hardware Setup” item.

    Similar to the previous program, right-click in the empty field and select “New Remote Control” from the menu. We called it Samsung. Next, using the right mouse button, we begin to add keys from the IR remote control (“New remote Button”). In the process of identifying the remote control buttons, a problem arose - all the button codes seemed the same to the program. The button code is displayed on the right in the "Signature" window and is a simple set of data read from the COM port. The solution was simple: in the screenshot next to the port indication there is a “Setup” button. It brings up the settings window, where you need to select the second tab called “Device Settings”. In it, set the "IR code length" parameter to a larger value, for example, 32 bytes.
    To assign actions to already defined buttons on the remote control, you need to go to the third section “Actions”. Add our remote control and add the buttons that we defined in the previous section, only now the selection will be from the right-click drop-down menu. Actions for commands are added in the right window.

    By checking the box "Disable OSD" you will get rid of the window that will pop up on the screen when you press this button on the remote control.

    Subjectively, I liked uICE more than PCRemote. But it's better to try both, because... they have several differences. In addition, if you are going to use unregistered versions, then uICE will completely lose its functionality after 30 days, while PCRemote will work with the above-mentioned restrictions.

    Working with homemade IR receivers

    The method discussed above is suitable for those who already have an IR adapter or purchasing one does not cause any difficulties. Otherwise, a simple IR receiver connected via a standard RS-232 port is not at all difficult to build yourself. Moreover, there are many more programs, working specifically with homemade IR receivers. The most popular such program is WinLirc. It would be more correct to call it not a program, but an interface for working with a COM port. This interface is used by all other programs that will be described below.

    This is the interface for the devices described above. He works under Windows control 95/98/ME/NT/2000. Originally created for Unix, so fans of this operating system will find everything they need on this site www.lirc.org. By itself, this program is only capable of receiving and processing signals received from the COM port of our device. In order to perform any actions on the computer using the remote control, other programs are needed, which in turn will receive all the data from WinLIRC. All of the programs described above are capable of working with WinLIRC.

    Version 2.0 came out just the other day. The program is distributed on Shareware terms, but there is free registration for citizens of the former USSR. The program's capabilities are quite wide: from keyboard emulation and WinAmp control to control external devices. All these features appear only after installing the appropriate plugins. All of them are located on the author's website.

    In our case, we will have to work with this program via WinLIRC. Plugins for working with conventional IR adapters, according to the author, are just now being developed. Frankly, I myself did not solder this circuit, so these and further statements are better attributed to the theoretical part. Therefore, it is wiser to continue without unnecessary words provide some annotated references.