Hello all,
maybe you can help me. I have ADXL 1005 and Teensy 4.0.
I want to measure g RMS of bearings.
Do you have any idea how to do it? Or any sample code…
Thanks a lot.
Michal
Hi Frohr, welcome to TechForum. Can you supply the full part numbers for the components you are using and the types of bearings you are working with. Glenda
Hi, I use just ADXL1005Z eval board and Teensy 4.0 (https://www.pjrc.com/teensy-4-0/) and Oled display. Programming in Arduino IDE. I will check all types of bearings - 99% rolling bearings. ADXL will be in box with magnet mounted on bearing housing. I will read samples continuesly and show on display g RMS (or just g value - RMS calculation is no problem = summed all >0 values x 0,707). But I do not know how read data from ADXL in samples to have the right value. I hope my description is clear…
Hi frohr,
The ADXL1005 outputs an analog signal, so you will need to either read that signal on one of the ADC input pins or use an external ADC and feed the resultant digital data from that ADC into the Teensy on one of its serial input ports (depending on the format of the external ADC’s output type). You will probably need to add a low-pass filter to prevent aliasing and get a clean signal.
To complicate things, the ADXL1005 will output 1/2 of the supply voltage under 0 g conditions. So, you must subtract this value from your readings to account for both positive and negative g readings.
Regarding calculating the RMS value, your formula only holds if you have a perfect sine wave. To get a true RMS value for any arbitrary waveform, you will need to calculate the Root of the Mean of the Squares of your samples (after first subtracting the 1/2 supply voltage offset):
So, you will need to use a library function which establishes a continuous sample rate, either for the internal ADC or an external one, subtracts the voltage offset, performs a squaring function to each sample reading, stores a sufficient number of those readings, adds those squares, then divides the sum of those squares by the number of samples in the set, and finally, calculates the square root of that value.
Hi,
thanks a lot for information. I have few additional questions.
- Could you recommend ADC which is suitable for this application? For example this one is ok? - https://arduino-shop.cz/docs/produkty/0/645/1517443417.pdf
or this one? https://arduino-shop.cz/docs/produkty/0/31/1427807780.pdf - What is a very important parameter of ADC to use with ADXL?
Is this method right?:
- connect ADXL to external ADC and ADC to Teensy digital pin
- read for example 4096 values on Teensy
- apply low-pass filter
- remove 1/2 supply voltage for 0g (positive and negative)
- how to convert data to g value?
- now I have normal g values in the buffer but not 4096 values, right? (removed 1/2 supply voltage for 0g) - and I think have to remove all negative values so now I have for example 1800 values instead 4096 - right?
- now I can calculate RMS according your formula
Thanks a lot for your great help.
Michal Frohr
Hi Michal,
You’ll need to find an ADC that allows you to use a reference voltage of 5V since that is intended supply voltage for the ADXL. Also make sure that it can interface with the 3.3V I/O of the Teensy. An I2C interface would be good for this since you can pull up the lines to whatever voltage you need. If the ADC uses SPI or something else, make sure it has separate analog and digital supplies to accommodate both voltages.
Second, you’ll want to look for a sampling rate that suits your application. I’m not sure what sort of frequency content you’ll get from measuring the bearings, but you must be able to sample at least twice as fast as the highest frequency according to Nyquist.
Next, your method isn’t quite correct. Let’s assume you’re using a 12-bit ADC, the process would be:
-
Connect the ADXL output to analog anti-aliasing filter. You need to reduce any frequencies greater than half your sampling rate in the input signal before it’s sampled to prevent aliasing. You could also oversample to make your anti-aliasing filter requirements less strict then downsample to your actual desired sampling rate afterwards.
The filtered output can then by connected to your ADC. -
Read N samples at your desired sampling rate.
-
Subtract the 0g offset (half of full range ADC value). For a 12-bit ADC, the max reading is 4095. So subtract 2048 from each sample. Your samples will now be centered around 0 in the range -2048 to 2048 instead of 0 to 4096.
-
Convert to g value by using the sensitivity given in the ADXL datasheet of 20mV/g when Vdd = 5V.
For a 12-bit ADC, each ADC “step” is 1/4095 * 5V or 0.001V.
With a sensitivity of 20mV/g or 0.020V, a change of 1g is then represented by 0.020 / 0.001 or about 20 ADC steps.
So in this case, you would divide each sample by 20 to get your g-values. -
Calculate the RMS value using the formula from David.
You do not remove samples from your buffer. Just subtract a constant offset from all of them.
Hi Michal,
Taylor beat me to the response. He’s right on, except that the ADXL1005 can be powered with as low as 3V. The zero-g output will always be 1/2 of the supply voltage, Vdd, and the output per g will be scaled based on Vdd. So, if you were to use 3V, the 0-g output would 1.5V, and the output would move from there by 3V/5V x 20mV/g, or 12mV/g.
As Taylor states, you do not have to remove the negative samples because you have to square those values, which will make the results all positive.
As far as a suitable ADC, the following could probably work:
MIKROE-340 12-bit 100kHz sample rate
Good point. I didn’t see the sensitivity scaling bit at the end of the datasheet.
With the voltage difference out of the way, the internal ADC on the Teensy might also be sufficient and save you from adding extra hardware.
Hi, thanks for information - it will help me.
Just one more question - is there difference if I measure in radial axis (horizontal / axial) and vertical axis? The g value is always the same? I have to measure all axis on bearing housing.
Thank you!
Hi Frohr,
The ADXL1005 is a single axis accelerometer. It only measures in the “X” axis, as shown in this diagram:
If you need three axes, you will either need three of these, each oriented appropriately, or another sensor with three internal axes.
Here are a few alternative 3-axis accelerometers to consider:
-
ADCMXL3021BMLZ-ND Digital output with internal frequency analysis capabilities
-
KX134-1211 Digital output
-
832M1-0050 Analog output
Unfortunately, none of these come in a convenient eval board like that which is available for the ADXL1005.
Hi, I am sorry for misunderstanding. I mean single axis sensor but in different positions. See picture. Values of measured g will be the same in vertical and horizontal direction? g force / gravity is allways to the ground. I am thinking if it affects adxl. Thanks.
Hi frohr,
If you oriented the sensor in such a way that the “x” axis of the sensor was facing vertically (the side position in your diagram) such that the vector of gravity and the sensor’s axis of sensitivity are aligned, then, yes, you will continuously measure 1g force in addition to any vibration it may be sensing.
You could place it in the same side location, but rotate it 90°, such that the “x” axis of the sensor was perpendicular to gravity and parallel to the axis of the motor shaft. This would prevent gravity from affecting the signal. However, doing so would make it less effective at sensing vibration of the motor. You want the axis of sensitivity to be perpendicular to the axis of the shaft. You can do this either in the side or top locations of your drawing, depending on the orientation of the sensor. I notice that in your drawing, based on how you draw the header pins, that you have the x-axis of the sensor in parallel with the axis of the shaft. This is going to give you worse sensitivity. You would need to rotate the sensor 90° from how you have it drawn. Note the axis of sensitivity of the eval board:
Most importantly, it really does not matter very much whether gravity is part of your measurement or not. The useful information is the varying part of the signal, not the static part. The ADXL1005 has a measurement range of +/-100g, so there is no chance that the gravity offset will saturate the output of the sensor. Therefore, I would place the sensor wherever it will detect the most vibration, regardless of whether gravity will be sensed or not. The best location will depend not only on the motor itself, but also how the motor is mounted. The geometry of the mounting points and the mechanical structure of the entire system upon which it is mounted will tend to affect vibration in certain axes more than others. Figuring out in what direction the maximum vibration will occur will help in determining the best placement location and orientation for the sensor.
Hello, could you help me with mm/s calculation?
I have g value, I think its clear:
useconds_sampling = micros();
for(int i=0; i<SAMPLES; i++)
{
sensorValue= adc->adc0->analogRead(A1);
sensorValueG = (((sensorValue * 3.0) / 4095) - (3.0 / 2)) / 0.020;
vRealg[i] = sensorValueG + OFFSET; //offset = 75
while(micros() < (useconds_sampling + sampling_period_us))
{
}
But how calculatevelocity - mm/s from my sensorValueG?
Thanks a lot for your help.