Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: bootstrap on February 14, 2008, 09:14:43 AM

Title: how to use an accelerometer?
Post by: bootstrap on February 14, 2008, 09:14:43 AM
Hello.I am new to using sensors .I have not used a sensor till now.I have bought an accelerometer to measure angles and send them back to the PC via the serial port.
Before doing that please guide me about how to interface a sensor to a micro controller (atmega8) and how to read the values.As I know a sensor generates an analog voltage signal which is to be taken up by a pin on the microcontroller.Thats it..i dont know which pin and mathematically analysing the values generated..Please help
Title: Re: how to use an accelerometer?
Post by: SgtToad on February 14, 2008, 10:00:04 AM
http://www.societyofrobots.com/robotforum/index.php?topic=602.0
Title: Re: how to use an accelerometer?
Post by: Rebelgium on February 14, 2008, 12:39:09 PM
to read an analog voltage with a microcontroller you'll have to connect it to the internal ADC, read the datasheet.
Title: Re: how to use an accelerometer?
Post by: Admin on February 17, 2008, 12:11:56 PM
equations here:
http://www.societyofrobots.com/sensors_accelerometer.shtml
Title: Re: how to use an accelerometer?
Post by: bootstrap on February 18, 2008, 10:52:27 PM
The accelerometer is MMA7261.Can I use it to measure angle (tilt )and implement as john palmisano did to move the servo along with the tilt of the acclerometer?
Title: Re: how to use an accelerometer?
Post by: silo_xtreme on February 18, 2008, 11:03:24 PM
of course, it just depends how (which axis) you mount it on.

For example, you will measure tilt (front to rear) if you align the sensor parallel to the body frame (long ways - front to back).

you'll measure tilt (or side tilt) if you place it perpendicular.
Title: Re: how to use an accelerometer?
Post by: bootstrap on February 19, 2008, 10:16:08 PM
equations here:
http://www.societyofrobots.com/sensors_accelerometer.shtml
I know about the hardware setup.But program part I am having probs.I need help reagrding the C code about using an accelerometer..

Title: Re: how to use an accelerometer?
Post by: Admin on February 23, 2008, 03:16:48 PM
Quote
I need help reagrding the C code about using an accelerometer..
just show us what you currently have and tell us where exactly you are stuck
Title: Re: how to use an accelerometer?
Post by: bootstrap on February 26, 2008, 06:56:16 AM
Quote
I need help reagrding the C code about using an accelerometer..
just show us what you currently have and tell us where exactly you are stuck

I had a problem with interfacing the accelerometer and programming the micro controller to read the accelerometer values.Right now I am able to get 10 bit adc values to be read.Now I have to hook up the accelerometer.As the accelerometer operates on 3.3 volts I also need to make up a resistive volatage divider.Do i need to keep a resistive voltage divider to each and every pin of the accelerometer? (I have the microcontroller running at 5v.)

Also do I need to keep as resistive voltage divider between "ADC pin" of the Microcontroller and the "X out" of the accelerometer?

Also what is the ideal capacitor (value ) to be used?And what is the capacitor that you used in your accelerometer ?
Title: Re: how to use an accelerometer?
Post by: paulstreats on February 28, 2008, 06:16:42 AM
You should only need 1 voltage divider for the vcc of the accelerometer.

The mcu running at 5 volts can still read in the 3.3v x output on an analogue pin, but it obviously wont be a very good resolution. You might want to consider using an opamp to boost the output of the accelerometer or maybe try to change the analog/digital reference to 3.3v .

If you are using a 10-bit a/d conversion then i would personally just try it because you might get a resolution that you can use - ive got a 3.3v 3axis accelerometer that i use on a 5v mcu with 10bit sampling it works good enough for me. all it means is that the highest output would register 675.83 instead of 1024
Title: Re: how to use an accelerometer?
Post by: bootstrap on March 01, 2008, 08:54:09 PM
So paul if i use an op-amp then will all the voltages above 3.3 will be boosted to 5 v?or will the op-amp add some fixed amount of voltage to each and every output voltage.What I want is 0 - 3.3 v should be scaled to 0 - 5 v.How shall I do this?
Title: Re: how to use an accelerometer?
Post by: Admin on March 15, 2008, 05:12:53 PM
You will need an op-amp:
http://www.societyofrobots.com/schematics_voltamp.shtml