Go to Post Stop whining about something that can be fixed by working harder. - artdutra04 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-02-2006, 21:56
bush's Avatar
bush bush is offline
Registered User
AKA: Aaron
FRC #0710 (Pine Crest School)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Fort Lauderdale, Florida
Posts: 42
bush has a spectacular aura aboutbush has a spectacular aura about
Send a message via AIM to bush
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   Spotlight this post!  
Unread 23-02-2006, 22:42
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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   Spotlight this post!  
Unread 23-02-2006, 22:47
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,979
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: accelerometer specs

Quote:
Originally Posted by bush
I didn't completely understand what the mV/g meant in the data sheet
You have it correct. Remember that calibration is not perfect, so you may be off by a few counts. A good source of gravity is the earth: When the sensor is pointing "down" it will measure 1 g (1 gravity).

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
__________________

I am N2IRZ - What's your callsign?
  #4   Spotlight this post!  
Unread 23-02-2006, 23:02
bush's Avatar
bush bush is offline
Registered User
AKA: Aaron
FRC #0710 (Pine Crest School)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Fort Lauderdale, Florida
Posts: 42
bush has a spectacular aura aboutbush has a spectacular aura about
Send a message via AIM to bush
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   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
  #6   Spotlight this post!  
Unread 24-02-2006, 11:12
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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   Spotlight this post!  
Unread 24-02-2006, 11:32
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: accelerometer specs

Quote:
Originally Posted by KenWittlief
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.
And even if someone does need to look at the numbers, the scaling can be done as part of the input and/or display of the values. The robot can still do all the real work using a convenient internal representation for everything else.

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   Spotlight this post!  
Unread 24-02-2006, 13:45
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 KenWittlief
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.
You are correct, it is not necessary. However... working in a standard unit is good practice for larger systems. Always conforming to a physical unit is nice, and actually... m/s^2 would be a better unit than g's.

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).
__________________
By far the best proof is experience. - Sir Francis Bacon
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 10:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi