Capturing infrared signals using the IR sensor
The focus of this lecture is the IR sensor. The IR sensor can be used to receive signals from a remote controller, it can be used to measure distance, and it can be used to track the angle of an infra red beacon. IR sensors are widely used in robotics. For example a robot vacuum cleaner uses an IR sensor to find the dock.
In proximity mode the signal sent by the IR sensor reflects from the detected object in front of the sensor. That way it can estimate the distance to the object. In beacon mode the IR beacon can be detected by the infrared sensor. This mode can be used to detect the beacon's heading and proximity. In remote mode the button presses or certain combination of button presses on the IR beacon can be detected by the IR sensor.
Look how simply you can connect the sensor
The EV3 Infrared sensor can be easily connected to the 1, 2, 3 or 4 ports of the Brick. These ports are located at the bottom of the Lego Brick. After you have connected the sensor to the Brick it will detect all connected devices. On Figure 1 you can see how to connect the sensor to the Brick.
Figure 1 - IR Sensor connected to Lego Mindstorms EV3
Let's take a look at the Infrared Beacon
You can use that infrared beacon to keep connected with the infrared sensor. The beacon has got two different modes: beacon and remote. In beacon mode, it continuously transmits an infrared signal until you turn it off by pressing the beacon mode button again. In remote mode, the beacon has got the functionality as a remote controller. The Infrared Beacon will only be detected by the infrared sensor on the channel specified in the software. That means if you have two robots and two infrared beacons the robots should be remote controlled on two different channels, otherwise one beacon will control all the robots on its channel.
Figure 2 - The Infrared Beacon
- Lego Mindstorms EV3 Brick
- EV3 Infrared Sensor
- EV3 Infrared Beacon
- EV3 cable
- Ozeki 10 installed
- Lego connection installed in Ozeki 10
- Bluetooth connection on your machine
Video tutorial: 'How to use the Infrared sensor in Ozeki 10'
Open Control Panel in Ozeki 10!
After setting up the system which is including the mounting the sensors to the Brick, the installation of Ozeki 10, and pairing of the Lego Brick to the computer (the guide of the bluetooth pairing available at http://www.ozeki.hu/index.php?owpn=6065), the first step is to open the Ozeki 10 by clicking on its icon on the desktop. The Ozeki 10 will open in your web browser, and will have two icons on its Dekstop, and the Start menu in the bottom left corner as it shows in the figure below. Now you will use the Control Panel, so open it by clicking on it as you can see on Figure 3.
Figure 3 - Ozeki 10 Dekstop
Select the Infrared sensor from the connection list!
In the Control Panel you can see a list of connections. If your Lego device is connected properly you should see the similar list as in the Figure 4 below. If your list is empty just do the following smart guide how to connect the Lego Mindstorms EV3 products to Ozeki 10 on the following page: http://www.ozeki.hu/index.php?owpn=6067. As you are working with the infrared sensor, so just select it from the list of connections to open the conversation with it.
Figure 4 - List of connections in Ozeki 10
Open the configuration menu of the sensor!
When you open the sensor you have got three menus to choose. Chat, where the communication with the sensor is happening. Configure, where you can try different modes of the sensor and the Events, where all the events logged. This step is focusing on the configuration part. Here you can rename your sensor, select between the sensor modes: proximity, beacon and remote. And also you can set an time interval, when the Ozeki 10 will automatically ask for information from the IR Sensor.
Figure 5 - Configure menu of the sensor
Send 'read' command when the sensor is in Proximity mode!
When you are using the sensor in proximity mode, the sensor is measuring the distance from the infrared beacon or from the nearest object up to 100 cm. You can easily ask for that distance with Ozeki 10. For making it possible just enter the command 'read' in the text box and by hitting the Enter button or clicking on the Send button the current proximity between the sensor and the beacon or the detected object reflected in front of the sensor will show up in just a second.
Figure 6 - Using of the Proximity mode
Switch to Beacon mode, and send 'read' again!
For using the beacon mode for the Infrared Sensor you just have to change the sensor mode in the configure menu as it showed in Step 3. By choosing this mode you will able to measure the beacon's proximity (relative distance from the sensor) and it's heading (angle from the direction the sensor is pointing). To read that data the procedure is the same as it was in the Proximity mode, so just enter the command 'read' and then hit Enter or click on the Send button.
Figure 7 - Using of the Beacon mode
Switch to Remote mode, and send the 'read' command again!
In Remote mode in the Configure menu the sensor will detect the button presses on the IR Beacon. For example if you enter the command 'read' while you sensor in Remote mode, and at the same time you press a button on the Infrared Beacon the IR Sensor will detect which button or combination of buttons you pressed and the result will show up in the Chat menu of Ozeki 10 (Figure 8).
Figure 8 - Using of the Remote mode
Open the Events menu, and check the low level communication!
As it was mentioned in Step 3, the connection has got an Events menu, where all the communication with the sensor is logged with separate messages. Each messages have got a time stamp that shows when the command from the user or the answer from the sensor was sent. The log line also contains the name of the sensor, the status of the sent command or answer from the sensor. For example the highlighted lines show that the user entered the command 'read', and the sensor has responded to that by sending the message, 'Proximity: 22'. The Figure 9 demonstrates it.
Figure 9 - Events menu of the sensor
The IR Sensor command set in Ozeki 10
The table below shows all the commands that you can use in Ozeki 10 when your Infrared Sensor is connected. Next to the commands you can also read the short description that describe what is going to happen when you enter them in Ozeki 10. All the commands can be sent through chat by hitting the Enter or clicking on the Send button.
|read||read the data from the sensor depending on which mode that the sensor is in|
Commands Table - Contains message reading the measured values of the IR sensor
The rest of the command set can be used on all Ozeki 10 sensors or actuators, including Lego Mindstorms products. You should always start by typing 'help'. It provides you the full command set for the actual device, which you would like to control through chat.
|help||request the command set|
|subscribe||subscribe to device messages|
|unsubscribe||unsubscribe from device messages|
|subscribers||shows the list of subscribers|
Basic commands Table - General commands for all devices
The beacon mode button is different compare to the other buttons. If you press that button, the beacon starts transmitting continuosly until you turn it off by pressing the button again. Here you can read some additional information of the infrared beacon mode and its usage. The following table will show you all the specific details about the beacon modes that can be very useful for the future.
|Detected||Logic||True/False||True if an IR Beacon on the specific channel, otherwise False|
|Proximity||Numeric||0 to 100||The relative distance to the beacon. 0 means very close, and 100 means far away. If the beacon is not detected the proximity will be 100.|
|Heading||Numeric||-25 to 25||0 means the beacon is directly in front of the sensor, negative value means that the beacon is on the left, positive value means the beacon is on the right.|
The table below is containing all the button codes and codes of the button combinations, that can be detected when the sensor is in Remote mode.
|Button ID||Numeric||0-11||Identifies which button, or combination of buttons, is pressed on the IR beacon.
0 = No button (and beacon mode is off) 1 = Button 1
2 = Button 2
3 = Button 3
4 = Button 4
5 = Both button 1 and button 3
6 = Both button 1 and button 4
7 = Both button 2 and button 3
8 = Both button 2 and button 4
9 = Beacon mode is on
10 = Both button 1 and button 2
11 = Both button 3 and button 4
- The touch sensor and sensor messaging
- How to measure light intensity and how to capture color information
- Using motors and rotary encoders
- Distance measurement, the ultrasonic sensor
- Orientation in space, the gyroscope sensor
- Using the LCD display
- Using indicator leds on the Lego Brick
- Power management and working with the brick battery
- Playing sounds on the Lego speaker