Code Monkey home page Code Monkey logo

drone-data-acquisition-subsystem's Introduction

Description

This project is powered by a STM32F767ZI and a X-NUCLEO-IKS01A2.

It consists in a FREERTOS based data acquisition subsystem as part of a flight control software for a rotary-wing drone.

By using the HAL provided by ST, the task taski2cR() acquire the following RawData from the sensors on the IKS01A2 and save it on the sensorData struct:

  • LPS22HB Barometer Sensor polled with ODR set to 50 Hz.

Data is acquired in Hectopascal (hPa).

  • LSM6DSL* Accelerometer Sensor polled with ODR set to 833 Hz, FS = ±2 with 0.61 mg/LSB sensitivity.

Data is later converted into the tridimensional vector of acceleration (rad·sec^−1).

  • LSM6DSL Gyroscope Sensor polled with ODR set to 833 Hz, FS = ±2000 with 70 mdps/LSB sensitivity.

Data is later converted into the tridimensional vector of angular speeds (rad·sec^−1).

  • LSM303AGR* Accelerometer Sensor polled with ODR set to 200 Hz, FS = ±2 g with 3.9 mg/LSB sensitivity.

Data is later converted into the tridimensional vector of acceleration (rad·sec^−1).

  • LSM303AGR Magnetometer Sensor polled with ODR set to 100 Hz, 1.5 mgauss/LSB sensitivity. Data is later converted into the tridimensional vector of magnetic flux (microT).

*Accelerometer RawData from the LSM6DSL and the LSM303AGR is then averaged and saved on a data struct.

A second task startPrintUart() , operating at 0.5hz, uses a custom _write() function to transmit real-time data over UART which can be read from the console.

Scheduling

The 5 tasks tControlMotor(), tAttitude(), tAltitude(), startPrintUart() and taski2cR() have been scheduled according to Rate Monotonic Scheduling.

Moreover, the system appears to be compliant with CPU utilization estimations (0.3844 < 0.7568) and the Hyperbolic Bound for RM results in 1.4046 which is below the 2.0000 threshold. It's fair to assume that the system is fully compliant with the scheduling implementation.

Given the inability to provide thread-safe I2C communications between the Nucleo board and the shield when using the HAL provided by ST in the case of running multiple tasks accessing to the I2C bus in a non-mutually exclusive way, I made the architectural decisions to use a single task running at 500hz to acquire data from the 4 sensors.

Considering that both taskI2cR() and startPrintUart() appear to write and read on the sensorData struct I decided to use the osSemaphores provided by FREERTOS to introduce a simple but functional binary semaphore to grant mutually exclusive access to the data stored in the struct.

Since startPrintUart() is the lowest priority task among the existing ones and since we are in a system where the use of preemption is allowed, one could generate the case in which startPrintUart, following the acquisition of the semaphore is interrupted by taskI2cR() which would not be able to acquire the semaphore that has not yet been released by the other task.

This was solved by implementing the Priority Inheritance Protocol (PIP): at the start of the StartPrintUart task, I therefore decided to immediately raise the priority level of the task via the primitive printUart_attributes.priority = osPriorityNormal7 which temporarily allows the task to inherit the priority of the higher priority task, i.e. taskI2cR, and then acquire the semaphore, print, release the semaphore and finally return to its original priority via printUart_attributes.priority = osPriorityNormal3.

Vid.20230629.101619.mp4

drone-data-acquisition-subsystem's People

Contributors

fnnn98 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.