![]() |
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! |
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. |
Re: Dual-Axis Accelerometer
Quote:
As for converting to 8bit, just shift it two bits to the right Code:
8_bit = 10_bit >> 2; |
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. |
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:
Code:
// Analog channel on the robot controller that's hooked-up to |
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.
|
Re: Dual-Axis Accelerometer
Quote:
Good Luck! -Joe |
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 |
Re: Dual-Axis Accelerometer
Quote:
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? |
Re: Dual-Axis Accelerometer
Quote:
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. |
Re: Dual-Axis Accelerometer
Quote:
Cheers! -Joe |
Re: Dual-Axis Accelerometer
Quote:
Cheers! -Joe |
Re: Dual-Axis Accelerometer
Quote:
|
Re: Dual-Axis Accelerometer
Quote:
-Kevin |
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.
|
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. |
Re: Dual-Axis Accelerometer
Quote:
|
Re: Dual-Axis Accelerometer
Quote:
|
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. |
| All times are GMT -5. The time now is 20:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi