vhdl

Interfacing 3-Axis Accelerometer Using SPI

Description

This project implements real-time interfacing of the on-board 3-axis MEMS accelerometer on the Nexys A7-100T (Artix-7) FPGA board using the SPI protocol. The FPGA operates as an SPI master, configures the accelerometer, continuously reads acceleration data, and displays the processed output on the on-board 7-segment display.

The entire design is written in Verilog HDL and runs purely in hardware, without any soft-core processor or embedded software. The project demonstrates practical sensor interfacing, SPI communication, clock management, and real-time digital display on FPGA.


accelerometer_06 accelerometer_05 accelerometer_04 accelerometer_03 accelerometer_02 accelerometer_01


Hardware Used


Project Overview

The system performs the following operations:

  1. Generates a suitable SPI clock from the system clock
  2. Configures the accelerometer via SPI
  3. Reads acceleration data from the sensor registers
  4. Processes and formats the data
  5. Displays real-time values on the 7-segment display

All modules are integrated at the top level and synchronized using deterministic hardware logic.


SPI Communication (Working Explanation)

SPI (Serial Peripheral Interface) is a synchronous serial communication protocol using four signals:

SPI Operation Sequence

  1. FPGA pulls CS low to select the accelerometer.
  2. SPI clock is generated by a divided system clock.
  3. Command and register address bits are sent on MOSI.
  4. Accelerometer responds with data on MISO.
  5. Data is sampled on the active clock edge.
  6. CS is pulled high to terminate the transaction.

The SPI master is implemented using a finite state machine to ensure correct timing, data alignment, and transaction control.


Accelerometer Working Principle

The on-board accelerometer is a MEMS-based sensor that measures acceleration along three perpendicular axes: X, Y, and Z.

Key characteristics:

In this project:


Real-Time 7-Segment Display Output

The acceleration data obtained from the sensor is mapped to the 7-segment display.

Display behavior:

The 7-segment control logic handles digit selection, segment encoding, and refresh timing.


Design Modules


Simulation

Functional simulation verifies:

Simulation waveforms are included in the repository to demonstrate correct operation.


Hardware Implementation and Results

A hardware demonstration video showing real-time changes on the 7-segment display is included in the repository.

image


Applications


Author

Swaroop Kumar Yadav
Electronics and Communication Engineering