The accX and accY values are about 1.5 each when the board is at rest. Do we need to use SetZero? I tried putting in 1.5 for the value and then accX went to an entirely different non zero value, -2.5 or something like that. Can I just use AnalogChannel and do the scaling in the code?
Before you do, be sure you are telling the class that your center point is 1.5V and your sensitivity is 300mV/g. I think the class assumes a different model.
If you read the WPILib source code, it gives you some hints.
/**
* Set the accelerometer sensitivity.
*
* This sets the sensitivity of the accelerometer used for calculating the acceleration.
* The sensitivity varys by accelerometer model. There are constants defined for various models.
*
* @param sensitivity The sensitivity of accelerometer in Volts per G.
*/
void Accelerometer::SetSensitivity(float sensitivity)
{
m_voltsPerG = sensitivity;
}
...
/**
* Set the voltage that corresponds to 0 G.
*
* The zero G voltage varys by accelerometer model. There are constants defined for various models.
*
* @param zero The zero G voltage.
*/
void Accelerometer::SetZero(float zero)
{
m_zeroGVoltage = zero;
}
So for the KoP accelerometer (zero G = 1.5V, sensitivity = 300mV/G), call: