0

I'm planning to use the ATMEGA328 and the ADXL335 accelerometer to monitor the bearing and gears vibration of a industrial extractor that works at maximum speed of 3000rpm at 380VAC - 50Hz .

The main scope of this monitoring is to get continuously the vibration readings and apply the FFT transform in order to identify if there is something that is not running well.

My primary concerns are regarding the sampling speed of the ATMEGA328P: i've tried to identify the needed sampling speed but i'm a little bit confused about the relation of motor/gear speed and the ADC sampling speed of the ATMEGA...also, the ADXL is the right choice?

15
  • 1
    According to nyquist-shannon you have to sample at 2x your maximum interesting frequency. That's probably the same as your max RPM, so 6000sps. You need to take 6000 readings per second from the ADXL, and if you want all three axes that's 18,000sps (if you want the values concurrently). The Arduino can (from a quick google) manage about 9615sps. – Majenko Jan 24 at 17:03
  • 1
    You could just about manage 1 axis with that. You could cycle through the three axes and take a sample block from each one and FFT it in turn I guess. – Majenko Jan 24 at 17:04
  • 1
    I fear the arduino approach is not the best, as long as you are fishing in the dark. You don't know what frequencies (fingerprints) you should expect. For research purposes you should use equipement with a wider and deeper view into the domain. Let's say an error leads to overtone frequencies of 23.000 HZ. Then none of the sensors you mentioned would suffice the pcb one would even get in resonance. And the arduino would be out of the race. Finding out what you need means finding the condition you have to search for. You may find some research results. Standing on the shoulders of giants. ;-) – Peter Paul Kiefer Jan 24 at 17:26
  • 1
    @Symon, I left an answer. Please remember to always leave purchase links, datasheet links, etc, for any specific device you are asking about in the future. Hopefully my answer sheds some light on the situation. A sound card could potentially be a great way to go, as they are designed to sample up to the hundreds of kilohertz usually, to sample high-quality voice, music, and audio. – Gabriel Staples Jan 26 at 2:06
  • 1
    Thanks for the support @GabrielStaples, for completeness, this is the sensor that i've picked: analog.com/media/en/technical-documentation/data-sheets/… – Symon Jan 26 at 8:06
2

My primary concerns are regarding the sampling speed of the ATMEGA328P

The ATmega328 can sample up to ~10ksps (kilo-samples-per-second) in normal configuration and at 10-bit ADC resolution, or reliably and with good (near 10-bit) resolution up to ~50ksps if you speed up the ADC clock. You can get even faster if you want to sacrifice a lot on sample resolution, but at faster speeds this processor is too slow to even reliably grab the data and transmit it or store it, so you should go to a much much beefier and better microcontroller, such as a 32-bit Arduino Zero, Portenta, or non-Arduino STM32 or something.

Example of speeding up the ATmega328 to sample up to ~50kHz:

See my library here, and my initial article on it here.

#include <eRCaGuy_NewAnalogRead.h>

void setup()
{
    adc.setADCSpeed(ADC_FAST); // now analogRead() will operate up to ~50 kHz
}

void loop()
{
    // these readings can now be done up to ~50 kHz
    uint16_t reading = analogRead(A3); 
}

I don't remember the exact details of configuring the ADC clock, but it's all in the ATmega328 datasheet, and in my code--which you can study at the library link above, and you can look at Nick Gammon's website on it here: https://www.gammon.com.au/adc.

How fast do you need to sample? Only you can answer that question.

Perhaps you read some academic paper that says that vibrations of 102kHz on a 5cm diameter motor made of material X can cause microfractures in the material if exposed for 100 hours. Well, in this case, you need to sample at at least 204kHz (2x the frequency of interest) to see if 102kHz vibrations exist.

Or, perhaps you just want to use FFT to determine the RPMs of the motor since it will almost certainly have a dominating frequency at its rotational frequency due to imperfect balance of the motor. In that case, sampling at 2x the max RPM (but in samples per second, not minute) is sufficient. You stated a max rotational speed of 3000 RPM, so that's 3000 rot/min x 1 min/60 sec = 50 Hz. To detect your RPM, therefore, by sampling vibration, you need to sample at least 2x as fast as this, or 100 Hz or higher.

