Remote control of the Lego Mindstorms robot via JMX and IP Video. What's the difference between Wi-Fi and Bluetooth? What is LEGO® MINDSTORMS®

Does your child dream of building and programming a robot on his own that would follow all his commands? Then we strongly recommend that you turn your attention to the unique series of constructors of the world-famous Danish company Lego Robots.

The Lego Mindstorms series is a special achievement of the Lego company. The thing is that these constructors are based on electromechanics and robotics, which means that they will be of interest to those who have original thinking and good imagination, as well as knowledge and understanding of all the ongoing technical processes. That is why very often the Lego Robots set becomes a favorite toy not only for senior school children, but also a hobby for their dads and even grandfathers.

Buying Lego Mindstorms constructor, you get:

An interesting construction game

Lego Robots is a product that uses the latest technology in the field of robotics. The Lego Mindstorms series toys have multiple motors, additional sensors, and a color display. Lego Robots are able to amaze everyone who encounters them for the first time, because they behave like living beings. Lego Mindstorms respond to touch and sound, and are capable of detecting object temperature and distance. They can come, hearing your cotton, pick up objects that are nearby, and distinguish between darkness and light. All this sounds rather complicated, but practice shows that any child who owns a computer at a user level can easily program a Lego Robot set by creating his own personal robot. Note that commands to the Lego Mindstorms toy can be given not only from a computer, but also from any mobile phonein which Bluetooth is installed.

Huge opportunities for the development of creativity

The Lego Robots set consists of more than 500 parts, which makes it possible to assemble a huge number of different modifications of construction robots: a mythological animal that lives only in your fantasies, a humanoid robot, a car of the future, etc.

Quality product

Before the start of serial production of designers, all their components are tested for strength on test benches. Each Lego Robots element is rated for over 50,000 clutch cycles. For the production of plastic elements of the Lego Mindstorms construction set, heavy metals and other materials harmful to health are not used.

You can talk endlessly about the developmental capabilities of Lego Mindstorms constructors. Lego Robots is not only about getting to know the latest technologybut also their use. Young Lego Mindstorms owners will be incredibly proud and happy when they write and upload their first computer program... And there is no need to talk about the parents' pride in their beloved child, who easily copes with the latest technologies!

An adult toy Lego Robots has already managed to win millions of fans around the planet and every day their number is only growing. Now there are even entire clubs dedicated to Lego Mindstorms constructors, in which people discuss ways to improve the functions of Lego Robots, share their achievements, discoveries, etc.

Buy a Lego set from usMindstorms and create toys that will certainly come to life in your hands!

The article contains a description of the experience of using lego constructor Mindstorms EV3 to create a prototype of a robot with its subsequent program and manual control using the Robot Control Meta Language (RCML).

  • Assembling a prototype robot based on Lego Mindstorms EV3
  • Quick installation and configuration of RCML for Windows
  • Programmed robot control based on the EV3 controller
  • Manual control of robot peripherals using keyboard and gamepad
Running a little ahead, I will add that in order to control a Lego robot using the keyboard, you need to create a program containing only 3 lines of program code. More details on how to do this are written under the cut.

1. To begin with, a prototype robot was created from the Lego Mindstorms EV3 set, which will be used for programming and manual piloting.

Description of the robot prototype

The robot has a design similar to a car chassis. Two motors mounted on the frame have one common rotation axis, which is connected to the rear wheels through a gearbox. The gearbox converts the torque by increasing the angular speed of the rear axle. The steering is assembled on the basis of a bevel gearbox.



2. The next step is to prepare the RCML to work with Lego Mindstorms EV3.

You should download the archives with executable files and library files and.

The downloaded archives must be extracted to a directory with an arbitrary name, but you should to avoid Russian letters in the title.

The contents of the directory after unpacking the archives into it



Next, you need to create a configuration file config.ini, which must be located in the same directory. To be able to control the EV3 Controller using a keyboard and gamepad, the lego_ev3, keyboard and gamepad modules must be connected.

Listing of the config.ini configuration file for RCML

Module \u003d lego_ev3 module \u003d keyboard module \u003d gamepad


