Question on ADC/Tilt/G-force

Hello all,

I have some question to ask on the table shown below. I know that Ax-g's = 0 and Az -g's = 1g and both Angle is 0 degree. But how to do i get A/D Ax , A/D Az and calculate the Resolution for 1-Axis and 2-Axis? Is it because 128 = 8bit? Then how about 190?

I don’t understand the question. You didn’t bother mentioning you have an accelerometer.
If that is not important enough to mention then what is the problem with the data ?

Fufu:
Hello all,

I have some question to ask on the table shown below. I know that Ax-g's = 0 and Az -g's = 1g and both Angle is 0 degree. But how to do i get A/D Ax , A/D Az and calculate the Resolution for 1-Axis and 2-Axis? Is it because 128 = 8bit? Then how about 190?

8 bits is from 0 to 255 (decimal).

Which resolution. You can't rate the acelerometer by the resolution of the ADC of the arduino because you czn get 12-bit ADCs.
Since you haven't posted a datasheet for the acelerometer we can't say what the resolution of that is.

I read throught this website: Tilt measurement using a low-g 3-axis accelerometer - 百度文库 . If u scroll down all the way, u will see the table 2. They never state any accelerometer. I don't quite understand how they determine the A/D AX from 128 to 190 and the resolution. Is there any formula that we can calculate out?

Yhe entire article you linked is about acelerometers. They are mentioned throughout the article. The 128 - !90 you mentioned is degreesI think. I don't know what you want to calculate. What are you trying to solve for?

The value highlight in yellow. I just want to understand how's the value come. Can u explain why it start from 128 and end at 190? And the value of resolution 0.9269,0.9240.

Broken picture.

Fufu:
The value highlight in yellow. I just want to understand how's the value come. Can u explain why it start from 128 and end at 190

Because that is the readings the sensor gives with a 90 degree tilt, there is nothing to calculate it is just a measurement. The angle resoloution is given by calculating what angle the least significant bit of the measurement corresponds to.

@Fufu, perhaps it would help to think about how the Arduino ADC works.

The ADC measures a voltage between 0 and 5volts. 0 volts gives a value of 1023. 5v gives 1023 and 2.5 volts would give 511 or 512.

If your ADC gives a number of (say) 473 then you can work out the voltage as 5 / 1023 * 473 = 2.31 volts.

If you are connecting an accelerometer to the ADC the accelerometer must produce a voltage proportional to the angle. You will have to read the accelerometer datasheet to find out what that is.

...R

Thanks for the reply.
How about this?

An 8-Bit ADC
An 8-bit ADC cuts 3.3V supply into 255 steps of 12.9mV for
each step. Therefore, by taking one ADC reading of the
MMA6260Q at 0g (0°of tilt for an x-axis device) and 1g (90° of
tilt for an x-axis device), would result in the following:

0°: 1650mV + 12.9mV = 1662.9mV,
which is 0.92° resolution ←
90°: 2450mV+ 12.9mV = 2462.9mV,
which is 6.51° resolution ←

Base on ADC can work out the voltage as example: 5 / 1023 * 473 = 2.31 volts. But how about the resolution? There should be a method or formula right?

Haha. I’m just started learning last week, i guess there still much thing for me to understand. :smiley:

But how about the resolution?

That depends on the number of bit of the A/D conversion.
An 8 bit conversion has 256 divisions, a 10 bit has 1024 divisions.

There should be a method or formula right?

Yes if you have N bits on a conversion you have:-
2N divisions. That is two to the power N.

An 8-bit ADC cuts 3.3V supply into 255 steps of 12.9mV for each step.

This is ONLY true if your 8 bit A/D has a 3.3V reference voltage. The reference voltage can be anything up to the supply of the chip and down to a minimum value given in the particular A/D’s data sheet.

Understand that 2N divisions = 28-1 = 255.
How about 0.92° resolution? What are the method to get 0.92° ? I can’t find any formula for this.
Sorry for asking so much question, i just want to learn more thing. XD

Fufu:
0°: 1650mV + 12.9mV = 1662.9mV,
which is 0.92° resolution ←
90°: 2450mV+ 12.9mV = 2462.9mV,
which is 6.51° resolution ←

I don’t understand this.

Are you saying that, for an angle of 0deg the MMA6260Q produces a voltage of 1.65 volts and for 90deg it produces 2.45 volts.

If so, why are you adding 12.9 mV?

If an 8 bit ADC has a reference voltage of 3.3v then 1.65 volts will give a number of 128 and 2.45 volts will give 189. That means that between 0 and 90 there are 61 steps - so about 1.5 degrees per step.

The Arduino has a 10bit ADC so it would have more steps per degree.

What Arduino are you using? The ADC in the Uno is more limited than in most other devices which allow differential ADC and should be capable of giving more resolution.

…R

How about 0.92° resolution? What are the method to get 0.92° ?

It is the angle represented by one division of the conversion.
Any A/D is only accurate to one division.

