Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

accelerometer

Status
Not open for further replies.

Nagarathna

New Member
Hi,

my project:determine the angle and position(tilt) of the I.C(accelerometer module).

I have an 3 axis accelerometer moudle which gives me x,y,z analog
output on three different pins.

controller : PIC16F877A
sensitvity of accelerometer : 1.5g 800mv/g
vref+ : 5v
vref- : 0v
10 bit adc



Help required in:

how to convert the analog values to voltage(Formula)?
how to calculate the tilt angle (formula) ?
how to detect the position of the accelerometer module i.e upside down
or side ways?
 
That's what
analog values to voltage
The values are voltage it's decimal you then divide it by 100 and then shift the decimal left.
49500/100 = 495 then shift comes out as 4.95 volts
how to calculate the tilt angle (formula)
What i did was set up a lcd to read the voltage and record the tilt from 0deg to 90deg you need two accelerometer to see if one is upside down.
 
Last edited:
...

What i did was set up a lcd to read the voltage and record the tilt from 0deg to 90deg you need two accelerometer to see if one is upside down.

Huh? what type of accelerometer were they?

Normally they read +/- 1.5g with 0g being output at a center voltage like 2.5v etc.
 
I suggest that you start with a microcontroller that can do divide, such as one of the 16 bit ones.

If not there are divide and multiply routines at PIClist, Microchip PIC

The accelerometer has an output of 800 mV/g, and a range of +/- 1.5g, so its output voltage range must be +/- 1.2 V.

You haven't said what accelerometer it is. There will have to be a defined output voltage for 0 g. If that is in the range 1.2 - 3.8 V, then the output will stay within the 0 - 5 V range of the ADC. If not, you need some sort of level shifter.

If the output is 2.5 V for 0g, that give 0x200 as the output of the ADC. So the acceleration is ([ADC output] - 0x200)/0.8/1024*5

The tilt is arctan(accel(y)/accel(x)). However, that function is impossible to calculate near 90 degrees. What you have to do is work out which acceleration out of accel(x) and accel(y) has the largest magnitude, and divide the smaller by the larger. Then you have a number between -1 and +1, so your arctan function gives a result in the range -45 to +45 degrees. You then add the right number of 90 degrees depending on the signs of the accelerations.

For instance, say accel(x) is 0.6 and accel(y) is -0.8, accel(y) is larger in magnitude, so you divide 0.6 / -0.8 = 0.75 and arctan (-0.75) = -37 degrees.

As accel(x) is +ve and accel(y) is -ve, you are nearest to 270 degrees. Because you have divided by accel(y) you need to subtract the angle. That gives the tilt as 270 - (-37) = 307 degrees.

**broken link removed** has some arctan functions.

Tilt in 3 dimensions is has three angles, so more maths is needed if you want tilt in 3 dimensions.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top