Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:hardware2:sensors_angle [2023/10/02 14:49] pczekalskien:iot-open:hardware2:sensors_angle [2024/05/23 19:44] (current) pczekalski
Line 1: Line 1:
-==== Angle & Orientation Sensors ====+====== Angle & Orientation Sensors ====== 
 +{{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\ 
 +== The Inertial Measurement Unit (IMU) ==
  
-===Potentiometer=== +An IMU is an electronic device that consists of an accelerometer, gyroscopeand sometimes a magnetometer. The combination of these sensors returns the object's orientation in 3D space. IMU sensors can present the object's current position and movement, expressed with at most six values called the DOF (Degrees Of Freedom). Three values represent the linear movements that the accelerometer can measure:
-A potentiometer is a type of resistor, the resistance of which can be adjusted using a mechanical lever. The device consists of three terminals. The resistor between the first and the third terminal has a fixed value, but the second terminal is connected to the lever. Whenever the lever is turned, a slider of the resistor is moved; it changes the resistance between the second terminal and side terminals. Variable resistance causes the change of the voltage, which can be measured to determine the position of the lever. Thus, the potentiometer output is an analogue value. +
- +
-Potentiometers are commonly used as a control level, for example, a volume level for the sound and joystick position. They can also be used to determine the angle in feedback loops with motors, such as servo motors. +
- +
-<figure label> +
-{{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:potentiometer_symbol_europe.png?100 | Symbol of a potentiometer}} +
-<caption>A symbol of a potentiometer</caption> +
-</figure> +
- +
-<figure label> +
-{{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:potentiometer_c.jpg?200 | Potentiometer}} +
-<caption>A potentiometer</caption> +
-</figure> +
- +
-<figure label> +
-{{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:sch_apz_shemas_potentiometer.png?300 | Arduino and potentiometer circuit}} +
-<caption>Arduino and potentiometer circuit</caption> +
-</figure> +
- +
-An example code: +
-<code c> +
- +
-//Potentiometer sensor output is connected to the analogue A0 pin +
-int potentioPin = A0;  +
-//The analogue reading from the potentiometer output +
-int potentioReading;       +
-  +
-void setup(void) { +
-  //Begin serial communication +
-  Serial.begin(9600);    +
-  //Initialize the potentiometer analogue pin as an input +
-  pinMode(potentioPin, INPUT);  +
-+
-  +
-void loop(void) { +
-  //Read the analogue value of the potentiometer sensor +
-  potentioReading = analogRead(potentioPin);  +
-  Serial.print("Potentiometer reading = "); //Print out +
-  Serial.println(potentioReading); +
-  delay(10); +
-+
-</code> +
- +
-===The Inertial Measurement Unit (IMU)=== +
- +
-An IMU is an electronic device consisting of an accelerometer, gyroscope and sometimes a magnetometer. The combination of these sensors returns the object's orientation in 3D space. IMU sensors can present the object's current position and movement, expressed with at most six values called the DOF (Degrees Of Freedom). Three values express the linear movements that the accelerometer can measure:+
   * moving forward/backwards,   * moving forward/backwards,
   * moving left/right,   * moving left/right,
Line 56: Line 12:
   * yaw left and right.   * yaw left and right.
  
-A **gyroscope** is a sensor that measures the angular velocity. The sensor is made with microelectromechanical system (MEMS) technology and is integrated into the chip. The sensor output can be analogue or digital, using I2C or SPI interface. Gyroscope microchips can vary in the number of axes they can measure. The available number of axes is 1, 2 or 3 axes in the gyroscope. A gyroscope is commonly used with an accelerometer to determine the device's orientation, position and velocity precisely.+A **gyroscope** is a sensor that measures the angular velocity. microelectromechanical system (MEMS) technology integrates the sensor into the chip. The sensor output can be analogue or digital, using I2C or SPI interface. Gyroscope microchips can vary in the number of axes they can measure. The available number of axes is 1, 2 or 3 axes in the gyroscope. A gyroscope is commonly used with an accelerometer to determine the device's orientation, position and velocity precisely.
 Gyroscope sensors are used in aviation, navigation and motion control. Gyroscope sensors are used in aviation, navigation and motion control.
  
Line 64: Line 20:
 A **magnetometer** is a sensor that can measure the device's orientation to the Earth's magnetic field. A magnetometer is used as a compass in outdoor navigation for mobile devices, robots, and quadcopters. A **magnetometer** is a sensor that can measure the device's orientation to the Earth's magnetic field. A magnetometer is used as a compass in outdoor navigation for mobile devices, robots, and quadcopters.
  
-Different elements allow measuring linear accelerations, angular accelerations, and magnetic fields in three axes. There exist elements that combine two (called 6-axis or 6-DOF) or all (9-axis, 9-DOF) measurement units. Popular integrated circuits are MPU6050 (3-axes gyro + 3-axes accelerometer), MPU9250, and BNO055 (3-axes gyro3-axes accelerometer3-axes magnetometer). All of them can be programmed in an Arduino environment using dedicated libraries. The latter automatically calculates additional information like gravity vector and absolute orientation expressed as an Euler vector or as a quaternion.+Different elements allow measuring linear accelerations, angular accelerations, and magnetic fields in three axes. There exist elements that combine two (called 6-axis or 6-DOF) or all (9-axis, 9-DOF) measurement units. Popular integrated circuits are MPU6050 (3-axes gyro + 3-axes accelerometer, figure {{ref>imu6050}}), MPU9250 (3-axes gyro + 3-axes accelerometer + 3-axes compass, figure {{ref>imu9250}}), and BNO055 (3-axes gyro 3-axes accelerometer 3-axes magnetometer, figure {{ref>bno055}}). All of them can be programmed in an Arduino environment using dedicated libraries.  
 +\\ The latter automatically calculates additional information like gravity vector and absolute orientation expressed as an Euler vector or a quaternion. The sample connection circuit for the BNO055 sensor is present in figure {{ref>bno055_2}}. Note, figure {{ref>bno055_2}} does not present pull-up resistors on the I2C bus as they are integrated into the development boards.
  
-<figure label>+<figure imu6050>
 {{ :en:iot-open:hardware2:20230925_114148_-_kopia.jpg?300 | IMU MPU6050 module}} {{ :en:iot-open:hardware2:20230925_114148_-_kopia.jpg?300 | IMU MPU6050 module}}
 <caption>IMU MPU6050 module</caption> <caption>IMU MPU6050 module</caption>
 </figure> </figure>
  
-<figure label>+<figure imu9250>
 {{ :en:iot-open:hardware2:20230925_114235_-_kopia.jpg?300 | IMU MPU9250 module}} {{ :en:iot-open:hardware2:20230925_114235_-_kopia.jpg?300 | IMU MPU9250 module}}
 <caption>IMU MPU9250 module</caption> <caption>IMU MPU9250 module</caption>
 </figure> </figure>
  
-<figure label>+<figure bno055>
 {{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:imu_c.jpg?200 | IMU BNO055 module}} {{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:imu_c.jpg?200 | IMU BNO055 module}}
 <caption>IMU BNO055 module</caption> <caption>IMU BNO055 module</caption>
 </figure> </figure>
  
-<figure label>+<figure bno055_2>
 {{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:imu_sch_hd.jpg?400 | Arduino Uno and IMU BNO055 module schematics}} {{ :en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:arduino_and_arduino_101_intel_curie:imu_sch_hd.jpg?400 | Arduino Uno and IMU BNO055 module schematics}}
 <caption>Arduino Uno and IMU BNO055 module schematics</caption> <caption>Arduino Uno and IMU BNO055 module schematics</caption>
Line 98: Line 55:
 void setup(void) void setup(void)
 { {
-bno.setExtCrystalUse(true);+  bno.setExtCrystalUse(true);
 } }
 void loop(void) void loop(void)
 { {
-//Read sensor data +  //Read sensor data 
-sensors_event_t event; +  sensors_event_t event; 
-bno.getEvent(&event); +  bno.getEvent(&event); 
-//Print X, Y And Z orientation +  //Print X, Y And Z orientation 
-Serial.print("X: "); +  Serial.print("X: "); 
-Serial.print(event.orientation.x, 4); +  Serial.print(event.orientation.x, 4); 
-Serial.print("\tY: "); +  Serial.print("\tY: "); 
-Serial.print(event.orientation.y, 4); +  Serial.print(event.orientation.y, 4); 
-Serial.print("\tZ: "); +  Serial.print("\tZ: "); 
-Serial.print(event.orientation.z, 4); +  Serial.print(event.orientation.z, 4); 
-Serial.println(""); +  Serial.println(""); 
-delay(100);+  delay(100);
 } }
  
 </code> </code>
 +
 +<note important>Most MEMS devices present built-in inaccuracy. For this reason, gyros and accelerometers should be calibrated before use to calculate their so-called offset, an average error they present (in each axis separately). Later, this error is used to calculate a correction factor applied during regular operation. Sample MPU6050 library along with calibration code can be found in the Github repository ((https://github.com/ElectronicCats/mpu6050/tree/master)).</note>
 +<note important>Similar problem is present in the case of the magnetometers: the surrounding environment can impact readings; thus, they require calibration that can be achieved by recording the minimum and maximum values during rotation in every axis. This process is common when using a drone in a new location.</note>
  
en/iot-open/hardware2/sensors_angle.1696258160.txt.gz · Last modified: 2023/10/02 14:49 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0