|
Re: Arduino and FRC Sensors
Any way you do it, you'll end up with raw data, which will need filtering and math to get useful information.
A gyro measures yaw rate, so it outputs a velocity. If you integrate it once, you will get angular heading. If it's analog, you'll also need a center bias, usually digital ones output a signed number. Don't worry about the calculus, it's fairly easy to "cheat" in robotics programming.
An accelerometer measures acceleration, so you'll need to integrate it once to get velocity and twice to get distance (at which point it's very inaccurate). If you aren't moving at all, you can use it as an inclinometer by finding the vector G from multiple axis of acceleration perpendicular to each other. Like the analog gyro, analog accelerometers need a center bias.
If you want vehicle speed and/or position, a pair of quadrature encoders and a gyro is the way to go. Although there can be wheel slip in the encoders, they're generally more accurate than the second integration of acceleration (which itself could be a noisy analog signal).
If you want to run quadrature encoders, you'll need to setup an ISR on one or both of the pins, on one or both edges (the number of interrupts = the decoding, one edge of one pin = 1x, both edges of one pin = 2x, both edges of both pins = 4x) and check the other pin to get direction. Speed comes from the first derivative of distance or the time between samples (I recommend filtering it any way you do it, it will be fairly noisy).
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor
"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
|