Remember, this is all Nyquist frequency stuff. All that the Nyquist frequency says is [in my own words]:

you can only detect a frequency up to 1/2 as high as your sampling rate

...or otherwise stated [in my own words]:

you must sample at 2x whatever frequency it is you are trying to measure

Any sample rate lower than this, and you get aliasing and it is mathematically and physically impossible to determine if a higher frequency exists. Any frequencies higher than 1/2x your sample rate which appear to exist in your FFT analysis must be thrown out, as they are invalid.

So, what max vibrational frequency do you need to measure? That's for you to find out. If you're looking to find gear tooth wear (ex: a broken, cracked, or missing gear tooth), you can come up with some estimations based on number of teeth per rotation, and knowing your motor's max rotational speed in rotations per second.

Example: assuming 32 teeth per revolution, you will be rotating at 3000 rot/min / 60 sec/min = 50 rot/sec x 32 teeth/rot = 1600 teeth/sec. But, to identify a broken tooth maybe you need to do a waveform analysis of the shape of the wave over that broken tooth, so you should sample at 5x to 10x that rate, or perhaps 1600 teeth/sec x 10 samples/tooth = 16000 samples/sec = 16 kSps. But...5 samples per tooth might be enough, or only 8 kSps...

See how some of this analysis might work? You have to figure out what it is you're trying to figure out, and sample accordingly. If you don't know what you're trying to figure out, just sample as fast as you can and then with that data try to see what you can figure out from what you just sampled! Such are the ways of engineering and curious minds! :)


With that being said, assuming you use my library's adc.setADCSpeed(ADC_FAST); trick, you can sample 1 channel up to 50kHz or 3 channels up to 50/3 = ~16kHz, meaning the max vibrational frequency you can detect with FFT for 3 channels is ~8kHz with an ATmega328. Is that enough?

BUT, you will have jitter problems unless you put the ADC into continuous sample mode at a fixed interval, and you cannot sample all 3 channels at once, so there will naturally be an offset between them all, as they happen in sequence one after the other.