The next step is to pair the EV3 controller and adapter.

Instructions for Pairing the EV3 Controller and Bluetooth Adapter

The instruction contains an example of pairing a Lego Ev3 controller and a PC running an operating room windows systems 7.

1. Go to the Ev3 controller settings section, then to the "Bluetooth" menu item.

2. Make sure the configuration parameters are set correctly. Checkboxes should be set on the opposite of the “Visibility”, “Bluetooth” items.

3. You need to go to "Control Panel", then "Devices and Printers", then "Bluetooth Devices".

4. It is necessary to click the "Add device" button. A window will open to select available Bluetooth devices.

5. Select the “EV3” device and click the “Next” button.

6. The EV3 Controller will display the Connect? Dialog. You need to select the checkbox option, and confirm your choice by pressing the central key.

7. Next, the "PASSKEY" dialog box will be displayed, the input line should contain the numbers "1234", then confirm key phrase to pair devices, by pressing the center key on the position with a check mark.

8. A form for entering the key for pairing devices will appear in the device pairing wizard. You need to enter the code "1234" and press the "Next" button.

10. On the PC, you need to return to the "Control Panel", then "Devices and Printers", then "Bluetooth Devices". The device with which it was paired is displayed in the list of available devices.

11. Should double tap go to the connection properties “EV3”.

14. The COM port index specified in the properties should be used in the config.ini configuration file of the lego_ev3 module. The example shows the Bluetooth connection properties of a Lego EV3 controller using the standard COM14 serial port.


Further configuration of the module comes down to the fact that it is necessary to register in the configuration file of the lego_ev3 module the address of the COM port through which communication with the Lego robot is carried out.

Listing of the config.ini configuration file for the lego_ev3 module

Connection \u003d COM14 dynamic_connection \u003d 0


Now you need to configure the keyboard module. The module is located in the control_modules directory, then keyboard. Create a config.ini file next to keyboard_module.dll. Before creating a configuration file, you need to determine what actions should be performed by pressing keys.

The keyboard module allows you to use keys that have a specific numeric code. The table of virtual key codes can be viewed.

As an example, I will use the following keystrokes:

  • The up / down arrows are used to rotate the rear wheel motor forward / backward.
  • Left / right arrows turn the wheels left / right
The configuration file of the keyboard module describes which axes are available to the programmer to interact with the robot in manual control mode. Thus, in the example we have two control groups - these are the keyboard axes. To add a new axis, you should adhere to the following rules for describing axes.

Axis description rules for the keyboard module

1. When adding a new axis, it is necessary in the section add a property whose name is the axis name and assign it the value of the keyboard button in HEX format, while a similar record is entered for each button, i.e. the axis name can be used multiple times. In general, writing to the section will look like this:

Axis_name \u003d keyboard_button_value_in_HEX_format
2. It is necessary to set the maximum and minimum value that can be plotted along this axis. For this it is necessary with new line add a section in the config file config.ini, with the same name as the axis name, and set the properties upper_value and lower_value, which correspond to the maximum and minimum of the axis, respectively. In general terms, this section looks like this:

[axis_name] upper_value \u003d max_axis_value lower_value \u003d min_axis_value
3. Next, you should determine what value the axis will have in case of pressing a button on the keyboard, which was previously attached to it. The values \u200b\u200bare determined by creating a section, the name of which consists of the axis name and the value of the keyboard button in HEX format, separated by an underscore character. The properties are used to set the default (unpressed) and pressed state. unpressed_value and pressed_value respectively, to which the values \u200b\u200bare passed. The general view of the section in this case is as follows:

[axis-name_value-keyboard-button] pressed_value \u003d axis_value_when_key pressed unpressed_value \u003d axis_value_when_pressed_key
Spoiler text copied from RCML documentation for ease of viewing.


To implement control of the robot prototype, a configuration file for the keyboard module was created, which includes the go and rotate axes. The go axis is used to set the direction of movement of the robot. Pressing the up arrow key will set the axis to 100, pressing the down arrow key will set the axis to -50. The rotate axis is used to set the steering angle of the front wheels. Pressing the left arrow key will set the axis to -5, pressing the right arrow key will set the axis to 5.

