Introduction: "Seismometer" Exercise Box
Using the Pmod ACL2, the WF32 and LabVIEW I made a simple exercise box that you jump on. It measures the quality of your landing, the time in-between each jump and the force of each landing. Before I made the decision to use the ACL2, I first tried out a simple tilt sensor. It didn’t have the sensitivity I was looking for.
This was my first time ever using any sort of Pmod, accelerometer and tilt sensor. Ever. We had a LabVIEW development brain storming session to discuss possible demos for NI Week in August. I said “shock wave related, maybe?” and this is what came out from the idea having gone around the room a few times.
I have had so much fun tinkering with the accelerometer and learning more about Pmods.
Step 1: Wiring It All Up
I used a simple storage box I grabbed from home to start and test. I first made sure the accelerometer was wired to the WF32 correctly. There is an example in the LabVIEW example finder that is named Pmod ACL2 and this will walk you through how to get started taking data with your accelerometer. Open LabVIEW, click Help -> Find Examples -> Search LINX -> select PmodACL2.
The ACL2 has 6 input ports – chip select (CS), master out slave in (MOSI), master in slave out (MISO), serial clock (SCLK), ground and high voltage. The WF32 has corresponding input ports – pin #10 corresponds to CS, #11 MOSI, #12 MISO, and pin #13 corresponds to the SCLK. The Pmod uses 3.3V so connect it to the digital output of the 3.3V on the board along with the ground port.
I used a small solder-free bread board to try my best to keep the wires semi-organized. If you decide to include a second accelerometer, then the breadboard will be even more important.
Step 2: Programming It All
In the LabVIEW program PmodACL2, you'll need to input the
Serial Port, SPI Channel and CS Channel in order to communicate with your WF32. The serial port is wherever your WF32 is plugged in to your computer – select something that looks sort of like COM3 (though yours might be different depending on where you have it plugged into your computer).
The SPI channel should always be set to 0. Our Chip Select channel should be 10 – that’s where the CS from our accelerometer is plugged into (pin #10) on our board. Keep the resolution at 2g for now, and keep the output data rate at 100 Hz.
The accelerometer should be all ready to go at this point. Run the LabVIEW VI and (carefully) wave your accelerometer around. You’ll see three separate waveforms – x, y, and z.
Notice how the data is pretty noisy, though? There are a few ways to filter that out. I merged the ACL2 code with the some filtering calculations and made a few changes, and that code is attached. The reason I decided to use two different while loops – one for data acquisition and one for calculations and filtering - is because they can run on separate cores of your processor (and in turn the filter works way faster) rather than the same one.
A different representation of the raw data is in the graph on the top and the filtered data is graphed at the bottom. The biggest thing is that you can adjust how the accelerometer data is filtered. Changing the values of the low frequency cut off, Gusse filter rate, number of data points averaged and the low pass filter order make a big difference on how much noise is filtered out.
For this project, I wanted to filter out the steps of people walking around the office. This accelerometer is pretty sensitive. Calibration is important to making sure you aren’t grabbing and reading data that isn’t related to the event you’re trying to look at. Make sure to play with it – adjust a value or two and run the program. Find the sweet spot with the smallest amount of noise while keeping a fair amount of detail in your waveforms from the jump itself. The low frequency cut off might be the most crucial of these settings. You don’t want to cut off too much, but just enough to keep ambient noise from overwhelming the raw data.
To filter out footsteps and co-workers jokingly jumping next to the box, I have my low frequency cut off at 7 Hz, low pass filter order set to 0, Gusse filter rate at 54 Hz and I’m averaging over 4 data points. This does it pretty well without sacrificing too much of our raw jump data.
I slowed the loop rate on the graphs to around 20 Hz in order to make it easier to read while the program is running by adding a timer into the data acquisition while loop, you may or may not want to keep it there.
Step 3: Get It All Set Up
For testing purposes, I just grabbed some electrical tape and taped my WF32 to the side of my storage box and the accelerometer to the top. Make sure they're pretty secure, you don't want to jump and cause anything to drop or become unplugged.
After this, put the top back on the box and you're done and ready to measure jumps, footsteps and any other "seismic" activity.