# Wiimote/Motion analysis

## Calibration

If we can assume the sensor response to acceleration is roughly linear and the chip is precisely oriented on the circuit board, then calibrating the Wiimote sensor is a three step procedure. We only need the raw integer force sensor readings for these three positions on a flat, level table:

1. Horizontal with the A button facing up: (x1, y1, z1)
2. IR sensor down on the table so the expansion port is facing up: (x2, y2, z2)
3. Laying on its side, so the left side is facing up: (x3, y3, z3)

In each of these cases, we are measuring g on one axis, and the zero point on the other two axes. We can estimate the zero points of each axis to be:

x0 = (x1 + x2)/2
y0 = (y1 + y3)/2
z0 = (z2 + z3)/2


Starting with any integer reading from the sensor (xraw, yraw, zraw), the calibrated force readings are:

$x = \frac{x_{raw} - x_0}{x_3 - x_0}$
$y = \frac{y_{raw} - y_0}{y_2 - y_0}$
$z = \frac{z_{raw} - z_0}{z_1 - z_0}$


The calibrated force is now in units where g = 1.0.

Following a 3-step calibration procedure that requires a table might be a hassle for the user, so a less rigorous procedure may be preferable. Based upon the above example, we might conjecture (possibly incorrectly) that the gain of the sensor (size of g, basically) is more uniform between remotes than the zero offset. In that case, we would only need the remote to be at rest briefly in order to determine the zero offsets for all 3 axes at once. Such a procedure might in fact be the only way to calibrate the Nunchuk sensor, as that controller does not have the flat surfaces needed to perform the 3-step calibration.