How to use gyroscope: Difference between revisions

From wikiluntti
(Created page with "=== Introduction === === Robot === === Sensors === === Example Videos === === Theory === === Example Code === === Exercises === This course is supported by [https://m...")
 
No edit summary
Line 1: Line 1:
=== Introduction ===
=== Introduction ===
The gyroscope is very powerful tool in navigation. The gyroscope is similar to a compass, and it gives the angle with respect to reset. The gyroscope can be used to steer the correct amount, or to drive straight. These gyroscope algorithms are proportional, but it is easy to implement with e.g. the PID algorihm, too.
The gyroscope driving functions should be done as MyBlock so that they are easy to use at your own codes.
We show two different methods, (i) drives straights, and (ii) turns to given angle.


=== Robot ===
=== Robot ===
Almost any robot will do, though these examples are done by using Verne/ Asimov 2.


=== Sensors ===
=== Sensors ===
The gyroscope sensor is used.


=== Example Videos ===
=== Example Videos ===
The two different methods are shown.


=== Theory ===
=== Theory ===
The limitations of gyroscope sensor should be known. E.g. the magnetic field affects the sensor values. Also, the sensor should be exactly still while starting the sensor. Otherwise, it might start drifting. If the sensor starts drifting, the easiest method to make it work properly is to unplug and plug the sensor again. Usually it works on the first replugging.


=== Example Code ===
=== Example Code ===
The first example code explains the resetting, and how to use proportional algorithm to drive straight. The second code employs the proportional algorithm to follow a given compass direction.
[[File:Gyro0degrees.png|thumb|The gyro gives to 0 degrees.]]
[[File:GyroAngle.png|thumb|The MyBlock version of gyro program to drive the given angle.]]


=== Exercises ===
=== Exercises ===
* Make the robot to turn the shorter distance.
* Make the robot to turn the longer distance.
* Use the Modulo operator to fix the number of turns the robot makes during the drive.
* Make a MyBlock that drives, and turns the robot as LEGOs steering block, but while using the gyro sensor.





Revision as of 13:52, 12 September 2020

Introduction

The gyroscope is very powerful tool in navigation. The gyroscope is similar to a compass, and it gives the angle with respect to reset. The gyroscope can be used to steer the correct amount, or to drive straight. These gyroscope algorithms are proportional, but it is easy to implement with e.g. the PID algorihm, too.

The gyroscope driving functions should be done as MyBlock so that they are easy to use at your own codes.

We show two different methods, (i) drives straights, and (ii) turns to given angle.

Robot

Almost any robot will do, though these examples are done by using Verne/ Asimov 2.

Sensors

The gyroscope sensor is used.

Example Videos

The two different methods are shown.


Theory

The limitations of gyroscope sensor should be known. E.g. the magnetic field affects the sensor values. Also, the sensor should be exactly still while starting the sensor. Otherwise, it might start drifting. If the sensor starts drifting, the easiest method to make it work properly is to unplug and plug the sensor again. Usually it works on the first replugging.


Example Code

The first example code explains the resetting, and how to use proportional algorithm to drive straight. The second code employs the proportional algorithm to follow a given compass direction.


The gyro gives to 0 degrees.
The MyBlock version of gyro program to drive the given angle.

Exercises

  • Make the robot to turn the shorter distance.
  • Make the robot to turn the longer distance.
  • Use the Modulo operator to fix the number of turns the robot makes during the drive.
  • Make a MyBlock that drives, and turns the robot as LEGOs steering block, but while using the gyro sensor.


This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.