3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

A MPU6050 based RTA app

Thu Apr 13, 2017 4:02 pm

I have written an app that lets you connect an MPU6050 IMU (accelerometer/gyro) to an rpi, collect data from it and then analyse that to investigate the response of whatever you're measuring. This is written so that the recorder, which runs on the rpi, is decoupled from the analysis server so that you can connect multiple sensors to a single server and control them as one.

The app is written in python with a js (react) front end, packages are published to pypi and there's a windows exe available via github.

I put a video to show how the UI works at https://youtu.be/pXOHOIwnnWw

Feature list is;

- collecting data from 1 or more connected sensors concurrently
- user defined target curves (via text based format or from uploaded wav files)
- charts available for each measurement
- time series data (vibration, tilt, raw data)
- frequency response data (spectrum, peak spectrum and psd)
- measurements can be analysed by axis of vibration or using a summed response (calculated using a root sum of squares method with more weight placed on x and y axis vibration)
- charts available for target curves
- frequency response data (spectrum, peak spectrum and psd)
- allows user to compare 1-n data sets in a single graph including target curves
- allows user to normalise curves against a chosen reference series

Docs are available at http://vibe.readthedocs.io/en/latest/
Source is on github at https://github.com/3ll3d00d/vibe
pypi packages at https://pypi.python.org/pypi/vibe-analyser/0.3.1 and https://pypi.python.org/pypi/vibe-recorder/0.3.1
windows exe (only tested on windows 8.1) at https://github.com/3ll3d00d/vibe/releases/tag/0.3.1
Last edited by 3ll3d00d on Wed Sep 11, 2019 7:35 pm, edited 1 time in total.

dkglover
Posts: 2
Joined: Thu Apr 11, 2019 3:09 pm

Re: A MPU6050 vibration measurement app

Thu Apr 11, 2019 4:31 pm

Dear Matt, I have been having a problem getting the vibration measurement app to work and I would really appreciate your help. The analyser portion running on a PC starts up fine but the recorder part running on a raspberry pi 3 crashes before start. Here is the output in the terminal window after launching the recorder:

Loading config from /home/pi/.vibe/recorder.yml
/home/pi/python/recorder/lib/python3.5/site-packages/core/BaseConfig.py:63: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
return yaml.load(yml)

Initialising http logger to log data to http://192.168.205.129:8080
Loading smbus 1
Loading mpu6050 mpu6050/500
Reactor reactor is starting

2019-04-11 12:24:53,429 - recorder.heartbeater - ERROR - sendHeartbeat - Unable to ping server
Traceback (most recent call last):
File "/home/pi/python/recorder/lib/python3.5/site-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/home/pi/python/recorder/lib/python3.5/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/home/pi/python/recorder/lib/python3.5/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
socket.timeout: timed out

Any advice that you can provide would be greatly appreciated.

Many thanks,
David

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 vibration measurement app

Fri Apr 12, 2019 5:55 pm

the error says that the app on the rpi is unable to connect to the server within 0.5s (the timeout set in the code)

- is the server running when you start the recorder?
- if yes, if you login to the rpi, can you ping the server?
- if yes, can you try and hit the server's REST api? something like

curl http://192.168.205.129:8080/api/1/state

should complete ok

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 vibration measurement app

Fri Apr 12, 2019 10:20 pm

It's been a while since I've installed this so I thought I'd check it installs ok these days. I did a fresh install of the latest stretch minimal image, did the basic network config and then installed the recorder from pypi. No problems seen.

dkglover
Posts: 2
Joined: Thu Apr 11, 2019 3:09 pm

Re: A MPU6050 vibration measurement app

Mon Apr 15, 2019 4:37 pm

Hi Matt, thank you very much for your reply. I was able to get the system working by installing Ubuntu on a PC and running the analyser under that OS. This method works to bring up the UI which shows the recorder detected. I am able to change settings on the acclerometer with the update device button. However, every time I schedule a measurement it fails. Does this app only allow analysis after the measurement is complete? I thought it would allow me to display RMS or PSD calculations in real-time while streaming the data to a file but after exploring the menu options in more detail, it looks like the analysis is only after completing the acquisition.

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 vibration measurement app

Wed Apr 24, 2019 8:06 am

Measurement failure typically means one of