Listing of the config.ini configuration file for the keyboard module

; Mandatory section; axis_name \u003d key_code (in HEX format); The go axis gets values \u200b\u200bfrom the up_arrow go \u003d 0x26; The go axis gets values \u200b\u200bfrom the down_arrow go \u003d 0x28; The rotate axis gets values \u200b\u200bfrom the left_arrow rotate \u003d 0x25; The rotate axis gets values \u200b\u200bfrom the right_arrow rotate \u003d 0x27; Description of the go axis, must always have both keys; Upper bound of the values \u200b\u200bof the go axis upper_value \u003d -100; Lower bound of the values \u200b\u200bof the go axis lower_value \u003d 100; Description of the rotate axis, must always have both keys; Upper bound of the values \u200b\u200bof the axis rotate upper_value \u003d - 100; The lower limit of the values \u200b\u200bof the rotate axis lower_value \u003d 100; Description of the behavior of the go axis for the key * up_arrow * (0x26); When pressing the key * up arrow * set the axis value to 50 pressed_value \u003d 100; When releasing the key * up arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the go axis behavior for the * down_arrow * (0x28) key; When pressing the * down_arrow * key, set the axis value to -50 pressed_value \u003d -50; When releasing the key * down_arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the rotate axis behavior for the * left_arrow * (0x25); When pressing the * left_arrow * axis value set to -5 pressed_value \u003d -5; When the key is released * left_arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the rotate axis behavior for the key * right_arrow * (0x27); When you press the key * right_arrow * set the axis value to 5 pressed_value \u003d 5; When you release the key * right_arrow * set the axis value to 0 unpressed_value \u003d 0


Further, to implement control using a gamepad, you need to configure the gamepad module. Configuring the module includes creating a config.ini configuration file next to gamepad_module.dll located in the control_modules directory, then gamepad.

Universal module configuration file for interaction with a gamepad

; Mandatory section describing the used axes; Axis for ending the manual control mode Exit \u003d 9; 11 binary axes corresponding to the gamepad buttons B1 \u003d 1 B2 \u003d 2 B3 \u003d 3 B4 \u003d 4 L1 \u003d 7 L2 \u003d 5 R1 \u003d 8 R2 \u003d 6 start \u003d 10 T1 \u003d 11 T2 \u003d 12; 4 stick axes; Right stick up / down movement RTUD \u003d 13; Right stick left / right movement RTLR \u003d 16; Left stick up / down movement LTUD \u003d 15; Left stick left / right movement LTLR \u003d 14; 2 axes of the cross; Movement of the cross up / down arrowsUD \u003d 17; Movement of the cross to the left / right arrowsLR \u003d 18; Description of the B1 axis behavior; When the B1 button is pressed, set the axis value to 1 upper_value \u003d 1; When the B1 button is released, set the axis value to 0 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0; Description of the behavior of the right stick axis up / down movement; Axis value when moving to the maximum possible upper position upper_value \u003d 0; Axis value when moving to the maximum possible lower position lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535; Description of the motion cross axis behavior up / down; Axis value when the up arrow is pressed upper_value \u003d 1; Axis value when the down arrow is pressed lower_value \u003d -1 upper_value \u003d 1 lower_value \u003d -1


For more information on the specifics of the gamepad module, see the RCML reference manual.

3. The next step is to write a program in RCML.

In the root of the created directory, you need to create a program file. The name of the program file and its extension can be anything, however, you should avoid Russian letters in the name. In the example, the filename is hello.rcml.

For the lego_ev3 module program code redundancy of the robot, has next view:

@tr \u003d robot_lego_ev3;

The lego_ev3 module connection page describes most of the functions supported by the controller. As a test case, a program was created to automatically enter the robot into a skid.

The program algorithm is as follows:

After reservation of the first free robot, two motors are connected for subsequent work with them as one. Then the robot starts to skid. The software description of the robot's actions allows you to accurately set the angles of rotation of the front wheels and the rotation speed of the rear wheels. Using this technique allows you to achieve results that are difficult to repeat when manually piloting with a keyboard or gamepad.