How fast can the ADXL335 sample? (ie: what's its "bandwidth", or frequency response?)

As for the ADXL335, its datasheet reveals it to be an analog 3-axis accelerometer, not a digital one, so you are limited by:

  1. how fast the ADC you have on your microcontroller can sample the sensor (we already came up with ~16khz (kSps)/channel, for 3 channels, above) and
  2. what the ADXL335's bandwidth, or max frequency response, is.

The datasheet (see image below) says you get a bandwidth of 0.5 Hz to 1600 Hz for the X and Y axes, and 0.5 Hz to 550 Hz for the Z axis, all depending on the chosen bypass capacitors, cx, cy, and cz you choose for it. See the image and highlighting below.

enter image description here

Bandwidth means simply [in my own words]:

Bandwidth is the maximum frequency at which a device can respond to changes in the thing is it measuring (ex: an accelerometer to changes in acceleration).

By definition, a bandwidth for a low-pass filter, or a sensor responding to a high-frequency input, is equal to the frequency at which point the measurement of the thing being measured is attenuated by 3 db, or in other words, is 1/sqrt(2) = 0.707 times as big as the actual thing being measured. So, if the bandwidth of an accelerometer is 50 Hz, then that means if it tries to measure a 50 Hz vibration, then the measurement it outputs at that frequency is attenuated to 0.707x as large as the actual amplitude of that vibration. Therefore, it is said that this sensor cannot be reliably used to measure higher frequencies than this. Note that since Power = V^2/R, and the 0.707 rule applies to voltage, the attenuation is 0.707^2 = 0.5 for power.

If you bought your ADXL335 sensor from Adafruit here for $15 (https://www.adafruit.com/product/163), they state:

The XYZ filter capacitors are 0.1uF for a 50 Hz bandwidth

...which means they chose capacitors to give it a 50 Hz bandwidth, or frequency response. This means the sensor is limited to reliably measuring vibrations only up to 50Hz. You should sample at least 2x this bandwidth then in order to adequately capture frequencies up to that value, again, based on Nyquist. This means for this Adafruit version of the device and with these chosen bypass capacitors you can sample at 100 Hz or higher to detect vibrations up to 50 Hz (that's Hertz, not kiloHertz!). Even if you sample much much faster, the maximum reliable frequency this device can measure is only up to 50 Hz before attenuation of its measurements becomes a significant concern. Whether sampling at 100 Hz or 1000 Hz, the frequency this sensor can measure, in this configuration, is only up to 50 Hz, which is only 50/sec x 60sec/min = 3000 RPM if your goal is to just detect the rotational frequency, but not any higher-frequency vibrating modes, for your device.

A 50 Hz bandwidth (max frequency response), FYI, is optimized to reduce sample noise for handheld tilt-based game controllers, as it intentionally attenuates any frequencies above 50 Hz, and 50 Hz input from a human is a good expectation for human control signals. You might sample this sensor for such a game controller anywhere from 50 Hz to 1 KHz, but again, it can't detect vibrations any faster than about 50 Hz. So, the Adafruit version of the ADXL335 is optimized to be used to make home-made tilt-based hand controllers for games, toys, smart devices, radio control devices, etc.

Extra note on sampling frequency

Even though the Nyquist frequency says you only need to sample 2x the frequency of interest to detect the frequency of interest through FFT or similar, you need to realize that if you ever want to plot a given signal or inspect its shape or waveform, you should sample at least 5x to 10x as fast as the frequency of the signal you are trying to record and inspect.

This is how oscilloscopes are rated. A "100 Mhz" bandwidth oscilloscope will have a sample rate of at least 5x to 10x that, or 500 MSps (Mega-samples-per-second) to 1 GSps (Giga-samples-per-second). This makes sense because the purpose of an oscilloscope is to plot waveform shapes, and that requires at least 5 to 10 points per period, or 5x to 10x the sample rate of the rated bandwidth in order to display a reasonably-nice picture of the waveform.

For pure FFT or frequency analysis, where you just want to know the frequency of the thing being measured, but don't need to know how the waveform looks, a sample rate exactly 2x or higher than the frequency of the thing being measured is physically and mathematically sufficient.

2
  • 1
    Thanks Gabriel, this is one of the most complete answer that everyone gave me in my entire life! have a good day man! thanks! Now, the only remaining question is: looking at commercial MEMS sensors, you have some recommendations about where i need to point in order to sample also higher frequencies...maybe this sensor is the right choice: static6.arrow.com/aropdfconversion/… – Symon Jan 26 at 8:17
  • 1
    @Symon, yeah, that looks like a great sensor! It is a digital sensor with its own built-in ADC up to 220 kSps, FIR filters, internal FFT capability, etc. I see a it uses CS (Chip Select), SCLK (Serial Clock), DIN (Data In--MOSI (Master Out Slave In)), DOUT (Data Out--MISO (Master In Slave Out) pins, meaning it communicates over SPI. You'll have to figure out how to do that. Will be a learning curve for sure, but absolutely, go get one and get to it! – Gabriel Staples Jan 28 at 7:12
3

First of all, 3000 RPM is only 50 Hz, so sampling is not a problem for the fundamental frequency. But you usually want to see harmonics, to pick up gear tooth issues, etc. I suggest using my Daqarta software with a sound card to do your initial testing. It already does everything you need, including waveform, spectrum, and spectrogram displays plus a lot more. You can use it free for 30 sessions or 30 days, then the sound card inputs are no longer supported. By that time you should have a good idea about what you need. As it turns out, Daqarta also supports Arduino, and that does not end with the trial period. So you may be able to do everything with an Arduino, for free. The Daqarta site also has a contact page, and I am glad to answer questions and provide specific help for any issues that arise. That include free users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.