# How to calibrate the EV3 Gyro Sensor (software solution)

The EV3 Gyro sensor is quite powerful, but there are some little tricks when using it. In the previous episode we showed a hardware solution to the problem and now we are exploring how could the sensor be calibrated from the EV3-G software. Thanks to Sharon and Faye (full names omitted) for the request for this video.

• #88
• 01 Jan 2017
• 3:53

### The hardware solution

For the hardware solution take a look at How to calibrate the EV3 Gyro Sensor and remove its drift (hardware solution)

### Calibration

Simply put - you have a device that is making measurements. If there is a difference between a well-known value and the value measured by this device then you need to calibrate the device.

Example - you take a compass and get the direction of North measured by the compass. You compare this measurement with the real direction of North. If there is a difference the compass should be calibrated.

Example 2 - you take a thermometer and get the temperature of a freezing water. You know that the temperature of a freezing water is 0 degrees Celcius. If the thermometer has measured something else than you need to calibrate it.

### Calibration with the gyro sensor

The EV3 Gyro Sensor is a powerfull sensor for every robot construction. It detects Angle of rotation and Rate of Rotation. In order to calibrate it you must get the difference between a known value and the measured value.

In the video tutorial we are discussing exactly this. How to calibrate the sensor using the EV3-G software, what is the measured value and what is the difference between the measured and the known value.

### English

1 00:00:08,150 --> 00:00:14,410 In the previous episode we started with experimenting with Ev3 Gyro drift, and 2 00:00:14,590 --> 00:00:19,420 ways to remove it. We looked at the hardware solution, and in this video we 3 00:00:19,600 --> 00:00:21,850 will explore different software solutions. 4 00:00:22,030 --> 00:00:28,880 As you can see, the brick currently, although it is not moving, shows that the 5 00:00:29,060 --> 00:00:37,510 Gyro sensor is moving and that's in fact called EV3 Gyro drift. Let's look for 6 00:00:37,690 --> 00:00:39,964 ways to remove this drift. 7 00:00:44,580 --> 00:00:48,510 As you can see, the brick is currently connected to the computer, and we can see 8 00:00:48,690 --> 00:00:56,160 the result of the Gyro drift. A simple problem for solving this drift is to use 9 00:00:56,340 --> 00:00:58,283 the Gyro sensor block. 10 00:01:00,160 --> 00:01:06,930 The Gyro sensor's connected on port 1, and we have the first measuring rate, 11 00:01:07,110 --> 00:01:12,861 the second block measuring angle, and after that we have a simple wait. 12 00:01:13,430 --> 00:01:21,000 This should cause a reset in the sensor and from then on the value detected 13 00:01:21,000 --> 00:01:27,740 from the sensor should be correct. These blocks are now run each time we start our 14 00:01:27,920 --> 00:01:35,203 program and our program is to output the value of the Gyro Sensor. 15 00:01:35,490 --> 00:01:43,340 So here I'll just get the value and display this value on the screen. I would like 16 00:01:43,520 --> 00:01:54,090 to wire, display text, and show the value on the screen, and after display the value 17 00:01:54,090 --> 00:01:57,007 we wait for about a second. 18 00:01:57,007 --> 00:02:03,764 So again, we start the program with calibrating the sensor by resetting, not 19 00:02:03,764 --> 00:02:07,875 by resetting, but by changing the rate that is measuring. 20 00:02:07,875 --> 00:02:13,609 First the rate and then the angle, you wait for about second, and we start the 21 00:02:13,609 --> 00:02:18,986 loop, and in this we loop, we just measure the angle and display this angle 22 00:02:18,986 --> 00:02:21,979 on the screen. Let's see how this works. 23 00:02:25,353 --> 00:02:30,001 Now, this is where it gets really interesting. After running the program, as 24 00:02:30,001 --> 00:02:35,649 you can see, it should calibrate. We set the value of the Gyro sensor and from 25 00:02:35,649 --> 00:02:43,354 then on we measure only the real value, and not the drift. But currently I'm not 26 00:02:43,354 --> 00:02:48,138 moving the brick, and we can see that there is a Gyro drift. 27 00:02:52,283 --> 00:02:59,053 From our experience, what I've personally found is that for some bricks it works, 28 00:02:59,053 --> 00:03:05,196 the program that we have just written, for other, it just doesn't work. Let me just 29 00:03:05,196 --> 00:03:08,217 start the same program for another brick. 30 00:03:09,356 --> 00:03:14,173 I have simulated the Gyro drift on another brick, uploaded the program, 31 00:03:14,173 --> 00:03:19,767 and now I'm holding the brick in my hand, and as you can see there is no Gyro drift. 32 00:03:19,767 --> 00:03:23,968 Actually, the differences are from the movement of my arm. 33 00:03:26,393 --> 00:03:34,068 As a conclusion, we have simple program for calibrating the sensor, but it seems 34 00:03:34,068 --> 00:03:37,632 that this program works on some sensors and on some bricks, 35 00:03:37,632 --> 00:03:39,662 and on other bricks it doesn't work. 36 00:03:39,662 --> 00:03:45,053 So I recommend that you use the Harbor solution and the link for the solution is 37 00:03:45,053 --> 00:03:48,847 provided below in the description of the video.