Go to Post Brains and hard work aren't necessarily about age or grade. - Redhead Jokes [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 15-01-2006, 11:18
naor52 naor52 is offline
Registered User
FRC #1578
 
Join Date: Dec 2005
Location: ISREAL
Posts: 23
naor52 is an unknown quantity at this point
Dual-Axis Accelerometer

I got the Acceleration sensor working (if people are still having problems with this, PM me, i'd be happy to help) but the values i'm getting are odd....

when sitting still the value returned by Get_Analog_Value(rc_ana_in09) is around 716-717, and can get to about 915 or so when shaked.....

is this normal?

how can i transofrm these to normal 0-255 values? should i?

Thanks!
  #2   Spotlight this post!  
Unread 15-01-2006, 11:22
Noah Kleinberg Noah Kleinberg is offline
Registered User
FRC #0395 (2TrainRobotics)
Team Role: Driver
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 196
Noah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to behold
Send a message via AIM to Noah Kleinberg
Re: Dual-Axis Accelerometer

In my experience with it, that's normal.

Just like with the gyroscope, you'll need to first calculate the bias and then subtract that from all of your readings to get accurate numbers.

Last edited by Noah Kleinberg : 15-01-2006 at 11:29.
  #3   Spotlight this post!  
Unread 15-01-2006, 11:38
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by naor52
when sitting still the value returned by Get_Analog_Value(rc_ana_in09) is around 716-717, and can get to about 915 or so when shaked.....

is this normal?

how can i transofrm these to normal 0-255 values? should i?

Thanks!
I'm sure that you need to figure out the bias. However, you also might want to make sure that it's level. Remember that gravity will register on an accelerometer.

As for converting to 8bit, just shift it two bits to the right
Code:
8_bit = 10_bit >> 2;
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #4   Spotlight this post!  
Unread 15-01-2006, 12:26
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: Dual-Axis Accelerometer

shaking it doenst provide any usefull information.

use gravity as your test acceleration - first tip it one way (9.8M/S^2 down) then rotate 90 degrees (0 M/S^2) then tip it up the other way (9.8M/S^2 up).

Use those readings as your reference / zero points.

Last edited by KenWittlief : 15-01-2006 at 14:36.
  #5   Spotlight this post!  
Unread 15-01-2006, 12:56
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by sciguy125
I'm sure that you need to figure out the bias. However, you also might want to make sure that it's level. Remember that gravity will register on an accelerometer.
Here's my first-cut at code that will give an angle relative to the gravity vector, which points down. I'm working on a calibration routine for the bias,
but for now, just assume it's at the 2.5v mid-point. This code will work with the ADC code on my website. I imagine this code would work great for knowing what angle your ball launcher was at.

-Kevin

Code:
 
int Accel_Angle(void)
{
int x_axis;
int y_axis;
int angle;
 
x_axis = (int)Get_ADC_Result(X_AXIS_CHANNEL) - X_AXIS_BIAS;
 
y_axis = (int)Get_ADC_Result(Y_AXIS_CHANNEL) - Y_AXIS_BIAS;
 
angle = (int)(ANGULAR_CONVERSION * atan2((float)y_axis, (float)x_axis));
 
return(angle);
}
 
 
Here are the constants:

Code:
// Analog channel on the robot controller that's hooked-up to
// the x-axis accelerometer
#define X_AXIS_CHANNEL 1

 
// Analog channel on the robot controller that's hooked-up to
// the y-axis accelerometer
#define Y_AXIS_CHANNEL 2
 
// 800Hz sample rate & 16 samples averaged per update (see adc.h)

#define X_AXIS_BIAS 2048

#define Y_AXIS_BIAS 2048
 

// Pick the angular unit by removing the // from one of these two lines.
// #define MILLIRADIANS
// #define TENTHS_OF_A_DEGREE
#define DEGREES
 
 
#ifdef MILLIRADIANS
#define ANGULAR_CONVERSION 1000.0// milliradians per radian
#endif
 
#ifdef TENTHS_OF_A_DEGREE
#define ANGULAR_CONVERSION 573.0// tenths of a degree per radian
#endif
 
#ifdef DEGREES
#define ANGULAR_CONVERSION 57.3// degrees per radian
#endif
 
// function prototypes
int Accel_Angle(void);
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #6   Spotlight this post!  
Unread 15-01-2006, 12:59
Biff Biff is offline
Registered User
AKA: Tom Cooper
#1227 (Techno Gremlins)
Team Role: Mentor
 
Join Date: Jan 2004
Location: Grand Rapids MI
Posts: 214
Biff is a jewel in the roughBiff is a jewel in the roughBiff is a jewel in the roughBiff is a jewel in the rough
Re: Dual-Axis Accelerometer

The info is in the manual for the controller and in other places. Here goes anyway, the A/D converters on the robot control have 10 bit resolution, the code snippet above shows how to get rid of the lest significant bits. To get 0 to 254 numbers. The A/D converters on the operator interface (OI) are 8 bit, no need to bit shift them to get to 0 to 254. If you are comparing the numbers from say from a pot on the IO and one on something attached to the robot it's good to keep in mind that the a/d converters have this difference.
  #7   Spotlight this post!  
Unread 15-01-2006, 14:30
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Kevin Watson
Here's my first-cut at code that will give an angle relative to the gravity vector, which points down. I'm working on a calibration routine for the bias,
but for now, just assume it's at the 2.5v mid-point. This code will work with the ADC code on my website. I imagine this code would work great for knowing what angle your ball launcher was at.

-Kevin
If you guys decide to use the accelerometers to measure angles on your bot, keep in mind that the accelerometer will sense all accelerations in its axis. If you are moving or getting bumped or if your machine shakes violently, then you will pick up those accelerations as well as gravity, and the angle you compute will be less precise due to that noise. This will almost definitely keep you from shooting well on the run or under duress.

Good Luck!
-Joe
  #8   Spotlight this post!  
Unread 15-01-2006, 14:39
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: Dual-Axis Accelerometer

what Joe said^

and remember the magnitude of gravity doesnt change - so if your sensors are reading more that 9.8M/S^2 (vector reading) that tells you the bot is accelerating, not sitting still
  #9   Spotlight this post!  
Unread 15-01-2006, 17:23
Goldeye Goldeye is offline
Registered User
AKA: Josh Hecht
FRC #0694 (Stuypulse)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: New York
Posts: 145
Goldeye has a spectacular aura aboutGoldeye has a spectacular aura aboutGoldeye has a spectacular aura about
Send a message via AIM to Goldeye
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by naor52
I got the Acceleration sensor working (if people are still having problems with this, PM me, i'd be happy to help) but the values i'm getting are odd....

when sitting still the value returned by Get_Analog_Value(rc_ana_in09) is around 716-717, and can get to about 915 or so when shaked.....

is this normal?

how can i transofrm these to normal 0-255 values? should i?

Thanks!
No one here gave a particularly helpful explanation unless you have a good understanding of the inner workings of the code, so here ya go.
Get_Analog_Value returns an int value from 0-1024, rather than the unsigned chars. This is based on the voltage returned along the signal wire from the accelerometer.
The readings from the accelerometer pointing straight up with it resting on a nonmoving surface should be equivalent to an acceleration of zero.
When you turn the accelerometer onto its side, one of the values it returns should change. The difference between this value and the original one represents 1g of acceleration, and can be used to scale all the readings.
Precisely how to do that in code is for you to figure out.

By the way, using a timer and low level access to the ADC (Analog-digital converter), it is possible to sample the device more than once per loop, and closer to if not more frequently than the rate than device updates itself. The adc code on http://kevin.org/frc can help you do this. Use the gyro code as an example, or wait until kevin uploads his new accelerometer code. (Soon, please )

On a related note, the specs for the accelerometer have it working at 3V. Is there a way to change the power supply to that?
__________________
Team 694

2005 Championship - Galileo Semifinalist
2005 New York - Regional Chairmans Award
2005 New York - Semifinalist (Thanks 1257,1340)
  #10   Spotlight this post!  
Unread 16-01-2006, 14:19
Tatsu Tatsu is offline
Audiophile and Physicist.
AKA: Tatsu Hashimoto
FRC #1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Woodside
Posts: 49
Tatsu will become famous soon enough
Send a message via AIM to Tatsu
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Goldeye
No one here gave a particularly helpful explanation unless you have a good understanding of the inner workings of the code, so here ya go.
Get_Analog_Value returns an int value from 0-1024, rather than the unsigned chars. This is based on the voltage returned along the signal wire from the accelerometer.
The readings from the accelerometer pointing straight up with it resting on a nonmoving surface should be equivalent to an acceleration of zero.
When you turn the accelerometer onto its side, one of the values it returns should change. The difference between this value and the original one represents 1g of acceleration, and can be used to scale all the readings.
Precisely how to do that in code is for you to figure out.

By the way, using a timer and low level access to the ADC (Analog-digital converter), it is possible to sample the device more than once per loop, and closer to if not more frequently than the rate than device updates itself. The adc code on http://kevin.org/frc can help you do this. Use the gyro code as an example, or wait until kevin uploads his new accelerometer code. (Soon, please )

On a related note, the specs for the accelerometer have it working at 3V. Is there a way to change the power supply to that?

I dont think you need to "change" it to v3.3.. thats what U1 on the board is for i think, cant find the datasheet for it its a MCP something something (microchip power IC probably) anyway.. if you want to "change" the 5v output to 3.3, or 12 to 3.3 just use a voltage divider.
  #11   Spotlight this post!  
Unread 17-01-2006, 02:23
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Goldeye
On a related note, the specs for the accelerometer have it working at 3V. Is there a way to change the power supply to that?
The accelerometer's data sheet is on the US FIRST website here and is the best source of information on the device. Page 3 tells you that the power supply can range from 2.4V to 5.25V. The datasheet does list some example specs when you assume that the supply is 3V. If you look at the bottom of page 9, there is a section entitled USING THE ADXL311 WITH OPERATING VOLTAGES OTHER THAN 3 V that should shed some light on the effects of a different supply voltage.

Cheers!
-Joe
  #12   Spotlight this post!  
Unread 17-01-2006, 02:26
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Tatsu
I dont think you need to "change" it to v3.3.. thats what U1 on the board is for i think, cant find the datasheet for it its a MCP something something (microchip power IC probably) anyway.. if you want to "change" the 5v output to 3.3, or 12 to 3.3 just use a voltage divider.
In general, it's not a good idea to use a voltage divider in a power supply for a device. If you use large resistors, then any current you draw into the device will cause a larger voltage drop across the upper resistor and lower your supply voltage. If you use relatively small resistors, then you can reduce that drop, but you then have a low total resistance across your battery. This will drain your battery and make your resistors very hot. You should use a voltage regulator designed specifically for power supply applications. For relatively low currents < 500mA, you can just use a monolithic voltage regulator like an LM7805 (for a 5V regulator). LM7812 is the 12V version. You get the idea. A search on Digi-Key should yield plenty of results.

Cheers!
-Joe
  #13   Spotlight this post!  
Unread 26-01-2006, 17:24
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Kevin Watson
Here's my first-cut at code that will give an angle relative to the gravity vector, which points down. I'm working on a calibration routine for the bias,
but for now, just assume it's at the 2.5v mid-point. This code will work with the ADC code on my website. I imagine this code would work great for knowing what angle your ball launcher was at.

-Kevin

Code:
 
int Accel_Angle(void)
{
int x_axis;
int y_axis;
int angle;
 
x_axis = (int)Get_ADC_Result(X_AXIS_CHANNEL) - X_AXIS_BIAS;
 
y_axis = (int)Get_ADC_Result(Y_AXIS_CHANNEL) - Y_AXIS_BIAS;
 
angle = (int)(ANGULAR_CONVERSION * atan2((float)y_axis, (float)x_axis));
 
return(angle);
}
 
 
Here are the constants:

Code:
// Analog channel on the robot controller that's hooked-up to
// the x-axis accelerometer
#define X_AXIS_CHANNEL 1

 
// Analog channel on the robot controller that's hooked-up to
// the y-axis accelerometer
#define Y_AXIS_CHANNEL 2
 
// 800Hz sample rate & 16 samples averaged per update (see adc.h)

#define X_AXIS_BIAS 2048

#define Y_AXIS_BIAS 2048
 

// Pick the angular unit by removing the // from one of these two lines.
// #define MILLIRADIANS
// #define TENTHS_OF_A_DEGREE
#define DEGREES
 
 
#ifdef MILLIRADIANS
#define ANGULAR_CONVERSION 1000.0// milliradians per radian
#endif
 
#ifdef TENTHS_OF_A_DEGREE
#define ANGULAR_CONVERSION 573.0// tenths of a degree per radian
#endif
 
#ifdef DEGREES
#define ANGULAR_CONVERSION 57.3// degrees per radian
#endif
 
// function prototypes
int Accel_Angle(void);
In this code what is "atan2"? When I compile this code it gives me a prototyping error. I deleted the line with "atan2" and it compiled just fine. I can't seem to find "atan2" anywhere else in the code.
  #14   Spotlight this post!  
Unread 26-01-2006, 17:30
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by railerobotics
In this code what is "atan2"? When I compile this code it gives me a prototyping error. I deleted the line with "atan2" and it compiled just fine. I can't seem to find "atan2" anywhere else in the code.
Um, before posting, perhaps you could just google "atan2()".

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #15   Spotlight this post!  
Unread 26-01-2006, 18:12
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Re: Dual-Axis Accelerometer

Sorry, Thanks. I still can't figure out why it is giving me a protoype error on the line that has atan2.
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
Dual fields Keith Chester Rumor Mill 11 05-04-2005 17:57
Accelerometer Timer Question psquared Programming 3 12-02-2005 01:34
URGENT! We need help with the accelerometer lkdjm Electrical 5 11-02-2005 16:42
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


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

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