ADXL377 stability at high data rate

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
stysis
 
Posts: 9
Joined: Fri Jun 20, 2014 5:54 am

ADXL377 stability at high data rate

Post by stysis »

I'm seeing some unexpected behaviour from my ADXL377 accelerometer and am wondering if anyone has an explanation or thoughts on what might be happening.

Basically, when I try to analodRead() as quickly as I can I am seeing a drop in voltage to the analog pin. The faster I try to read, the greater the drop.

My project is to build a system capable of measuring rapid deceleration as a falling object hits a target. The deceleration I want to track occurs in about 10-20 milliseconds so I want to read the data at around 20000 sample per second.

Running the code below on my Arduino Uno reads the analog input at a maximum of about 9000 samples/sec - not good enough. So I got myself a Teensy 3.1 which manages well over 100000/sec! Very nice.

So I have the ADXL377 accelerometer (Adafruit product ID 1413) hooked up to a Teensy 3.1. I'm only interested in acceleration in one dimension so pins X and Z on the accelerometer aren't connected. Pin Y goes to Teensy pin 16 (A2) and the 3V pin on the ADXL377 goes to Aref on the Teensy.

I've powered this setup from both the USB cable and a 9V battery run through a 5V regulator (Adafruit product ID 1065) using bluetooth for the serial interface. Different power supplies don't change these results.

The table shows the data for the first 40 analogRead()s from both the Arduino Uno with no delay and from the Teensy 3.1 with various delays in the code. For zero delay the line of code was commented out.

The ADXL377 was sitting on a flat surface when all of these readings were taken and I have confirmed it is operating correctly by tilting up and down and observing a small change in analogRead().

I've also recorded the A2 pin input from the centre of a voltage divider made from two 100KOhm resisters between the Teensy's 3V output and GND. There was much more noise than I saw from the ADXL377 but there was no reduction in analogRead() even with no delay.

Any ideas?

Code: Select all

const int accelPin = A2;
const int samples = 100;
int count;
char c[21];
unsigned int accel[samples];
float startTime,finishTime,intTime;
String data;

String readInput(){
  while(Serial.available() == 0){
  }
  Serial.readBytesUntil('*',c,20);
  return c;
}

void startTest(){
  Serial.println("Starting...");
  startTime = micros();
  for(count=0; count<samples; count++){
    accel[count] = analogRead(accelPin);
    // Delay value to slow down the sample rate
    delayMicroseconds(10);
  }
  finishTime = micros();
  Serial.println("Completed.");
}

void showData(){
  Serial.print(1000000*samples/(finishTime-startTime),0);
  Serial.println(" samples per second");
  Serial.println();
  Serial.println("Time (ms),ADXL377");
  intTime = (finishTime-startTime)/samples/1000;
  for(count=0;count<samples;count++){
    Serial.print(count*intTime,3);
    Serial.print(",");
    Serial.println(accel[count]);
  }
}

void setup(){
  analogReference(EXTERNAL);
  Serial.begin(9600);
}

void loop(){
  data = readInput();
  switch(data[0]){
    case '1':
      startTest();
      break;
    case '2':
      showData();
      break;
    default:
      Serial.println("Incorrect");
  }
}
Attachments
analogRead() data.png
analogRead() data.png (27.5 KiB) Viewed 753 times

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADXL377 stability at high data rate

Post by adafruit_support_mike »

What you're seeing is frequency rolloff in the output filter.

Toward the bottom of the description on the ADXL377 product page, it says:
The XYZ filter capacitors are 0.01uF for a 500 Hz bandwidth
and you're trying to sample it at between 2 and 230 times that rate.

At a technical level, the ADC's front end is a sample-and-hold system composed of a small capacitor (a few picofarads) and a switch. The switch opens to let the capacitor charge to whatever voltage is on the input, then closes to let the rest of the ADC do its work. Before the switch opens, the S&H circuit will drain the capacitor to 0v so left-over charge from the previous reading doesn't create errors in the current one.

That sample-then-drain process makes the switched capacitor look like a resistor. As you raise the sampling frequency, it takes more and more charge per second out of the ADXL377's output capacitor. That causes the output voltage to droop faster than the chip's 32k output resistance can replace the charge.

Bottom line, that device won't support sampling at 20kHz.

User avatar
stysis
 
Posts: 9
Joined: Fri Jun 20, 2014 5:54 am

Re: ADXL377 stability at high data rate

Post by stysis »

Thanks for the reply Mike. Some of your technical explanation is beyond me but I'm pretty clear as to why it can't be done.

But I got to wondering if there might be a work around.

When I read data from X as well as Y with the ADXL377 sitting flat, the analogRead() data stablises quite quickly and coincides (first graph).
(The sample rate here is about 50000/second.)

I then repeated this with Y pointing up and down and subtracted X from Y (second graph).

I don't know why the absolute value is different for up and down but I wonder if this is a feasible way around the limitation.

Any thoughts?
X & Y (flat).png
X & Y (flat).png (12.61 KiB) Viewed 727 times
Y-X.png
Y-X.png (20.12 KiB) Viewed 727 times

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADXL377 stability at high data rate

Post by adafruit_support_mike »

You can use the reduced output if you want, but it won't be as good as the readings you'd get at a lower sampling at a rate.

First, any sensor has random noise. Sending the signal through a filter makes the random parts cancel out, and the longer you wait between samples, the more noise cancellation you get. The faster you sample, the less cancellation you get, so the more error you get in each reading.

Second, the relationship between sampling rate and signal voltage probably isn't linear. Instead of getting, say, 90% of the value you would at a lower samping rate, the percentage will probably change with the sampling rate and the expected value. You'll need to calibrate the system to see how useful the readings are.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”