I don't understand this.

Are you saying that, for an angle of 0deg the MMA6260Q produces a voltage of 1.65 volts and for 90deg it produces 2.45 volts.

If so, why are you adding 12.9 mV?

If an 8 bit ADC has a reference voltage of 3.3v then 1.65 volts will give a number of 128 and 2.45 volts will give 189. That means that between 0 and 90 there are 61 steps - so about 1.5 degrees per step.

The Arduino has a 10bit ADC so it would have more steps per degree.

What Arduino are you using? The ADC in the Uno is more limited than in most other devices which allow differential ADC and should be capable of giving more resolution.

...R

Hi, i read through this website: http://aitendo3.sakura.ne.jp/aitendo_data/product_img/sensor/MMA7260Q/MMA7260QT_AN3107.pdf .
Thanks for the explanation on the step. I still not quite understand how do the resolution give the value? i mean every degree will have different resolution right? There must be a way to calculate out the resolution if not how's the value come from?

If an 8 bit ADC has a reference voltage of 3.3v then 1.65 volts will give a number of 128 and 2.45 volts will give 189. That means that between 0 and 90 there are 61 steps - so about 1.5 degrees per step.

I think you are confusing analog INPUT steps with analog OUTPUT steps. ALL ARDUINO ANALOG INPUT IS 0 TO 1023. If your Vcc is 5V, then each step is 4.88mV. If your Vcc is 3.3V, each step is 3.22mV. If you invoke analogREFERENCE(INTERNAL)

then each step is 1.07mV, but no matter what your Vcc is , the analog INPUT is always 0 to 1023 counts UNLESS you have an EXTERNAL ADC like the ADS1115 16-bit I2C ADC., in which case everything is different because it even has scaling factors. You could have counts up to 65535.

There must be a way to calculate out the resolution if not how’s the value come from?

It comes from the the responce of the device. Look at the curve on the data sheet, it is not linear. So at each reading you have a different reading. It is measured not calculated.

You can only derive this figure from a calculation if you know the formular of the sensor’s output curve. You can see that output curve of the sensor in the graph above the table. Can you express that shape as a formula? If not then you measure it and use a look up table to translate the reading into a tilt angle, that look up table is what you have been posting.

At each reading one division of your A/D represents a different angle, that is what is shown in that table as resoloution.
If there was a simple way to calculate it then it would be shown in the data sheet, a look up table is always a last resort for non linear sensors.

It comes from the the responce of the device. Look at the curve on the data sheet, it is not linear. So at each reading you have a different reading. It is measured not calculated.

You can only derive this figure from a calculation if you know the formular of the sensor's output curve. You can see that output curve of the sensor in the graph above the table. Can you express that shape as a formula? If not then you measure it and use a look up table to translate the reading into a tilt angle, that look up table is what you have been posting.

At each reading one division of your A/D represents a different angle, that is what is shown in that table as resoloution.
If there was a simple way to calculate it then it would be shown in the data sheet, a look up table is always a last resort for non linear sensors.

Oh i got it. Thanks thanks. Finally understand the resolution part. Thanks for the clear explanation. :smiley:

As i know 0g = 1650mv, -1g = 850mv, +1g = 2450mv, when i placed my accelerometer flat on my table but the result does not seem get close to the voltage. And also when i flip over the z-axis result should be getting -g if i’m not wrong. But why i am getting value like 337.74?

const float VOLTAGE = 3300;

const float ZOUT1G = 2450; 
const float ZOUT0G = 1650; 
const float ZOUT_1G = 850; 

const float XOUT1G = 2450; 
const float XOUT0G = 1650; 

const float YOUT1G = 2450;
const float YOUT0G = 1650;
const int error = 10;

// Analog inputs where the sensors are
const int xaxis = 0;
const int yaxis = 1;
const int zaxis = 2;

float XError, YError, ZError;
float z,x,y;

float AccelAdjust(int axis)
{
 float acc = 0;
 float reading = 0;
 for (int j=0; j<error; j++)
 {
   reading = analogRead(axis);
   acc = acc + ((reading * 3300) / 1023.0);
   delay (11);
 }

 return acc/error;
}
void setup()
{  
 Serial.begin(9600); 
 pinMode (xaxis, INPUT);
 pinMode(yaxis,INPUT);
 pinMode (zaxis, INPUT);
}
void loop()
{
 XError = AccelAdjust (xaxis);
 YError =  AccelAdjust(yaxis);
 ZError =  AccelAdjust(zaxis);
 ZError = ZError - ZOUT_1G; 
  
 Serial.println ("Adjusted accelerometer X axis");
 Serial.print ("Error of X =");
 Serial.println (XError);

 Serial.println ("Adjusted accelerometer Y-axis");
 Serial.print ("Error of Y =");
 Serial.println(YError);

 Serial.println ("Adjusted accelerometer Z axis");
 Serial.print ("Error of Z =");
 Serial.println (ZError); 

 delay(2000);
}