This is an old revision of the document!


Angle & Orientation Sensors

Potentiometer

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.

 Symbol of a potentiometer
Figure 1: A symbol of a potentiometer
 Potentiometer
Figure 2: A potentiometer
 Arduino and potentiometer circuit
Figure 3: Arduino and potentiometer circuit

An example code:

//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);
}

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 can be measured by the accelerometer:

  • moving forward/backwards,
  • moving left/right,
  • moving up/down.

Another three values present the rotation in three axes that can be measured by gyroscope:

  • roll side to side,
  • pitch forward and backwards,
  • 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 the axis is 1, 2 or 3 axes in the gyroscope. A gyroscope is commonly used with an accelerometer to precisely determine the device's orientation, position and velocity. Gyroscope sensors are used in aviation, navigation and motion control.

An accelerometer measures the acceleration of the object. The sensor uses microelectromechanical system (MEMS) technology, where capacitive plates are attached to springs. When acceleration force is applied to the plates, the capacitance is changed; thus, it can be measured. Accelerometers can have 1 to 3 axis. The 3-axis accelerometer can detect the device's orientation, shake, tap, double tap, fall, tilt, motion, positioning, shock or vibration. Outputs of the sensor are usually digital interfaces like I2C or SPI. The accelerometer is often used with a gyroscope for precise measurement of the object's movement and orientation in space. Accelerometers are used to measure objects' vibrations, including cars, industrial devices, and buildings, and to detect volcanic activity. In IoT applications, it can also be used for accurate motion detection for medical and home appliances, portable navigation devices, augmented reality, smartphones and tablets.

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.

There are different elements available that allow measuring linear accelerations, angular accelerations, and magnetic fields, all 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 gyro, 3-axes accelerometer, 3-axes magnetometer). All of them can be programmed in an Arduino environment with the use of dedicated libraries. The latter automatically calculates additional information like gravity vector, and absolute orientation expressed as an Euler vector or as a quaternion.

Take a photo of MPU6050.

 IMU MPU6050 module
Figure 4: IMU MPU6050 module

Take a photo of MPU9250.

 IMU MPU9250 module
Figure 5: IMU MPU9250 module
 IMU BNO055 module
Figure 6: IMU BNO055 module
 Arduino Uno and IMU BNO055 module schematics
Figure 7: Arduino Uno and IMU BNO055 module schematics

The example code:

//Library for I2C communication
#include <Wire.h>
//Downloaded from https://github.com/adafruit/Adafruit_Sensor
#include <Adafruit_Sensor.h>
//Downloaded from https://github.com/adafruit/Adafruit_BNO055 
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55);
void setup(void)
{
bno.setExtCrystalUse(true);
}
void loop(void)
{
//Read sensor data
sensors_event_t event;
bno.getEvent(&event);
//Print X, Y And Z orientation
Serial.print("X: ");
Serial.print(event.orientation.x, 4);
Serial.print("\tY: ");
Serial.print(event.orientation.y, 4);
Serial.print("\tZ: ");
Serial.print(event.orientation.z, 4);
Serial.println("");
delay(100);
}
en/iot-open/hardware2/sensors_angle.1692955267.txt.gz · Last modified: 2023/08/25 06:21 (external edit)
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