Skip to content

arpit6232/Embedded_Systems_MMA8451Q

Repository files navigation

Sensor_Fusion_PES

Project Goal and Repository Comments

  • Objective: To tie into the MMA8451Q accelerometer over I2C. Change the LED colors in response to the device orientation, and also use the LED (blinking pattern) to show sudden acceleration.

  • Contains Code for Final Project for Principals of Embedded Systems Software, ECEN-5813, Fall 2020 Only DEBUG Target is considered for this assignment whose goal is setting up an communication with MMA8451Q Sensor.

  • contact arpit.savarkar@colorado.edu

Repository for PES Final Project

Source Code for this assignment can be found under source /

  • main.c - The main script which forms the application entry point to the state machine which changes LED Colors based on current Roll and Pitch of KL25Z
  • bme.h - NXP Updated C Implemetation of the BME API based on Bit Manipulation engine Block Guide v0.3
  • clock.h - Header file for Instantiation and functionalities for clock and TPM/PWM
  • clock.c - Functionalities for Processor Clock and PWM with 48000 brightness level
  • delay.h - Header File for Busy Waiting
  • endian.h - Header file for Instantiation and functionalities to check endieanness of the Data generated from MMA8451Q
  • global_defs.h - Debug Functions Defines
  • i2c.h - Header file for Instantiation and functionalities for communication over I2C
  • i2c.c - Communication Function Setup for I2C based setup and analysis
  • i2carbiter.h - Header file for i2carbiter.h to settle a dispute or has ultimate authority in a matter in case multiple sensor update is required
  • i2carbiter.c - Functionality to settle a dispute or has ultimate authority in a matter in case multiple sensor update is required
  • init_sensors.h - Header file for init_sensors.c to instantiate MMA8451Q Inertial Sensor with appropriate settings.
  • init_sensors.c - To instantiate MMA8451Q Inertial Sensor with with appropriate Setup Configurations for Interrupt on Jerk and extreme acceleration.
  • led.h - Header file for Instantiation and functionalities for LED to interact with the PWM
  • led.c - Instantiates the LED to interact with the PWM/TPM and adjust brightness in accordance to MMA8451Q Tilt angles (Roll, Pitch). Green : Indicates Roll, Blue : Indicates Pitch Increasing Brightness indicates higher angles
  • mma8451q.h - Header file for DataSheet and DataStructures to handle interaction with MMA8451Q sensor.
  • mma8451q.c - DataSheet and DataStructures to handle interaction with MMA8451Q sensor.
  • statemachine.h - Header file of statemachine.c defining State Machine Function Prototypes
  • statemachine.c - File containing Statemachine functionalities implemented in accordance to Routine Vs Sudden Accleration States. Kindly refer to the image below for the state machine.
  • State Machine
  • sysclock.h - Header file for Instantiation and functionalities for system clock based on MCG
  • sysclock.c - Instantiation and functionalities for system clock based on MCG
  • systick.h - Header File for Mangement of Sytick Timer and Interrupt
  • systick.c - Sytick Timer every millisecond and Intrrupt
  • queue.h - Header file which contains the function prototypes and enumerators needed for queue.c
  • queue.c - The main script for instantiating and testing a Circular Buffer based Queue
  • test_queue.h - Header file which contains the function prototypes and enumerators needed for test_queue.h
  • test_queue.c - Function prototypes and enumerators needed for test_queue.h
  • UART.h - Header file which contains the function prototypes and enumerators needed for UART.c
  • UART.c - The main script for instantiating UART functionalities and handling Interfacing with the user

Project Comments

  • The MMA8451Q is a smart, low-power, three-axis, capacitive, micromachined accelerometer with 14 bits of resolution. This accelerometer is packed with embedded functions with flexible user programmable options, configurable to two interrupt pins.The device is configured to generate inertial wakeup interrupt signals from any combination of the configurable embedded functions allowing the MMA8451Q to monitor events.

  • State Machine

  • The State Machine has only 2 states, "Routine" which updates the LED's in accordance to the Tilt Angles and "Accel" which Flashes LED's according to current Angle, to indicate a Sudden Jerk is detected. The flags linked to these are updated in the IRQ Handlers.

  • Motion Detection (Jerk/Jolt) is used to simply alert the main processor that the device is currently in use has caused a sudden acceleration. When the acceleration exceeds a set threshold (2g along the Z-axis) the motion interrupt is asserted (In this repository it is 2g). A motion can be a fast moving shake. This will depend on the threshold (2g) and timing values configured for the event. The motion detection function is used in this project to analyze static acceleration changes or faster jolts.

  • RGB LED's on the processor react to the Acceleration values calculating Roll and Pitch with the processor is currently at by changing the Brightness of the Green LED (Roll) and Blue LED (Pitch) relating to higher brightness meaning for higher Angle.

  • Motion Detection for sudden acceleration: A Processor is considered to be in sudden acceleration if at any instant of time the acceleration along the X,Y axis is greater than 2G(G=9.81 m/s^2). The Processor is Configured to cause an interrupt and "FLASH" the LED's with on appropirate color to indicate that sudden acceleration was detected.

  • PWM Brightness for LED's has 48000 Levels, which increase in brightness as the Processor KL25Z is raised in angles.

  • The Calculations for PWM, Jerk Constraints can be found in the appropriate code under source directiory and are not discussed here in the README.

  • The Communication for Logging And Interaction with the processor is done 115200 Baud Rate, 8 Bit Parity, 1 Stop-Bit over UART.

  • As shown in the video below, MMA8451Q Sensor interacts with the processor using I2C. Kindly Jerk and hold the KL25Z to the jolted position. The goal here is to flash the LED's for a sudden change in acceleration and not pronounce to the user about detecting multiple jerks. Kindly refer to the video link at the end of the this README to understand what is mentioned here

Manual Test Routine

Refer to the [Manual Test Routine! for the manual Test cases routine, required for QA Testing.

Images of the Project over LED's

Pitch

  • Pitch

  • Video Link for Pitch Action

Roll

  • Roll

  • Video Link for Roll Action

Sudden Jerk/Acceleration

  • Video Link for Jerk/Jolt Action

Screen Output over UART

  • Terminal Output over UART

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published