update: link to source code for IMU to Matlab connection
The next steps for the wave buoy project involves collecting accelerometer and gyroscope data from the onboard IMU and filtering/processing the data with a laptop to determine orientation and position. The math needed to perform these computations is too much for an arduino alone, so for now I plan to transmit the IMU data to my laptop with an Xbee and let the laptop do all the heavy lifting. Later on, the laptop will be replaced by a Raspberry Pi or other Linux based computer board, but for now it easier for me to develop everything in Matlab and then convert the code to C/C++ or something else in the future. Just personal preference.
I started by incorporating an arduino + xbee + accelerometer and wirelessly sending the data to my laptop for a class project. Some of the steps were covered in a previous post, which also had links to very helpful videos. Sine learning how to send data with the Xbee to Matlab over serial, I created a program to measure mechanical machine vibrations for a graduate level Advanced Manufacturing Technologies class. The goal of the class project was to build a wireless sensor that could be mounted inside a machine in order to detect an undesirable phenomena called “chatter” that occurs during drilling, turning, and milling of metals. You may be familiar with chatter if you have ever heard a high pitched noise when drilling into a piece of steel or using a milling or turning machine and the cutting tool began to vibrate uncontrollably. Example video of chatter at 0:24 min.
To visualize this vibration data and have the program alter the operator when chatter was detected, I created a graphical user interface (GUI) in Matlab to plot the acceleration data in near real time on the laptop. There was a slight delay between transmitting serial data with the Xbee and plotting the data in Matlab, so it was as close to running in “real time” as I could get, given the hardware limitations and time restraints. The GUI gave the operator the ability to choose two filtering methods, a simple moving average (SMA) and a exponential moving average (EMA), before calculating the vibration frequencies and their relative magnitudes using a Fast Fourier Transform (FFT). These two filters options were replicated from this video. In this way, it was possible to determine if the measured vibrations were typical mechanical vibrations due to the movement of the machine, or undesirable chatter vibrations due to the tool and workpiece interacting close to the natural frequencies of the mechanical system.
From the image above:
a. option to filter incoming accelerometer data
b. if filter selected, use slider bar to set filter setting
c. near real-time visualization of accelerometer data (note it is noisy, thus filtering usually needed).
d. option to upload a saved CSV file from historical measurements for analysis
e. visualization of discrete Fourier transform showing magnitude and frequencies calculated from filtered accelerometer data
f. milling process parameters used to calculate the expected theoretical chatter freq.
g. threshold line to set minimum required magnitude before the chatter alarm was triggered
i. based on detected chatter, algorithm would suggest the closest optimal spindle speed to eliminate chatter problem
h. visual alarm: blue for no chatter, turns red to indicate chatter was detected
The significance of this project is that it gave me a chance to brush up on FFT calculations in Matlab and also create a GUI to visualize the accelerometer data steaming from the Xbee. I plan to use similar GUI for testing various IMU sensors when benchmarking their performance so having this code already built will save time. Additionally, dominant wave height and wave period can be calculated from FFT calculations, so this may also be beneficial to a later stage in the project once the IMU data has been filtered and corrected for buoy tilt.
The presentation slides and the class report are included below. The report has more details about the project as well as the Matlab and arduino codes.