Pages: [1]   Go Down
Author Topic: ADXL377  (Read 1388 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone, I`m doing a datalogger with the adxl377 accelerometer and the arduino due and I was wondering if anyone have used this sensor, I choosed the Arduino due since it has 12 bits of resolution, so my question is which readingns should I have on the serial monitor, and how can I refine my readings
« Last Edit: May 21, 2013, 09:00:03 pm by leotriador » Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the problem ?
It needs 3.3V and the three axis outputs should be connected to analog inputs of the Due.

Like all those sensor it is probably not very stable. You could use the average of a few samples. What kind of values are you reading ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is for extreme G readindgs, I expect to get values for 150 G
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

According to the datasheet it is +/- 200g. So I assume every axis is able to measure -200g to +200g.
For 150g, you have to take care about the boards (arduino and sensor board), but it depends on whether it is a short peak or continues 150g.

Can you tell what the problem is ?
Do you know how to solve the offset in software ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is for measuring peaks, and the software issues are prety much solved I just wanted to know if anyone had anprevious experience with this sr in particular, I`m usingthe following sketch:

Code:
void setup() {
  // open a serial connection
  Serial.begin(9600);
}

void loop() {
 
  // change the resolution to 16 bits and read A0
  analogReadResolution(16);
  Serial.print(", 16-bit : ");
  Serial.print("x :");
  Serial.print(analogRead(A0)); 
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));

  // a little delay to not hog serial monitor
  delay(100);
}

Is there anything I can do here to improve the results?
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The "analogReadResolution(16)" can be called once. Use it in the "setup()".

In the sketch, you don't have offset compensation.
You would need three variables that contain the value while the sensor is kept still. After that substract that from the new samples.

9600 baud is only 960 byte per second.
You sent 22 + 3 * something = about 40 byte. That is 400 byte per second.
That should work, but if you double the samples rate, you could get into problems.

The delay is 100ms. You can't detect a good peak with only 10 samples per second.
If the sensor detects a 'hit' like a car or a crash dummy, you need a higher sample rate.

I would like to reduce the characters via the serial monitor and increase the sample rate.

The resulting sketch would depend on what you want.
Do you want a steady pace of the sample rate ? (use the millis() function).
Do you only want to detect the value of the peak ? (detect the peak and send that to the serial monitor).
Perhaps you want to increase the accuracy ? (take the average of 3 (2...5) samples).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First thank you for answering, and what I need to do is register peaks, like in car crash, so thats the reazon I need the sample rate so high, and the using the code I posted I get the following readings

x= 2056
y= 2076
z= 2088

is this ok, in the analog devices page it says that the sensor is set to give 0g at half the mV given to the adxl377 so in this case it would be 4094/2 = 0G right? But doing some math, 1g would be aproximatly 2056, now, my sensor shoul give me in theory this:

x= 2047
y= 2047
z= 2056
I`m right about this or I`m having some error?
« Last Edit: May 22, 2013, 02:17:21 pm by leotriador » Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

12 bit with 3.3V is 4096 steps = 0.8mV per step.
Sensitivity is 6.5 mV/g = 8 steps.
The values in theory should be  2048, 2048, 2056.
I get the same values as you.

The sensor values look very good. They are very close to it. Many sensors have more offset.

The bandwith is roughly 1000Hz for the sensor. So I suggest to sample at about 1000Hz.

Do you want to know the top of the peak (max g), or the whole peak, or the surface of the peak (energy impact) ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, just the top peak, with this value and the total mass of the object I can easily get the total force produced on the impact.

I`m doing some math and with 3.3 V my sensitivity is 7.15mV/G so I will put all this in a formula in order to get g results in the serial monitor, I have also set the baudrate higher and set the delay in 10.

Do you have any other sugestion?

I appreciate your help, thanks very much
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...
Do you have any other sugestion?
...

Yes, upload the new sketch.
Perhaps 100 samples a second is still slow. The Arduino has no problem to do more, so why not do more ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here it is

Code:
void setup() {
  // open a serial connection
  Serial.begin(115200);
  analogReadResolution(12); //setea maxima resolucion al adc
}

void loop() {
 
  Serial.print("x :");
  Serial.print(analogRead(A0)); 
  Serial.print("y :");
  Serial.print(analogRead(A1));
  Serial.print("z :");
  Serial.println(analogRead(A2));
 
  delay(10);

  // a little delay to not hog serial monitor

}
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was thinking about taking samples until a peak is detected.
After that the peak value could be sent to the serial monitor.
That requires more programming and comparing the values.
Can you do that ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The thing is that this device is going to be inside a racecar, so I don`t know when a peak or an incident is going to happen, all the data collected is going to be writen to a sd card to read it after.
Logged

Pages: [1]   Go Up
Jump to: