# Sensors

## IMU

Reading of the 3D digital angular rate sensor, the 3D digital magnetic sensor and temperature sensor is performed by I2C bus. Data received from sensor are in raw value, and to get the actual measurement, conversion is required.

### Calibration

#### Magnetic sensor calibration

Magnetic sensor calibration should be performed in a magnetic-neutral environment, for example in a park. IGRF-12 model is used to get a vector magnitude of the reference magnetic field $$|\vec{b\_r(i)}|$$ in a given location. Raw data from the sensor is gathered while the sensor is being rotated in every axis. Then the data is processed to calculate matrix A and vector o. To achieve calibration parameters, minimalization of the goal function $$\sum\_{i=1}^{n} \[|\vec{b\_r(i)}| - |\hat{\vec{b}}(i)|]^2$$ is performed. The figure bellow shows calibration results, where red points are raw data and green points are calibrated measurements.

![Magnetic sensor calibration results](https://304735622-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L_OaaGq_sXQV0Tmp9Pu%2F-Lusj5qrvZb-6uWo8rcs%2F-LuskeOVnxhKfYAGTYb4%2Fmag_pomiar_3d.jpg?alt=media\&token=710d2056-77ab-4b50-990c-d046166cf464)

#### Angular rate sensor calibration

Angular rate sensor calibration is performed on a rotating platform. The speed of the platform is constant, known and can be changed. First, the platform has no angular velocity. Raw measurements are collected and based on them, linear translation $$\vec{o}$$ is calculated. Then the platform is accelerated to given various constant rotation velocities and raw measurements are collected once again. Based on them, the scale factor $$K$$ is calculated.

## Temperature sensors

There are three temperature sensors in the payload. The first is built into the microcontroller and provides information about its temperature. The other is on the IMU circuit board and measures the temperature on the gyroscope and magnetometer chip. The third is near F.R.W. and monitors the temperature of the electromagnets.

| Sensor                             | Interface                              |
| ---------------------------------- | -------------------------------------- |
| Microcontroller temperature sensor | Analog to digital converter            |
| IMU temperature sensor             | Inter-Integrated Circuit (I2C)         |
| F.R.W. temperature sensor          | Serial Peripheral Interface&#xD; (SPI) |

All the sensors require simple conversion of raw value with a linear equation. Coefficients of that equation are obtained by performing linear regression on reference measurements.

$$
x \text{ - raw sensor value}\\
t \text{ - real sensor value}\\
t\_k, t\_0 \text{ - temperature regression coefficents}\\
t(x) =t\_k \cdot x + t\_0
$$

Calibration was performed using a climate chamber. The temperature range for  the regression is from  -20°C to 50°C.

![Microcontroller (ucTemp) and F.R.W (tempFRW) sensor calibration results](https://304735622-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L_OaaGq_sXQV0Tmp9Pu%2F-LvMpkYBb3tGY-bju6a5%2F-LvMrHqgBeYABAskPNoh%2Fimage.png?alt=media\&token=5d8ff65b-333e-4e99-aea9-7098996051f7)

![IMU (tempIMU) sensor calibration results](https://304735622-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L_OaaGq_sXQV0Tmp9Pu%2F-LvMpkYBb3tGY-bju6a5%2F-LvMqvEZQVAEGPR4dvi-%2Fimage.png?alt=media\&token=714b513a-67d7-4a62-ac55-e437787dbae1)

Based on the measured temperatures, linear regression coefficients were determined for all sensors.

| Regresion results | tk      | t0       |
| ----------------- | ------- | -------- |
| ucTemp            | 0,93216 | 7,88081  |
| tempIMU           | 0,05858 | 30,73653 |
| tempFRW           | 0,98121 | -2,00320 |

The determined coefficients were introduced into the temperature determination software.
