Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Clock and accelerometer speed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Clock and accelerometer speed

by drborst on Thu Oct 31, 2019 8:28 pm

I'm trying to measure vibration. The system I'm measuring has motors that spin at about 5, 53, and 150 Hz. I need to sample at 300 Hz to capture the 150 Hz spin and if it wobbles and I get a harmonic, I should double that to 600 Hz. (in general, the faster the better)

So far I've been using CircuitPython on a Feather M4 express with an Adalogger Featherwing. This is a code snippet:
>>> t_log[i]=time.monitonic() = t_start
>>> x[i]. y[i], z[i] = accelerometer.acceleration
>>> i = i+1
>>> if i == 1024... [flush the array to disk and reset i to 0]

I chose 1024 for convenience. I'll FFT the data in 1024 chunks later.

1. The RTC doesn't seem fast enough. I generally get the time number repeated between 1 and 14 times, then it changes by between 0.033 and 0.068 seconds, if it changes on consecutive measurements, it changes by 0.0033 seconds (meaning I'm sampling at about 300 Hz).

2. The Feather seems uneven. Its hard to tell with the time issue above, but looking at the wave form with only 1 motor running, it kinda looks like it grabs samples in bunches of 8-10 at 500 Hz sampling, then takes a small break (like maybe the bus is blocked by the time read?)

3. The disk is slow. I can tolerate the 0.5s breaks at the flush to disk operation, but would love to be able to eliminate those.

So here's the questions:
1. Would swapping the MSA accelerometer for something else help?
2. Should I use the SPI bus instead of I2C?
3. Should use arduino instead of circuiit python?
4. Would it be faster if I moved to a Raspberry Pi? (and by faster, I mean faster sampling).

Any advice would be appreciated.

drborst
 
Posts: 10
Joined: Wed Nov 12, 2014 2:43 pm

Re: Clock and accelerometer speed

by franklin97355 on Thu Oct 31, 2019 8:49 pm

I'll answer #3. Circuit Python is an interpreted language which means each instruction needs to be read then processed. That takes time and is not the best choice for time-dependent processes.

franklin97355
 
Posts: 21586
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Please be positive and constructive with your questions and comments.