|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
accelerometer specs
I read over the data sheet, and I don't completely understand everything. I just want to double check a few things...
1) The resolution for RC analog inputs is 10-bits, so my code would would read in values ranging from 0 to 1023. 2) Since we are supplying 5V, zero acceleration corresponds to 2.5V, which is represented by 512 in my code. 3) Acceleration is directly proportional to voltage, so an acceleration of +2g would read as 1023 in my code, and an acceleration of -2g would read as 0. +1g would read in 768, and -1g would read in 256, and so on... If I were wrong about anything, my guess would be #3. I didn't completely understand what the mV/g meant in the data sheet I might also be wrong about the code values. Similar to PWM, where we only use 0-254 with neutral at 127, this could be 0-1022 with neutral at 511. Anybody who can clarify this will be helping me out a lot. Thanks |
|
#2
|
||||
|
||||
|
Re: accelerometer specs
you are right on the money!
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. |
|
#3
|
|||||
|
|||||
|
Re: accelerometer specs
Quote:
mV/g refers to the number of millivolts (1/1000 of a volt) for each "g" sensed("g" stands for gravity, the normal force experienced by the pull of the earth at sea level, an acceleration of around 9.8 meters per second per second (m/s2), or abour 32 feet per second per second.) So, if a sensor gives out 125 mV/g, at 1 gravity you can expect to see 125 millivolts. Hope that helps, & good luck Don |
|
#4
|
|||||
|
|||||
|
Re: accelerometer specs
Hmm.. if 0g is read at 2500 mV... if mV/g was 125, wouldn't 1g be read at 2625mV?
And that leads my to my next question. 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). Isn't the conversion... CODE_VALUE = mV * (1024 / 5000mV) So my code values should have a range of 512 +/- 127 (385 for -2g and 639 for +2g)? I know I completely did a 360 from my original understanding (which was apparantley correct?), but I wan't to make sure I completely understand how this is working first. Would somebody explain where my fault is in the logic in this post. |
|
#5
|
||||
|
||||
|
Re: accelerometer specs
Quote:
Quote:
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! |
|
#6
|
||||
|
||||
|
Re: accelerometer specs
Mikes equations look correct. Sometimes you dont need to factor out the scaling of the sensor - your robot equations dont need to be in g's, if you know that 1023 is +2g and 0 is -2 g
I was working on a program once trying to calculate the RMS voltage of a chopped sinewave, which requires doing a square root calculation (try writing THAT in assembly code). After about a day of struggling with this I realized I didnt need the actual RMS (SQRT) number, I could leave the number squared and use that. (I was detecting when an RMS voltage was = 82V. The square of 82 is 6724, so instead of calculating the square root and then comparing the answer to 82, I left the number squared, and looked for 6724). Scaling the numbers in your SW to actual units (g's, volts, degrees...) is only necessary if a human needs to look at those numbers. Last edited by KenWittlief : 24-02-2006 at 11:14. |
|
#7
|
|||||
|
|||||
|
Re: accelerometer specs
Quote:
For example, last year we used nifty "follower" wheels to track our robot's position and heading during autonomous mode. The direction values were a minimally-processed version of the raw encoder counts, which got dubbed "RALPHS" for Robot alpha (angle). There was a straightforward conversion between RALPHS and degrees (or radians), but it was only used when specifying turns in the autonomous scripting. There was a corresponding "RITA" unit for distance, intended to rhyme (sort of) with "meter", but measures of linear travel usually ended up just being called encoder counts. |
|
#8
|
||||
|
||||
|
Re: accelerometer specs
Quote:
If I were choosing not to work in physical units, I'd just leave everything in volts (- bias) to minimize the calculations (as you did with encoder counts). |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accelerometer Timer Question | psquared | Programming | 3 | 12-02-2005 01:34 |
| Accelerometer Wiring/Input | DAN THE MAN | Control System | 1 | 06-02-2005 20:02 |
| Example accelerometer code released. | Kevin Watson | Programming | 0 | 20-01-2005 03:45 |
| 2004 Motor specs - Part 1 | Paul Copioli | Motors | 12 | 28-01-2004 17:40 |