 Arduino UNO and DE-ACCM2G2 Accelerometer

Hello all,

This is my first post on this forum, so please bear with me. What we are trying to do is use the above mentioned accelerator to measure vibration data on a floor. We will be trying to utilize the accelerometer at a sampling rate of 500Hz as that is the frequency noted on the product datasheet, without having to add additional capacitors (https://www.dimensionengineering.com/datasheets/DE-ACCM2G2.pdf). We are using the Arduino to run an analog read and then export via serial to a computer running python where we do some more data crunching.

Our setup is as follows, the accelerometer is powered by a 5.0 v off the board, which is powered through USB. The external analog voltage is 3.3V from the accelerometer as denoted in the data sheet. Therefore we are utilizing an AREF to the 3.3v pin on the Arduino, in order to get the correct ADC. I have attached code for the Arduino as a text file.

So essentially what I am assuming is the following

1. Baud rate set to 115200 bits/seconds
2. The accelerometer sends a value such as 716 which is 3 bytes
3. The accelerometer reads at 500Hz

Therefore the accelerometer wants to send 500(cycles/second)*3 (bytes)*8 (bits/byte) = 12000 bits/second, which would make me think that the serial read could send the data almost simultaneously.

Does everyone think this is feasible, or am I missing something?

If so the next question is how do I determine how fast the actual thing is reading and writing as having the correct cycle rate noted is very important to the final data crunching in python?

Thanks,

Scott

Arduino Accelerometer Code.txt (1.9 KB)

This is the page for the accelerometer : https://www.dimensionengineering.com/products/de-accm2g2 It uses the LIS244ALH analog 2-axis accelerometer which was introduced 7 years ago. That is not very outdated, but that was about the time that digital cheap 3-axis accelerometers were introduced. For example the MPU-6050 costs 3 dollars on Ebay and is probably better. It has an accelerometer plus gyro and 3 axis, which makes it ideal for Kalman filtering.

According to the datasheet of the LIS244ALH, it has an internal resonant frequency of 2kHz and a bandwith of 2kHz on both axis. However, I'm sure the sensitivity will not be equal at all in that 2kHz. I can't find a drawing of the sensitivity over the vibration range up to 2kHz. I think the sensor is not ment for higher frequency vibrations.

Do you want to send a single channel ? It is possible to send two binary bytes for a 16-bit integer plus a start byte: stx, lowbyte, highbyte 3 * 10 (8+2 overhead) * 500 = 15000 baudrate. The 115200 baud should be fine.

The attached code is not very serious, is it ? Please write a new sketch (the code) and with good comments for your sensor and for your circuit.

In theory it is possible to have the full 10-bit range for 3.3V by applying 3.3V to AREF. But it can cause a shortcut inside the microcontroller when the sketch is not correct.

Peter,

Thanks for the help. I will post a new code at the end of this reply.

Peter_n:
This is the page for the accelerometer : DE-ACCM 2g Buffered 2 Axis Accelerometer
It uses the LIS244ALH analog 2-axis accelerometer which was introduced 7 years ago. That is not very outdated, but that was about the time that digital cheap 3-axis accelerometers were introduced.
For example the MPU-6050 costs 3 dollars on Ebay and is probably better. It has an accelerometer plus gyro and 3 axis, which makes it ideal for Kalman filtering.

According to the datasheet of the LIS244ALH, it has an internal resonant frequency of 2kHz and a bandwith of 2kHz on both axis. However, I’m sure the sensitivity will not be equal at all in that 2kHz.
I can’t find a drawing of the sensitivity over the vibration range up to 2kHz. I think the sensor is not ment for higher frequency vibrations. The sensor is not needed for high frequency vibrations, as we are looking at vibrations in the range of 1Hz to 20Hz, so hopefully this sensor will work.

Do you want to send a single channel ? Currently we only want to read a single channel, as we are only interested in vertical accelerations.
It is possible to send two binary bytes for a 16-bit integer plus a start byte: stx, lowbyte, highbyte
3 * 10 (8+2 overhead Is this 8 bits plus start and stop byte?) * 500 = 15000 baudrate.
The 115200 baud should be fine. So are you saying that I could send the data out with no delay, our biggest issue is that we are unsure if we are getting the full 500Hz read rate of the sensor.

The attached code is not very serious, is it ? Revised code attached at the end of this post, essentially we just utilized the previous version to get us going and had hand written notes outside of the code, sorry for not having proper code, and hopefully this one lives up to expectations.

In theory it is possible to have the full 10-bit range for 3.3V by applying 3.3V to AREF. But it can cause a shortcut inside the microcontroller when the sketch is not correct. I think we are ok as we are calling out the external reference voltage command in order to utilize the 3.3V. The mV reading coming off the accelerometer looks correct right now with the 3.3V AREF in the code.

</*
Reads a Dimension Engineering DE-ACCM2G2 accelerometer and communicates the
acceleration to the computer. The pins used are designed to be easily
compatible with the breakout boards DE-ACCM 2g Buffered 2 Axis Accelerometer

Accelerometer Information
LIS244ALH https://www.dimensionengineering.com/datasheets/lis244alh.pdf
Vdd=3.3V
Sensisitivity +/- 2g Vdd/5 +/- 5% 660Mv +/- 33Mv
Voff= Vdd/2
Noise = 50

Breakout Board DE-ACCM2G2

RMS Noise = 6.2mg
0g = Vcc/2
500Hz bandwidth

The circuit:
analog 3: x-axis
analog 0: y-axis
Arduino Uno GND: ground
Arduino Uno 5V: vcc
Arduino Uno 3.3V: AREF

created 2 Jul 2008
by David A. Mellis
modified 02 February 2015
by Scott Bouvia

This example code is in the public domain.

*/

// these constants describe the pins. They won’t change:
//Seeing as breakout board is being powered off of typical
//power and ground pins we will not have to state analog pins
//to be used as ground or power
//const int ypin = A0; // y-axis of accelerometer
const int xpin = A3; // x-axis of accelerometer

void setup()
{
// initialize the serial communications:
Serial.begin(115200); //send and recieve data at 115200 bits/second

//digitlal to analog reference voltage. This changes the ADC conversion
//from Arduino assumed of 5V to 3.3V therefore giving more range.
//This is why the AREF pin is hooked to Arduino 3.3V pin.
analogReference(EXTERNAL);

}

void loop()
{
// print the sensor values:These values will be in mV
Serial.println();
delay(2);
}>

1 to 20Hz is still very low, that should be no problem.

Start byte + 8 bits + stop byte is about 10. I always use 10, easy to calculate with. A sample rate of 100Hz is often used, but I think that 500Hz is possible. Capturing analog data with a fixed sample rate is what the ATmega chip is designed for, but that is not in the Arduino libraries. You could use millis() for a fixed sample rate, or you could program the registers in the ATmega chip and use interrupts with the ADC.

Is that sketch working ? You are sending now the ascii text (readable text) of an integer, followed by LineFeed. For example 1005 -> "1005\n" that are 5 bytes.

Using the delay(2) will not be a good 500Hz. The next example should be 500Hz (not tested !).

// not tested example. not a full sketch.

unsigned long prevMillis;

void setup()
{
...

// at the end of setup(), set the prevMillis.
prevMillis = millis();
}

void loop()
{
// Example of 500Hz with millis().
if( millis() - prevMillis >= 2)    // 2 ms have passed already ?
{