How to calculate "G" value from 3 Axis Accelerometer Board ?

General discussion on mikroC.
Post Reply
Author
Message
crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

How to calculate "G" value from 3 Axis Accelerometer Board ?

#1 Post by crocu » 23 Sep 2010 21:45

Hello

I would like to add "G-meter" function working with Three-Axis Accelerometer Board.

MikroElektronika provides a code example to calibrate and measure angles on each axis :

( http://www.mikroe.com/eng/downloads/get ... s_v101.zip)


Has someone already built a project to get "G" measurement ?

I would like to measure how much a car brake or speed gets, and also show how many "G" gets the sensor when falling down ( Z axis )

I spent some time to do some calculations without success, i will appreciate if you can share your experience and maybe share a part of code showing me how to calculate G measurement on any axis.

Many thanks for your help, :D

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

Re: How to calculate "G" value from 3 Axis Accelerometer Boa

#2 Post by Sobrietytest » 26 Sep 2010 09:44

In that zip folder there's an example of how to calibrate and read G. The board's outputs are analogue voltages which are proportional to G in the three planes.

crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

Re: How to calculate "G" value from 3 Axis Accelerometer Boa

#3 Post by crocu » 26 Sep 2010 10:48

Yes, i found it

G measurement is calculated with this line :

Code: Select all

void Read_Angles() {
 double div_x, x_rad, div_y, y_rad, div_z, z_rad ;

div_z = (float)(meas_z-zeroG_z) / (oneG_z-zeroG_z);  // measured_G / one_G
...
}
But my problem is to display div_z value on my LCD display with 1 digit after comma , like this +1.5 or -2.5

div_z is set as double variable, i don't know how to change it in order to display a readable value, can you write the code to do that please ?


Many thanks for your help,

Post Reply

Return to “mikroC General”