- the data overflowed, i.e you were unable to read data off the FIFO buffer in the chip quickly enough
- a sample exceeded the sensitivity limit

The reason should be somewhere in the recorder logs

For the former, you can reduce sample rate or the amount of data collected per sample (eg turn off the gyro) as one option. It is a fixed size buffer on the chip so either option gives you more time to read the available data. It may also suggest a wiring problem limiting bandwidth on the serial bus or perhaps you can look at increasing bus speed on the rpi.

For the latter, change the sensitivity setting and remeasure.

There is no RTA in the app, would be v clunky with a web interface. Certainly possible to write one though using the available data.

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 vibration measurement app

Wed Sep 11, 2019 7:25 pm

dkglover wrote: Does this app only allow analysis after the measurement is complete? I thought it would allow me to display RMS or PSD calculations in real-time while streaming the data to a file but after exploring the menu options in more detail, it looks like the analysis is only after completing the acquisition.
I have rewritten this app so the analyser is a (py)Qt app (with binaries built for windows, OSX and a certain flavour of linux) & the recorder is also updated to use a more efficient/faster protocol over the network. It has most of the features from the old app but adds an RTA view as well as a speclab style scrolling live spectrogram view. The RTA easily maintains a 20fps update rate on my machine though it seems a bit clunkier on windows so performance may vary. Quick example in https://www.youtube.com/watch?v=3dJteeiPq9w (though that has averaging turned on hence the apparently v slow update rate).

analyser -> https://github.com/3ll3d00d/qvibe-analy ... /tag/0.3.7
recorder -> https://github.com/3ll3d00d/qvibe-recorder (so is installable using pip install qvibe-recorder)

PiXplorer
Posts: 1
Joined: Tue Oct 08, 2019 12:04 pm

Re: A MPU6050 based RTA app

Tue Oct 08, 2019 12:07 pm

What is the practical highest sampling rate for the accelerometer using the setup described? I would like to measure transmission of vibration from power tools to the hand and would need to go 1kHz and maybe more. Would it be possible to use a MPU6000 with SPI instead?

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 based RTA app

Tue Oct 08, 2019 1:18 pm

Maximum sampling rate for the mpu60x0 accelerometer is 1kHz, this is not dependent on the interface used,it is a limitation of the sensor itself. I can see whether it is stable at this rate over i2c.

danjperron
Posts: 3402
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: A MPU6050 based RTA app

Tue Oct 08, 2019 10:54 pm

Wow pretty cool software.

I look into your code and I was surprise that some of your code was reference to one of my own.

Keep the good work! I'm impress!

Daniel Perron

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 based RTA app

Wed Oct 09, 2019 9:59 pm

Thanks, your code was extremely useful when getting this going :)

a pi0 is not stable at 1kHz at least not with a 100kbit/s i2c bus, I'll try a rpi3 to see if that is better behaved

danjperron
Posts: 3402
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: A MPU6050 based RTA app

Wed Oct 09, 2019 10:22 pm

An I2C clock at 100KHZ can't read all the data of the MPU6050 using a rate of 1000 samples/sec.

start bit + I2c address + 1 bit for r/W + 14 byte + 15 acknowledge + stop bit = 137 clock => 100KHz / 137 = 730 packets read / sec.


The mpu6050 is rated for 400KHz clock! How the PI0 behaves when the i2c clock is 400KHz?


Update *** Forget the register address then it is 146 clock. The theoritical max is 685 samples/ sec at 100Khz clock.
Last edited by danjperron on Thu Oct 10, 2019 11:12 am, edited 1 time in total.

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 based RTA app

Thu Oct 10, 2019 6:39 am

I turned off the gyro and temperature sensor to reduce the load, this saves 8 bytes per sample so I think it should be able to fit at normal i2c speed. I can try a higher speed though aswell.

3ll3d00d
Posts: 9
Joined: Thu Apr 13, 2017 3:52 pm

Re: A MPU6050 based RTA app

Fri Oct 11, 2019 8:04 pm

rpi3 is perfectly stable at 1kHz with a 400kbit/s i2c bus speed, rpi0 (for me anyway) . I find you need to reduce the network publish rate to ~20Hz to keep it stable on the rpi0 whereas the rpi3 can keep up at 50-100Hz or so (if you need a really fast update rate on the UI that is... not sure why you would be useful to have the option!)

Return to “Automation, sensing and robotics”