This project implements a high-speed data acquisition system for three ADXL355 accelerometers using a Raspberry Pi and a host computer. The system captures acceleration data at 1000 Hz from each accelerometer and streams it to a host computer for storage and analysis.
- Raspberry Pi: Acts as the data acquisition device, interfacing with three ADXL355 accelerometers via SPI and streaming data over TCP/IP.
- Host Computer: Receives the streamed data, processes it, and stores it in binary files for further analysis.
- ADXL355 Accelerometers: High-precision, low-noise 3-axis accelerometers.
/home/bvex/accl_c/accl_tx.c
: C program for data acquisition and transmission/home/bvex/accl_c/accl_tx
: Compiled executable ofaccl_tx.c
/home/bvex/accl_c/logs/
: Directory for log files
accl_rx.c
: C program for receiving and storing dataaccl_rx
: Compiled executable ofaccl_rx.c
run_accl.sh
: Bash script to automate compilation and executionlogs/
: Directory for log files
[Previous content remains the same]
ADXL355 Pin | Raspberry Pi Pin | Accelerometer 1 (SPI0) | Accelerometer 2 (SPI0) | Accelerometer 3 (SPI1) |
---|---|---|---|---|
MOSI | PIN 19 (SPI0 MOSI) | Connected | Connected | - |
MISO | PIN 21 (SPI0 MISO) | Connected | Connected | - |
SCLK | PIN 23 (SPI0 SCLK) | Connected | Connected | - |
CS | PIN 24 (SPI0 CE0) | Connected | - | - |
CS | PIN 26 (SPI0 CE1) | - | Connected | - |
MOSI | PIN 38 (SPI1 MOSI) | - | - | Connected |
MISO | PIN 25 (SPI1 MISO) | - | - | Connected |
SCLK | PIN 40 (SPI1 SCLK) | - | - | Connected |
CS | PIN 12 (SPI1 CE0) | - | - | Connected |
VDD | 3.3V | Connected | Connected | Connected |
GND | GND | Connected | Connected | Connected |
Note: Ensure that you connect the VDD (power) and GND (ground) pins of each accelerometer to the appropriate 3.3V and GND pins on the Raspberry Pi, respectively.
Raspberry pi 4 and above models have two SPI busses that can be used simultaneously. In this case since we are reading out three SPI sensors, we need to access the 2nd SPI bus on the pi called SPI1. To activate that add this line to "/boot/config.txt":
dtoverlay=spi1-3cs
- GCC compiler
- SPI kernel module enabled
To enable SPI:
- Run
sudo raspi-config
- Navigate to "Interfacing Options"
- Select "SPI"
- Choose "Yes" to enable SPI
- Reboot the Raspberry Pi
- GCC compiler
- Bash shell
-
Clone this repository on both the Raspberry Pi and the host computer.
-
On the Raspberry Pi:
cd ~/accl_c gcc -o accl_tx accl_tx.c -lm
-
On the host computer:
gcc -o accl_rx accl_rx.c
-
Ensure that the
run_accl.sh
script has execute permissions:chmod +x run_accl.sh
-
Update the
SSH_OPTIONS
inrun_accl.sh
with the correct path to your private key for SSH authentication.
-
Connect the ADXL355 accelerometers to the Raspberry Pi according to the pin connection table above.
-
Ensure both the Raspberry Pi and host computer are on the same network.
-
On the host computer, run the
run_accl.sh
script:./run_accl.sh
This script will:
- Compile the C programs on both the Raspberry Pi and host computer
- Start the data acquisition program on the Raspberry Pi
- Start the data reception program on the host computer
- Display the elapsed time of the data acquisition process
-
To stop the data acquisition, press Ctrl+C in the terminal running
run_accl.sh
.
The received data is stored in binary files in the outputs
directory on the host computer. Each accelerometer's data is saved in a separate subdirectory:
outputs/[timestamp]-accl-output/accl1/
outputs/[timestamp]-accl-output/accl2/
outputs/[timestamp]-accl-output/accl3/
Each subdirectory contains binary files with chunks of data, named in the format: [start_time]_chunk_[number].bin
- Raspberry Pi:
/home/bvex/accl_c/logs/[timestamp]_accl_tx.log
- Host Computer:
logs/[timestamp]_accl_rx.log
- Script Log:
logs/run_accl_[timestamp].log
These log files contain important information about the data acquisition process, including any errors or warnings.
- To change the sampling rate, modify the
ADXL355_ODR_1000
definition inaccl_tx.c
. - To adjust the acceleration range, modify the
ADXL355_RANGE_2G
definition inaccl_tx.c
. - To change the data chunk duration, modify the
CHUNK_DURATION
definition inaccl_rx.c
.
Use the provided jupyter notebook called accl_data_analysis.ipynb to plot the data from the three accelerometers.
-
Connection Issues: Ensure that the Raspberry Pi and host computer can communicate over the network. Check firewalls and network settings.
-
SPI Errors: Verify that SPI is enabled on the Raspberry Pi and that the ADXL355 accelerometers are correctly wired.
-
Permission Errors: Ensure that the user has the necessary permissions to access SPI devices and create log files.
-
Data Reception Issues: Check that the correct IP address and port are used in both
accl_tx.c
andaccl_rx.c
.
Mayukh Bagchi