Loading...
Pages: [1]   Go Down
Author Topic: Screwed by accelerometer?  (Read 824 times)
0 Members and 1 Guest are viewing this topic.
Central MN, USA
Online Online
Faraday Member
**
Karma: 35
Posts: 5947
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought an ADXL321, +-18g dual axis accelerometer, from the red box company. They sent me the wrong part. Now the right part came in a week later and it's not doing what it's supposed to do. Maybe I'm completely wrong but I expect 512 for x and y axes output since I lay it flat but I got 743ish, with 5V supply. Tilting the accelerometer will get as big as 756 or as small as 731. This has +-18g so 512 levels correspond to 18g, making 28 levels per g. My tilting should create exactly 1g from laying flat so should increase 28 instead of 14ish. Any idea what could have gone wrong?

Datasheet here:
http://www.analog.com/static/imported-files/data_sheets/ADXL321.pdf

Code:
Code:
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  int temp;
  lcd.setCursor(0,0);
  temp=analogRead(0);
  Serial.print(temp);
  Serial.println("   ");
  lcd.setCursor(0,1);
  temp=analogRead(1);
  Serial.print(temp);
  Serial.println("   ");
  delay(500);
}

I simply has nothing on the arduino except for the accelerometer, powered by the 5V and gnd pins and sensed by analog 0 and 1 for x and y axes.

Logged


Worcester, MA
Offline Offline
God Member
*****
Karma: 2
Posts: 619
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right those numbers look weird and are a bit contradictory.  Reading 743 while flat suggests the accelerometer is being powered by a ~7 volt supply while the tilt range you are getting for +/-1 g suggests the accelerometer is being powered by a 3.3 volt source.  

Try connecting the ST pin to 5v and taking a reading and comparing it what the datasheet says it should be.  If you have a meter verify the voltages powering the accelerometer and also the outputs going to the A/D converter.

Lastly you may want to check to make sure there isn't a problem with the A/D converter.  Connect the 3.3v source to the ADC pin and take a measurement, it should be around 675.
Logged

I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

Central MN, USA
Online Online
Faraday Member
**
Karma: 35
Posts: 5947
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks wayneft. I had 667 if I connect 3.3V to the ADC 0 so I think it's working. Today I brought the accelerometer to work and tested it on a different arduino and different computer. It's working alright, getting around 512 and about 24ish for each g. I do have a good Keithley meter and I measured the voltage, around 2.5V when the board is flat. So maybe my home arduino chip broke? I've copy and paste the code from this thread to my work comp so nothing is changed software wise.

A possible explanation is the micro structure in the chip was stuck due to rough mail handling and was freed when I transported it to work today.
« Last Edit: January 21, 2011, 01:37:38 pm by liuzengqiang » Logged


Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 27
Posts: 5083
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A possible explanation is the micro structure in the chip was stuck due to rough mail handling and was freed when I transported it to work today.

Possible - but I'm not sure about likely (given the specs of the accelerometer - IIRC, 10,000g shock?); though from your explanation of the ADC on 3.3V, and everything else - lots of contradictory things going on. Let us know how it goes when you get it back home...
Logged

Central MN, USA
Online Online
Faraday Member
**
Karma: 35
Posts: 5947
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

cr0sh, wayneft,

I tested the accelerometer with a third arduino with 168 chip and it worked just fine, same code, same wires. 509 was the zero g reading. I also used a rotation stage and found the ratio to be a bit off. When I had 4rev/s rotation speed the accelerometer should give about 12g at 20cm away from center of rotation but I only got about 9+, ~20% error. My mounting distance could only be off by 2mm at most and if it becomes lose while rotating, the acceleration should become larger. The rotation is accurate up to 1ms timing error so should be very good. I used 512/18=28.4~=28 so I could be off by 1.4% but still 20% comes from something else. My rotation has been checked with a photogate system we use for teaching so it's not the problem.

Now I'm back home and just plugged the thing in my home arduino's analog pins, using digitalWrite(HIGH) and digitalWrite(LOW) to power it. It's working fine with 510 offset with min=491, max=534 if I tilt it. So about 21 levels per g instead of the 28.4 levels per g.

I don't know what could have happened other than the thing was not working as should last night. I just got the modern device package. Should have a bunch of RBBB PCBs and a $10 accelerometer to tinker with. like the flip box I've been blabbing about.

Update: Read the spec sheet one more time. It said 57mV/g with Vd=3V so 95mV/g if I use 5V. OK. My bad. Now the conversion is 19.46 levels per g. Now it all makes sense. Hope it stays functional for a while. I'll keep testing it for the weekend.
« Last Edit: January 21, 2011, 09:00:58 pm by liuzengqiang » Logged


0
Online Online
Tesla Member
***
Karma: 73
Posts: 6638
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The low-pass RC filter bandwidth is probably causing that 20% dropout.  The RC rolloff is 50Hz with the installed 100nF caps.  Either calculate the attenuation or replace the capacitors with lower values (minimum is 2.2nF according to specs - there will be more noise of course).
Logged

Pages: [1]   Go Up
Print
 
Jump to: