WARNING. Starting from WiiC 1.1, a different organization in the acceleration data structures has been adopted. This page refers to this version, and does not refer anymore to the previous versions.

The Wii Remote is equipped with a three-axis linear accelerometer ADXL330. For further details about this sensor, you can refer to WiiBrew. In this section we describe all the functionalities provided by WiiC to exploit accelerometer data.

Calibration Data

Accelerometers' calibration values are stored in the EEPROM memory of each Wiimote device, and are loaded at start up.

C Layer

Every connected Wiimote device is associated to a struct wiimote_t, which in turn contains the variable struct accel_t accel_calib where calibration values are stored:

typedef struct accel_t {
        struct vec3b_t cal_zero;	/**< zero calibration			*/
        struct vec3b_t cal_g;		/**< 1g difference around 0cal		*/
        float st_alpha;			/**< alpha value for smoothing [0-1] */
} accel_t;

In particular, struct vec3b_t cal_zero are the zero values along all the three axes, while struct vec3b_t cal_g contains the g values along the three axes when the device is still, and are used to normalize the accelerometer values.

C++ Layer

It is possible to retrieve the g calibration values with the method:

void CAccelerometer::GetGravityCalVector(float &X, float &Y, float &Z)

Raw Acceleration Values and Gravity Vector

C Layer

Updated raw accelerometer values are stored in struct wiimote_t in the variable struct vec3b_t accel. On the other hand, the gravity vector is calculated through the function void calculate_gforce(struct accel_t* ac, struct vec3b_t* accel, struct gforce_t* gforce) and stored in struct wiimote_t in the variable struct gforce_t gforce. Basically, these values are computed from the difference between raw values and zero calibration values, normalized with respect to g calibration values, smoothed (if enabled), and stored in gforce.vec, as here reported:

gforce->a_vec.x = ((int)accel->x - (int)ac->cal_zero.x) / xg;
gforce->a_vec.y = ((int)accel->y - (int)ac->cal_zero.y) / yg;
gforce->a_vec.z = ((int)accel->z - (int)ac->cal_zero.z) / zg;

if(smooth) {
        apply_smoothing(gforce, ac->st_alpha);
else {
        gforce->vec.x = gforce->a_vec.x;
        gforce->vec.y = gforce->a_vec.y;
        gforce->vec.z = gforce->a_vec.z;

If smoothing is enabled, then an exponential moving average is applied on raw accelerometer data: St = St_last + (alpha * (tilt - St_last)). The smoothing parameter alpha (default value is 0.9) can be set by using the function:

float wiic_set_smooth_alpha(struct wiimote_t* wm, float alpha)

Smoothing is enabled by default. If smoothing is enabled but you still want unsmoothed gravity vector, they are stored in gforce.a_vec.

C++ Layer

It is possible to access the gravity vector (both smoothed and unsmoothed), through the methods:

void CAccelerometer::GetGravityVector(float &X, float &Y, float &Z) // smoothed data
void CAccelerometer::GetRawGravityVector(float &X, float &Y, float &Z) // unsmoothed data

Needless to say, in case smoothing is disabled, the effect of both the methods is equivalent. The smoothing alpha parameter can be set by using the method:

float CAccelerometer::SetSmoothAlpha(float Alpha)

Wiimote Attitude

The Wiimote attitude is reported as roll, pitch and yaw angles (in degrees), calculated from raw accelerometer values. It is worth noting three aspects:

  1. without IR or MotionPlus, it is impossible to retrieve the yaw angle, since the Z component reported by the accelerometer is parallel to the g gravity vector;
  2. accelerometers are precise only when the Wiimote is relatively still. In fact, Accelerometers report the combination of the gravity vector plus the linear acceleration caused by the device's motion. Thereby, it is impossible to identify only the gravity vector when the device is moving, and WiiC discards acceleration values greater in module then 1g to compute the device attitude;
  3. If you enabled smoothing, then the orientation will be computed on smoothed acceleration data.

C Layer

Attitude values are stored in struct wiimote_t in the variable struct orient_t orient, here reported:

typedef struct orient_t {
        struct ang3f_t angle; /**< roll, pitch and yaw (this may be smoothed)*/
} orient_t;

C++ Layer

The attitude can be respectively retrieved through the following methods:

void CAccelerometer::GetOrientation(float &Pitch, float &Roll, float &Yaw)




edit SideBar

Blix theme adapted by David Gilbert, powered by PmWiki