Slow progress waiting for parts to arrive, time-wasting boobs and many 'Person From Porlock' visits!
Anyway, the first accelerometer module failed because it processes data to remove vibration, making it great for stabilising a quadcopter and useless for detecting vibration. So I bought a simpler module allowing its sensors to be read directly and transferred the whole project on to a RaspberryPi3B+, cost about £35. This is a small general purpose computer, considerably more powerful than an Arduino, not ideal for time-sensitive electronic control projects because it's multi-user/multi-tasking, but – unlike a PC – it exposes 40 General Purpose Input-Output (GPIO) pins suitable for electronic projects. (The closest a PC ever came to providing a hobby friendly interface is the obsolete parallel printer port.) The 3B isn't as fast as a Pi4 but it uses less power, better if the computer is run off a battery in a messy workshop.
The RaspberryPi GPIO is far more delicate than an Arduino so take care – over-volting or drawing excess current might brick the whole computer, which is why PCs don't let you do it! On the plus side, the Pi has a full Linux OS with all the tools needed to capture data, crunch the numbers, and display the answers.
The Pi3 and MCU6050 module are connected together thus:
The 10nF, 10k and 2k resistors are needed to suppress electrical noise which in my workshop are enough to crash the I2C data link (SCL and SDA). Arduino I2C is relatively bomb-proof!
In operation Pi & sensor are plonked on the headstock and powered on. Note the sensor is weighted down.
The PI connects to my home network over wifi so the program can be started remotely. It reads the sensor and – when a button is pressed – logs a stream of X,Y & Z accelerometer values to a time-stamped file. Pressing the button again closes the file. Many timestamped logs can be taken. A second program reads logfiles, does the maths, draws the graphs, and saves them as a jpg:
The graphs suggest my lathe doesn't have a vibration problem at the frequencies detected by a MCU6050! The signal graph shows the module detecting small movements when cutting metal, worst when I hit the shoulder at the end. The maximum frequency detected by this set-up is 100Hz because the module can only report 200 samples per second.
The FFT analysis shows no big frequency peaks. And the zoomed in signal looks like noise: random small amplitude vibrations in all directions.
Neil suggested balancing a penny as a simple way of detecting vibration and my WM280 passes this test too, at any RPM:
And on the saddle, even when cutting with power traverse.
Python3 programs here.
mcuaccel.py reads the sensor. The import modules used should all be pre-loaded with the Pi Rasbian operating system. The log file is human readable.
mcugraph.py does the analysis. It requires scipy, numpy and matplotlib to be downloaded and installed from the command line with:
sudo apt install python3-dev
sudo apt install libffi-dev
sudo apt install python3-matplotlib
sudo apt install python3-scipy
(Installing scipy should also install numpy)
Next steps – follow up on earlier comments made by Andrew, Joe and Leslie and try some different sensors! Conclusions so far: it's possible but may not be worth the effort!
Dave
Edited By SillyOldDuffer on 29/06/2020 12:35:54