sensors(imu) - qopter · overview quadrotor lab • 1. week: introduction usart basics serial...
TRANSCRIPT
Sensors(IMU)Inertial Measurement Unit
MPU6050
Emqopter GmbH
Introduction quadrotor lab
IMU (Inertial Measurement Unit)
TWI (Two Wire Interface)
EMQ Framework
Exercises
2
Time scope: 1-3h
Programming a quadrotor flight control software
Step by step development of software components
Exercises build on one another
What are the parts of flight control?
Sensors (IMU)
Signal processing (filter, conversion into quaternions, etc.)
Control (attitude control, yaw control, 3 DOF control)
Steering (automation, commands)
Communication (telemetry, telecommands)
3Emqopter GmbH
4Emqopter GmbH
Sensors (IMU)Signal processing
ControlActuators
5Emqopter GmbH
Overview quadrotor lab• 1. week: Introduction USART Basics serial interface• 2. week : Introduction DIP Basics display control• 3. week : Sensors (IMU) Basics framework, sensor control, calibration• 4. week : Signal Processing Presentation of orientation as quaternion• 5. week : Actuators and Attitude Control Driving the motors and controlling of one horizontal axis (1 DOF)• 6. week : Yaw Control Controlling the pitch axis and superposition of two axes (2 DOF)• 7. week : 3DOF Control Controlling all 3 degrees of freedom• 8. week : Automation Automation: Executing automatically controlled maneuvers
DOF = Degree of Freedom
6Emqopter GmbH
Definition:A IMU is the combination of several inertial sensors. Most commonly used is a tri axial set up of accelerometers and gyroscopes. The IMU is the sensor unit of an inertial navigation system which captures changes in position and orientation. These can be used as inputs for the orientation representation of an attitude control.
Position determination (1D, simplified):
𝑃 = 𝑎
Orientation determination (1D, simplified):
𝜑 = 𝜔
Emqopter GmbH
IMU ITG/MPU:
MPU 6050
Gyroscope + Accelerometer
Driven via TWI
Datasheets:
IMU_MPU_6000+6050_RegisterMap.pdf
IMU_MPU_6000+6050_Sepcs.pdf
The sensor has to be configured and
calibrated before use.
7
Emqopter GmbH
Functional principle of a Gyroscope (Gyro):• Measurement principle Coriolis force (analogous to Lorentz force):
• Moving parts (v) (cause)• Simultaneous rotation (w) (mediation)
-> Effect: force (F) perpendicular to cause and mediation• Force is perpendicular to rotation axis and movement• Occurs in rotating reference frames (w) during simultaneous
movement (v)• F = - 2 ∙ 𝑚 ∙ 𝜔 ∙ 𝑣
• MEMS: Micro-Electromechanical systems• Tri axial (x,y,z = 3 DOF)• Rotation rate sensor: Captures rotation speeds• Measurement method: capacitive
8
Rotation w
Speed v
Force F
Emqopter GmbH
Functional principle of an Accelerometer (Acc):• Measurement principle: Spring mass principle
• Two rows with capacity C1 and C2
• Changing distances because of inertia• Capacitive Measurement of distance changes
• MEMS: Micro Electromechanical system• Tri axial (x,y,z = 3 DOF)• Acceleration sensor: Captures accelerations
(translational)
9
C1 = C2 C1 > C2
F = m ∙ a
Emqopter GmbH 10
TWI
Serial Master-Slave-Bus
Also named I²C or I2C (inter-Integrated Circuit)
2 Bus lines: SCL (serial clock), SDA (serial data line)
Advantages: cheap, few wirings
Disadvantages: Prone to failures, short maximum wire length
Clock modes: Standard up to 100 kHz, Fast Mode up to 400 kHz
Transmission rate: max. 3,4 Mbit/s (relatively slow)
Emqopter GmbH 11
TWI Data exchange
Start signal
1 Byte Address (7bit) + R/W (1bit = 1 for Write)
ACK (from Slave)
Byte wise Data packages each acknowledged
Stop signal
The address is the I²C/TWI Slave Address of the participant spoken to.
Implementation:
Use TWI Framework
Data packages:
At least 2 Bytes in AVR Framework
1. Byte: Command or address for R/W
2. Bytes + following for Data (R/W)
Using burst mode, several bytes beginning from a
certain start address are transmitted.
Emqopter GmbH 12
TWI Framework
Uses struct twi_package_t
chip = TWI Slave Address
addr = Command
addr_length = Length of the command in Bytes
(usually = 1)
buffer = Pointer to memory area of Data Send / Write (W): these data are transmitted Receive / Read (R): this is where the received data is stored
length = number of bytes being transmitted / received
typedef struct
{
char chip;// TWI Slave Address
unsigned int addr;// Command Byte to be sent
int addr_length;// Amount of Command Bytes
void *buffer;// Buffer for Data (Send/Receive)
unsigned int length;// Amount of Data Bytes
} twi_package_t;
Emqopter GmbH 13
TWI Framework Examplechar data_received_mpu_acc[6];twi_package_t packet_mpu6000_acc;
packet_mpu6000_acc.chip = 0x69;packet_mpu6000_acc.addr_length = 1;packet_mpu6000_acc.length = 6;packet_mpu6000_acc.addr = 0x3B;packet_mpu6000_acc.buffer = data_received_mpu_acc;
read_from_twi(&packet_mpu6000_acc, 0);
After this command, the 6 data bytes from the sensor memory starting with address 0x3B are copied into the MCU memory starting from address data_received_mpu_acc.
In case of an error a message is displayed. The second parameter, here 0, is used to identify the error source.
Read / receive data:
read_from_twi(const twi_package_t *twi, int error_id);
Write / transmit data:
write_to_twi(const twi_package_t *twi);
Emqopter GmbH 14
IMU configuration Read the sensor data sheet to find out how to configure the sensor. Write 5 x 1 Byte for configuration (check table for recommendation). Attention: buffer must be a pointer to the data given below. TWI address: chip = 0x69 Alternative: chip = 0x68
Configuration Command (addr) Configuration Data (buffer) Function
0x6B 0x03 Power Mode (z-Referenz)
0x19 0x09 Samplerate 10ms
0x1A 0x04 1kHz DLPF mit 19ms Delay
0x1B 0x10 +/- 1000°/s
0x1C 0x08 +/- 4g
Emqopter GmbH 15
EMQ Framework Delivered as library with open source part Developed exclusively for the quadrotor lab Contains drivers with functions for
Hardware: CPU, IRQ, TC, Remote, ADC, USART, TWI, Delay, motors, LED Software:
Basics for easy start Function templates
For details check software documentation: EMQ_Framework.pdf The EMQ Framework does not use an operating system The whole codes runs in an endless loop (while)
EMQ Data types The file EMQ_Interface_Data.h contains several available EMQ data types Data types including dummies are meant to be filled with content later on. All other data types should not be changed! The system time is available in the variable tc_ticks [ms].
Emqopter GmbH 16
Required hardware: EVK1100 Micro USB cable for power and flashing USART cable for communication: RS232 on PC (RS232 or USB) Sensor MPU6050 + Extra cable
Required software: AVR Studio 32 (with Tool Chain and FLIP Driver) EMQ Framework (Code) Documents:
EMQ_Framework.pdf IMU_MPU_6000+6050_RegisterMap.pdf IMU_MPU_6000+6050_Sepcs.pdf
Emqopter GmbH 17
Exercise 1a:Get familiar with the EMQ Framework. Read the documentation and have a look at all the source code files before you start.
Exercise 1b:Configure the sensors. Fill out the function my_imu_init(). Use the values from the table on slide 14 together with the framework from slides 12 and 13.
Exercise 1c:Read and condition the sensors. Check the data sheet to get the address of the register, which contains the sensor data. Conditioning means transforming the raw values into correctly scaled values. Each sensor delivers 6 bytes, which means one high byte and one low byte for each axis.
The scaling factors are 8.192 for ACC and 32.8 for GYRO.
Emqopter GmbH 18
Exercise 2:Calibrate the sensors by using a mean value over several measurements for bias compensation. The number of measurements over which the average is built should be easy to change. The gyro is to be calibrated on 0/0/0, the Acc is to be calibrated on the gravity vector.
Exercise 3a:Implement the one dimensional integration of the gyro measurements, by integrating each of the three axes independently. A rotation over 90° should be captured as a 90° rotation!
Hint:The sensor should lie on the table and be connected with the extra cable.
Exercise 3b:Use the display to show the 3 angles. Modify the renew_display() function to solve the task.