Author Topic: how to use an accelerometer?  (Read 4564 times)

0 Members and 1 Guest are viewing this topic.

Offline bootstrapTopic starter

  • Full Member
  • ***
  • Posts: 61
  • Helpful? 0
how to use an accelerometer?
« 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

Offline SgtToad

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0

Offline Rebelgium

  • Supreme Robot
  • *****
  • Posts: 637
  • Helpful? 0
  • It's called the future ... We like it here
    • orgcrime.net
Re: how to use an accelerometer?
« Reply #2 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.
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how to use an accelerometer?
« Reply #3 on: February 17, 2008, 12:11:56 PM »

Offline bootstrapTopic starter

  • Full Member
  • ***
  • Posts: 61
  • Helpful? 0
Re: how to use an accelerometer?
« Reply #4 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?

Offline silo_xtreme

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Re: how to use an accelerometer?
« Reply #5 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.

Offline bootstrapTopic starter

  • Full Member
  • ***
  • Posts: 61
  • Helpful? 0
Re: how to use an accelerometer?
« Reply #6 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..

« Last Edit: February 22, 2008, 01:54:39 AM by infibit »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how to use an accelerometer?
« Reply #7 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

Offline bootstrapTopic starter

  • Full Member
  • ***
  • Posts: 61
  • Helpful? 0
Re: how to use an accelerometer?
« Reply #8 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 ?
« Last Edit: February 28, 2008, 05:37:23 AM by infibit »

paulstreats

  • Guest
Re: how to use an accelerometer?
« Reply #9 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

Offline bootstrapTopic starter

  • Full Member
  • ***
  • Posts: 61
  • Helpful? 0
Re: how to use an accelerometer?
« Reply #10 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?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how to use an accelerometer?
« Reply #11 on: March 15, 2008, 05:12:53 PM »