Listing of a program for a Lego robot in RCML language

function main () (@tr \u003d robot_lego_ev3; // Reserve the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Set the motor timing @ tr-\u003e motorMoveTo ("D", 100, 0,0); system.sleep (500); @ tr-\u003e trackVehicleForward (-100); system.sleep (1000); @ tr-\u003e motorMoveTo ("D", 50, -50,0); system.sleep (4000); @ tr-\u003e motorMoveTo ("D", 50,50,0); system.sleep (4000); @ tr-\u003e trackVehicleOff (); system.sleep (1000);)


To compile the program, you must use the window command line. First, you should move to the created directory with the rcml_compiler.exe and rcml_intepreter.exe executables. Next, you need to enter the following commands.

Command to compile the hello.rcml file:

Rcml_compiler.exe hello.rcml hello.rcml.pc
As a result of compilation, in the created directory will appear new file hello.rcml.pc.

Command line screenshot after successful compilation



Now make sure the EV3 Controller is powered on and paired with the Bluetooth adapter. The gamepad must be connected to the PC. After that, you need to execute the command to execute the program file:

Rcml_intepreter.exe hello.rcml

Appearance command line during program execution



A video demonstrating the robot movement program is located at the bottom of the article.

4. The next step is to control the robot in manual mode using the keyboard.

Using the keyboard, it is possible to control any robot motor. As part of the example, control of the following mechanisms is implemented:

  • Steering angle of the front wheels
  • The direction of rotation of the rear wheels

Listing of the program of interaction between the keyboard and the Lego robot based on the EV3 controller

function main () (@tr \u003d robot_lego_ev3; // Reservation of the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Setting the motor timing system.hand_control (@tr, "keyboard", " straight "," go "," speedMotorD "," rotate ");)


The next step is to compile the program and execute it. The result of manually controlling a Lego robot using a keyboard is shown in the video at the bottom of the page.

5. In addition to the keyboard, a gamepad module is available that allows you to manipulate the robot using a gamepad. To implement control of the robot using a gamepad, it is necessary to describe at the program level which axes of the robot will take on the values \u200b\u200bof the axes of the gamepad.

Listing of the program of interaction between the gamepad and the Lego robot

function main () (@tr \u003d robot_lego_ev3; // Reserving the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Setting the motor synchronization system.hand_control (@tr, "gamepad", " straight "," RTUD "," speedMotorD "," RTLR ");)


Next, you should repeat the process of compiling the program and then execute it. The following shows the result of manually controlling a Lego robot using a gamepad, and all previously connected methods:

This article briefly demonstrates just a few of the capabilities of RCML. Most detailed description be in the reference manual.

Tags:

  • lego mindstorms
  • robotics
  • programming
Add tags

LEGO Mindstorms is a set of electronic blocks and mating parts designed to create a programmable robot. LEGO presented the first set of Mindstorms back in 1998, and 8 years later, in 2006, the first version of the LEGO Mindstorms NXT 1.0 set was released, after another 3 years, in 2009 the second version of the set was released - LEGO Mindstorms NXT 2.0. and finally, in 2013, the LEGO Mindstorms EV3 set went on sale.

The LEGO Mindstorms set includes both standard LEGO parts such as axles, gears, beams, wheels and servos, as well as motors, sensors, and a programmable block. These sets are subdivided into resource and base sets.

The LEGO MINDSTORMS NXT Core Set is available in three versions:

    8527 LEGO MINDSTORMS contains 577 pieces, manufactured in 2006. This is the first version of a commercial set;

    9797 LEGO MINDSTORMS Education The NXT Base Set contains 431 parts, manufactured in 2006. It - basic set for training, educational set;

    8547 LEGO MINDSTORMS NXT 2.0 contains 619 pieces, manufactured in 2009. This is the second version of the commercial set.

Each of the three kits includes the same version of the NXT smart box. The firmware is different, but easily updated, so the kits can be considered equivalent in principle.

The LEGO MINDSTORMS Education Resource Set is available in two versions:

    9648 LEGO MINDSTORMS Education Resource Set;

    9695 LEGO MINDSTORMS Education Resource Set.

The 2010 Resource Kit contains 817 parts and is more varied.

The 2013 LEGO MINDSTORMS EV3 3.0 Core Set comes in one version 31313 and contains 601 pieces. "EV" stands for Evolution here.

LEGO Mindstorms sets are equipped with control blocks on microcontrollers of several versions of RCX, NXT and EV3. At the moment there are three of them, in addition there are modifications 1.0; 2.0 and 3.0.

The huge number of sensors that come with LEGO Mindstorms sets open up ample opportunities for creativity. Sensors are also produced by third-party manufacturers such as Mindsensors and HiTechnic. Here are just a few examples of standard sensors for LEGO Mindstorms NXT: NXT Servo Tachometer, NXT Ultrasonic Distance Sensor, NXT Touch Sensor, NXT Sound Sensor, NXT Light Sensor. In general, the list is quite extensive.

Let's take a look at what the LEGO MINDSTORMS EV3 Set is.

As for the EV3 stuffing, the smart box is equipped with a 300 MHz Sitara AM1808 (ARM9) processor from Texas Instruments, has 64 MB random access memory, 16 MB Flash-memory, there is also a slot for microSDHC memory cards up to 32 GB. USB host and Bluetooth available, Wi-Fi possible via USB dongle, Apple devices supported. The unit is also equipped with a monochrome LCD display with a resolution of 178x128. All motors and NXT sensors are fully compatible with the EV3 Brick. By the way, the NXT block can be programmed for the EV3, but some functions will not be available.

The box with the constructor can be deployed into a track with multi-colored zones, and the color sensors will perfectly interact with them. The parts in the box are initially packed in several separate bags. In addition, there is a set of stickers and instructions included.

The Intelligent EV3 Brick is the heart of the building block. Meals are provided 6 finger batteries... There are 6 buttons for control, and the backlight has three color modes indication. There are 4 input ports for connecting sensors, there are also 4 command output ports. To connect the unit to a computer - a miniUSB socket, a USB host port for organizing connections, a built-in speaker and, as mentioned earlier, a slot for a memory card. The programming interface allows you to create and configure programs directly from the block.

In addition to the smart box, the kit includes:

2 large servomotors equipped with precise rotation sensors and capable of 170 rpm at a maximum torque of 40 Ncm.

There is also one medium servo motor, the torque is less here - up to 12 Ncm, however, the revolutions can reach 250 per minute.

Color and light sensor with the ability to distinguish 8 colors with a sampling rate of up to 1 kHz.

A touch sensor capable of recognizing and counting clicks, touches, releases.

IR distance sensor, applicable for remote control, capable of receiving a signal even from 2 meters, with a distance measurement range within a radius of 70 cm. 4 channels are available for individual reception of signals and control commands.

Infrared beacon for IR sensor, can work as a remote control. The case has a green indicator LED and a channel switch. It can transmit in 4 separate channels within a radius of up to 2 meters. Automatically shuts off after an hour of inactivity. Powered by two little finger batteries.

In addition to the sensors included in the kit, other sensors can be used:

A gyro sensor for measuring rotational movements of the robot with an accuracy of 3 degrees, sensitive to moments up to 440 degrees per second. Sampling rate up to 1 kHz.

An ultrasonic sensor used to measure distances by transmitting and receiving reflected waves. It can work as a sonar and as a receiver of sound waves as control signals. Capable of measuring distances up to 2.5 meters with an accuracy of 1 cm.

Not only LEGO sensors and accessories are supported, but also third-party models such as Mindsensors and HiTechnic. It can be joysticks, compasses, accelerometers, etc. The range of various solutions is very, very wide.

To program the robot, you can use software LEGO Mindstorms EV3 Home Edition for Windows or OS X, which is easy to download from the official LEGO website. There is also an abundance of firmware, programming tutorials, videos, interactive instructions, mission descriptions.

Of course, the EV3 can be controlled from an Android or iOS smartphone, there are separate apps for this. Programming is possible in Java and many other languages: ASM / C / C ++ / Perl / Python / Ruby / VB / Haskell / Lisp / Matlab / LabVIEW.

On the official LEGO website, you can find 17 models with instructions for building different robots from an EV3 set. These models are:

TRACK3R is a high-flotation crawler robot with four interchangeable tools.

SPIK3R is a scorpion robot, it can turn sharply, grab objects with a crusher claw, and a lightning tail will repulse everything that comes in its path.

R3PTAR is a 35cm high cobra robot that can slide on the floor and attack objects with its fangs at high speed.

GRIPP3R - This robot is capable of lifting weights, can grab, lift and throw a can.

EV3STORM is a tracked robot with many missions.

BOBB3E - Bobcat® Robot Loader with remote control through the buttons of the IR beacon, it can move or lift various objects.

BANNER PRINT3R is a robot printer. He can draw with a regular marker, drawing lines. You can set your own drawing.

RAC3 TRUCK is a remote controlled racing truck. You can add a trailer.

DINOR3X - Robot Triceratops walks and turns on four legs.

KRAZ3 - The robot reacts to the IR beacon of its bug friend. You can also control the robot using a custom program or program it so that it moves exclusively behind the bug;

EV3D4 - inspired by Star Wars, can follow the owner, move around the IR beacon, communicate. Supports an extensive set of scenarios that can be programmed and expanded using the new EV3 software.

EL3CTRIC GUITAR - By hitting one string, fingering the fretless neck using the tremolo system, you can play incredible solos on this guitar!

The EV3MEG is a robot assistant capable of moving precisely along lines of a certain color, thanks to a light sensor. Detects obstacles in the way and reacts to them. Able to move both independently and be controlled by an IR beacon.

EV3 game - a robot can hide a ball under a glass, then change the cups, and you have to guess where the ball is. Using the IR beacon, you can set the level.

MR.B3AM - measures the length of LEGO® Technic beams, determines the color and size of the beams.

ROBODOZ3R is a robot bulldozer. Can move independently or be controlled remotely. Clears its path by rolling and pushing obstructing objects out of the way.

Because these sets make you think, model, invent, and generally encourage creativity and development, it is not at all surprising that in many countries teaching in colleges and schools using LEGO Mindstorms sets is very widespread.

Robot competitions have become quite popular, in which each educational institution can put its own robotics teams in the competition. Such competitions are also held in Russia, the most famous of such events is RoboFest. The best of the best go to the World Robot Olympiad - WRO (World Robot Olympiad).

Where to buy LEGO Mindstorms EV3?

The price of LEGO Mindstorms EV3 depends on the set configuration. Various LEGO Mindstorms bundles, educational versions, are available from specialized LEGO Education retailers.

Andrey Povny


Constructor Lego Is a more versatile material than it might seem at first glance. After all, with its help you can build not only toy cars and houses, but also quite complex structures, for example, robots under the control of a mobile phone. Here are similar sets with the name Mindstorm EV3 and presented the Danish company recently at the 2013 CES in Las Vegas.




Last year, a fourteen-year-old American schoolboy became famous throughout the technical world for creating from LEGO, which can draw user-specified drawings with a felt-tip pen. And in 2013, the Danish company itself released a product with a similar name - Mindstorm EV3. But this is not a printer, but prefabricated robots assembled by hand from the parts of the above-mentioned designer.



The basis of Mindstorm EV3 is a kind of system unit, a small computer based on an ARM processor running an operating room linux systems... It has 16 megabytes of built-in flash memory, 64 megabytes of RAM, an expansion slot for SD cards, and a Wi-Fi module.

This system unit and will become the "brain" of a robot that every owner of the Mindstorm EV3 kit can assemble with their own hands, following the instructions from the manufacturer or guided by their engineering technical talent.



The module will control the actions of this robot, depending on the selected preinstalled program or an algorithm written by the user himself.

What's more, LEGO promises that the Mindstorm EV3 robot will also be able to interact with mobile phones running operating systems Android and iOS. It will be enough just to install special software on them, so that with just the movements of your fingers on the smartphone screen, you can control the actions of the newly assembled with my own hands robot.



The LEGO Mindstorm EV3 set includes 594 parts, and it will be possible to assemble a simple robot with it in just 20 minutes. The manufacturer promises to start selling this unusual construction set already in 2013.

The infrared sensor is included in the home version of the Lego mindstorms EV3 set. This is the only sensor that can be used both independently and in conjunction with an infrared beacon, which is also part of a home kit. The next two lessons will be devoted to exploring these two devices, as well as their interaction with each other.

8.1. Exploring the infrared sensor and infrared beacon

(Fig. 1) in his work uses light waves invisible to humans - infrared waves * ... The same waves are used, for example, by remote control panels of various modern household appliances (TVs, video and music devices). Infrared sensor in mode "Approximation" independently sends infrared waves and, having caught the reflected signal, determines the presence of an obstacle in front of it. The infrared sensor is paired with an infrared beacon in two more modes of operation (Fig. 2)... In mode "Remote"the infrared sensor can detect the pressing of the buttons of the infrared beacon, which allows you to organize remote control of the robot. In mode "Lighthouse" the infrared beacon sends constant signals that the infrared sensor can use to determine the approximate direction and distance of the beacon, which allows the robot to be programmed so that it always follows the direction of the infrared beacon. Before using the infrared beacon, two AAA batteries must be installed.

Figure: 1

Figure: 2

8.2. Infrared sensor. Zoom Mode

This mode of operation of the infrared sensor is similar to the distance detection mode of the ultrasonic sensor. The difference lies in the nature of light waves: if sound waves are reflected from most materials with little or no attenuation, then the reflection of light waves is influenced not only by the materials, but also by the color of the surface. Dark colors, in contrast to light ones, absorb the light flux more strongly, which affects the operation of the infrared sensor. The range of operation of the infrared sensor also differs from the ultrasonic one - the sensor shows values \u200b\u200bin the range from 0 (subject is very close) to 100 (the object is far away or not found). We emphasize again: the infrared sensor cannot be used to determine the exact distance to the object, since its readings in the "Zoom" mode are influenced by the color of the surface of the object under investigation. In turn, this property can be used to distinguish between light and dark objects that are at an equal distance to the robot. The infrared sensor copes with the task of determining the obstacle in front of it quite successfully.

Let's solve a practical problem similar to Problem number 14 Lesson number 7, but, in order not to repeat ourselves, let us complicate the condition with additional requirements.

Problem number 17: write a program of a straight-line robot, stopping in front of a wall or obstacle, moving back a little, turning 90 degrees and continuing to move until the next obstacle.

A robot assembled according to instructions small-robot-31313an infrared sensor is installed in front of the vehicle. Connect it with a cable to the port "3" EV3 Brick and start creating the program.

Consider the program block "Expectation" Orange palette by switching it to Mode: - "Comparison" - "Approach" (Fig. 3)... In this mode, the program block "Expectation" has two input parameters: "Comparison type" and "Threshold value"... We already know how to configure these parameters.

Figure: 3

Decision:

  1. Start straight ahead
  2. Wait until the infrared sensor threshold is less than 20
  3. Stop moving forward
  4. Drive back 1 engine revolution
  5. Turn right 90 degrees (using the knowledge of Lesson 3, calculate the required angle of rotation of the motors)
  6. Continue steps 1 - 5 in an endless loop.

Try to solve Problem number 17 independently, without peeping into the solution.

Figure: 4

Now, to reinforce the material, try to adapt the solution Problems number 15 Lesson number 7 to use an infrared sensor! Happened? Share your impressions in the comments to the lesson ...

8.3. Remote control of the robot using an infrared beacon

The infrared beacon included in the home version of Lego mindstorms EV3, paired with an infrared sensor, allows remote control of the robot. Let's take a closer look at the lighthouse:

  1. Using the infrared beacon, aim the signal transmitter (Fig. 5 pos. 1) towards the robot. There must be no obstacles between the beacon and the robot! Thanks to the wide viewing angle, the infrared sensor receives signals with confidence, even if the beacon is located behind the robot!
  2. There are 5 gray buttons on the lighthouse body (Fig. 5 pos. 2)which are recognized by the infrared sensor and transmits the press codes to the program that controls the robot.
  3. With a dedicated red switch (Fig. 5 pos. 3) you can choose one of four channels for communication between the beacon and the sensor. This was done so that several robots could be controlled in the immediate vicinity.

Figure: five

Problem number 18: write a program for remote control of a robot using an infrared beacon.

We already know that to implement the ability to select running blocks, you need to use a program block "Switch" Orange palette. Set the unit operation mode "Switch" in - "Measurement" - "Remote" (Fig. 6).

Figure: 6

To activate the communication between the infrared sensor and the beacon, you must set the correct parameter value "Channel" (Fig. 7 pos. 1) according to the selected channel on the lighthouse! To each program container of the block "Switch" it is necessary to match one of possible options gray key presses (Fig. 7 pos. 2)... Note: some options involve pressing two keys at the same time (the keys pressed are marked in red). Total in the program block "Switch" in this mode, you can process up to 12 different conditions (one of the conditions must be selected as the default condition). Software containers are added to the block "Switch" by clicking on "+" (Fig. 7 pos. 3).

Figure: 7

We propose to implement the following robot control algorithm:

  • Pressing the upper left button turns on the left motor rotation, the robot turns right (Fig. 7 pos. 2 meaning: 1)
  • Pressing the upper right button turns on the rotation of the right motor, the robot turns to the left (Fig. 7 pos. 2 value: 3)
  • Pressing the upper left and right buttons turns on the simultaneous forward rotation of the left and right motors, the robot moves forward in a straight line (Fig. 7 pos. 2 value: 5)
  • Simultaneous pressing of the lower left and right buttons turns on the simultaneous rotation of the left and right motors backward, the robot moves backward in a straight line (Fig. 7 pos. 2 value: 8)
  • If no beacon button is pressed, the robot stops (Fig. 7 pos. 2 value: 0).

When developing a remote control algorithm, you should know the following: when one of the combinations of gray buttons is pressed, the infrared beacon continuously sends a corresponding signal; if the buttons are released, the signal is stopped. The only exception is a separate horizontal gray button (Fig. 7 pos 2 value: 9)... This button has two states: "ON" - "OFF"... In the on state, the beacon continues to send a signal even if you release the button (which is indicated by the green LED lit up), to turn off the signal sending in this mode, press the horizontal gray button again.

Let's start implementing the program:

Our remote control algorithm provides 5 options for behavior, respectively, our program unit "Switch" will consist of five software containers. Let's go ahead and configure them.

  1. We will assign the default option to the option when no buttons are pressed (Fig. 7 pos. 2 value: 0)... Install a program block in the container that turns off the motors "B" and "C".
  2. To the top left click option container (Fig. 7 pos. 2 meaning: 1) install the program block "Big motor"including motor "B".
  3. To the top right click option container (Fig. 7 pos. 2 value: 3) install the program block "Big motor"including motor "C".
  4. To the container of the option of simultaneously pressing the upper left and right buttons (Fig. 7 pos. 2 value: 5)install the program block "Independent motor control" "B" and "C" forward.
  5. To the container of the option of simultaneously pressing the lower left and right buttons (Fig. 7 pos. 2 value: 8)install the program block "Independent motor control"including rotation of motors "B" and "C" back.
  6. Let's place our customized program block "Switch" inside the program block "Cycle".

According to the proposed scheme, try to create the program yourself, without peeping into the solution!

Figure: eight

Load the resulting program into the robot and run it. Try to control the robot using an infrared beacon. Did you succeed? Do you understand the principle of remote control implementation? Try to implement additional options management. Write your impressions in the comments for this lesson.

* Want to see invisible waves? Turn on the photo mode in the mobile phone and bring the emitting element remote control from TV to mobile phone lens. Press the buttons on the remote control and watch the glow of infrared waves on the phone screen.

Did you like the article? To share with friends: