|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
Re: Dual-Axis Accelerometer
Quote:
As for converting to 8bit, just shift it two bits to the right Code:
8_bit = 10_bit >> 2; |
|
#4
|
||||
|
||||
|
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
|
|||
|
|||
|
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.
|
|
#6
|
||||
|
||||
|
Re: Dual-Axis Accelerometer
Quote:
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);
}
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); |
|
#7
|
|||
|
|||
|
Re: Dual-Axis Accelerometer
Quote:
Good Luck! -Joe |
|
#8
|
||||
|
||||
|
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
|
||||
|
||||
|
Re: Dual-Axis Accelerometer
Quote:
|
|
#10
|
||||
|
||||
|
Re: Dual-Axis Accelerometer
Quote:
-Kevin |
|
#11
|
||||
|
||||
|
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.
|
|
#12
|
||||
|
||||
|
Re: Dual-Axis Accelerometer
Quote:
As a rule, any sort of math function has a good chance of being in "math.h," again, nothing a quick Google search can't confirm. |
|
#13
|
|||
|
|||
|
Re: Dual-Axis Accelerometer
LOL Ok yall....quit taking code snippets and trying to compile them. Take the snippets with grace and appreciation for the fact that there's people here that can figure this stuff out. It is YOUR responsibility to adhere to proper C syntax to get it to compile. ORRRR you can wait for Kevin Watson to finish tweaking it and supply the entire source on his site. We should ALL thank him for his work. Without him half the teams would be lost! Hip hip....hoorayyy!
![]() Oh in case it wasn't clear from my post, you need to add in the stuff that makes it a compilable C program (i.e. Math.h and appropriate brackets). Look at the rest of your working code for guidance. You could put the constants in Accel.h then the function blocks in Accel.c or something. Last edited by TubaMorg : 27-01-2006 at 22:10. |
|
#14
|
|||
|
|||
|
Re: Dual-Axis Accelerometer
Quote:
|
|
#15
|
||||
|
||||
|
Re: Dual-Axis Accelerometer
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |