View Single Post
  #5   Spotlight this post!  
Unread 24-02-2006, 10:09
Mike Shaul's Avatar
Mike Shaul Mike Shaul is offline
Registered User
FRC #0065 (Huskie Brigade)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Farmington Hills, MI
Posts: 53
Mike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant future
Re: accelerometer specs

Quote:
Originally Posted by bush
For my accelerometer, the sensitivity is is 312mV/g and the 0g bias is 2.5V (specs for supply voltage of 5V). The accelerometer has a range of +/- 2g, so the output voltage should have a range of 2500 +/- 624mV (1876mV - 3124mV).
Yes, this looks correct. Just as a tiny detail take a look at your sensor specification. Depending on the spec some sensors for a "+/- 2g" range may specify 2g as the nominal and some as the minimum. 90% of the time this isn't going to be a big deal unless you NEED to use the full range (and with your sensitivity this shouldn't be a problem).
Quote:
Originally Posted by KenWittlief
the only thing you will have to check is the actual zero point, it may be a little off from 512, but thats the normal value.
This is absolutely correct, and for clarity: When you power up you should take a number of analog readings and filter (average) their values to set the mid point (Bias) each time you power up (assuming you always start on level ground, which you should).

I highly recommend using signed math for this type of reading, here is a suggestion:

#define SENSITIVITY 64
// sensitivity = 312mV/g * 1024counts/5000mV = 63.89 (counts/g)

(signed)bias_corrected_voltage = (unsigned)analog_sensor_reading - (unsigned)bias_value;
(signed)acceleration = (signed)bias_corrected_voltage * (unsigned)SENSITIVITY;

This should give you acceleration. Positive and negative values based on direction, which is useful. (Anyone, please feel free to double check me!)

Also notice that without getting fancy your sensitivity is is rounded so your accuracy is limited (but not too much).

I hope this is all clear. Good luck!
__________________
By far the best proof is experience. - Sir Francis Bacon