1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<meta http-equiv="Content-Style-Type" content="text/css">
7<title>WBC Library Introduction</title>
8<link rel="stylesheet" type="text/css" href="../CSS/revolution.css">
9</head>
10
11<body>
12
13<h1>
14WBC API Introduction
15</h1>
16
17<h2>Introduction</h2>
18
19<p>
20The WBC Library is used to convert the raw values obtained using <CODE>WPADRead</CODE> from Wii Balance Board accessory (press values) into weight values.
21</p>
22
23<h2><strong>To Use this Library</strong></h2>
24
25<p>The following include file is required:
26
27
28<code>$REVOLUTION_SDK_ROOT/include/revolution/wbc.h</code>
29
30
31<p>The library archive file is <code>$REVOLUTION_SDK_ROOT/RVL/lib/wbc[D].a</code>.
32</p>
33
34
35
36<h2>About the Wii Balance Board Accessory</h2>
37The Wii Balance Board accessory has four legs, with a balance sensor attached to each leg. When subjected to a load, they return a value in proportion to the weight of the load. Specifically, the heavier the load, the larger the value returned.<br><br>The Wii console communicates wirelessly with the Wii Balance Board accessory at 200 samples per second, the same as the Wii Remote controller. However, the Wii Balance Board accessory's balance sensor values can change at a rate of only 60 samples per second.
38
39
40The order of the press values in the array obtained by <CODE>WPADRead</CODE> corresponds to the Balance Board's legs as shown below.
41<P><IMG src="image/wbc.gif" width="427" height="275"></P>
42
43
44To use the Wii Balance Board accessory, it must first be normal-paired with a Wii console. Pair the Balance Board by pressing SYNC on the Wii console and on the Wii Balance Board accessory at the same time.<br><br>
45
46Only a single Wii console can be normal-paired with a Wii Balance Board accessory. You can use <CODE>WPADIsRegisteredBLC</CODE> to check whether a Wii Balance Board accessory has already been paired. If a paired Wii Balance Board accessory is then paired with a different Wii console, the Wii Balance Board accessory's settings are overwritten and it will need to be normal-paired again. <br><br>Wii Balance Board accessory is always connected to P4. <font color="#FF0000"><u><strong>The application must perform disconnection processing if a Wii Remote controller has already been connected to P4. Be aware that the library does not perform this disconnection processing.</strong></u></font>
47
48<h2>Using the Library</h2>
49
50
51<h3><u>1. Loading Calibration Data and Creating a Conversion Formula</u></h3>
52
53<p>
54First, create a conversion formula within the library, which will convert the readings to weights. Each Wii Balance Board accessory stores unique calibration data, and the conversion formula uses that calibration data. By calling <a href="WBCSetupCalibration.html"><code>WBCSetupCalibration</code></a>, the calibration data will be loaded and the conversion formula will be created within the library.
55
56Bear in mind that <font color="#FF0000"><u><code>WBCSetupCalibration</code> may be executed only after the Wii Balance Board accessory is paired.</u></font>For details, see the sample demo (<CODE>handling_weight.c</CODE>).<br>
57
58After this function is executed, you may use the <a href="WBCRead.html"><code>WBCRead</code></a>, <a href="WBCSetZEROPoint.html"><code>WBCSetZEROPoint</code></a>, and <a href="WBCGetTGCWeight.html"><code>WBCGetTGCWeight</code></a> functions.
59
60(The <a href="WBCGetBatteryLevel.html"><code>WBCGetBatteryLevel</code></a> function can be used without executing <a href="WBCSetupCalibration.html"><code>WBCSetupCalibration</code></a> beforehand, but it is the only exception.) <br><br>Control will return immediately after executing this function, but its actual processing continues for a short time (about 650ms) before completing. Use <a href="WBCGetCalibrationStatus.html"><code>WBCGetCalibrationStatus</code></a> to determine whether this function has completed normally.
61
62</p>
63
64
65<h3><u>2. Setting the Zero Point</u></h3>
66
67<p>Setting the zero point is the act of setting the Wii Balance Board accessory's unloaded state in the WBC Library. The zero point <font color="#FF0000"><u><strong>must be set every time before measuring a weight</strong></u></font>. (Refer to <a href="#mark2">6. Balance Sensors</a> for more on the importance of always setting the zero point.)
68
69</p>
70
71<p><em><CODE>s32 WBCSetZEROPoint(double press_ave[], u32 size);</CODE></em></p>
72
73<p>
74For the <STRONG><CODE><EM>press_ave</EM></CODE></STRONG> argument, set the average value of all the press values obtained by <CODE>WPADRead</CODE> over a period of two seconds. Set <STRONG><CODE><EM>press_ave</EM></CODE></STRONG> in the same order as the press values. (For example, the average of <STRONG><CODE><EM>status.press[1]</EM></CODE></STRONG> should be inserted into <STRONG><EM><CODE>press_ave[1]</CODE></EM></STRONG>.) In <CODE><STRONG><EM>size</EM></STRONG></CODE>, specify the the number of elements in the <CODE><STRONG><EM>press_ave</EM></STRONG></CODE> array. (Normally, allocate space for four elements.)<br> <br>
75
76Before sampling for each press value, use the temperature update command (<a href="../WPAD/WPADControlBLC.html"><code>WPADControlBLC</code></a>) to update the Wii Balance Board accessory's temperature information.
77
78
79After updating the temperature with the temperature update command (<a href="../WPAD/WPADControlBLC.html"><code>WPADControlBLC</code></a>), use <CODE>WPADRead</CODE> to confirm that temperature was correctly updated.<font color="#FF0000"><u><strong>On very rare occasions a value of -128 or 127 is returned for temperature. If that happens, execute the temperature update command again.</strong></u></font><br>
80
81On very rare occasions, the Wii Balance Board press values can fluctuate wildly for a short period after a command is sent.<font color="#FF0000"><u><strong>Therefore, after issuing the temperature update command, wait a short time (roughly 200ms) before getting the press values.</strong></u></font><br>
82</p>
83
84
85<h3><u>3. Converting to Weight Values</u></h3>
86
87<p>The readings are converted into weight values with the following function.</p>
88
89<p><em><CODE>s32  WBCRead(WPADBLStatus *status, double weight[], u32 size);</CODE></em></p>
90
91<p>
92Specify the <CODE>WPADBLStatus</CODE> structure, obtained with <CODE>WPADRead</CODE>, as an argument. The converted weight values will be stored in <CODE><STRONG><EM>weight</EM></STRONG></CODE> array in the same order as the array of press values. In <CODE><STRONG><EM>size</EM></STRONG></CODE>, specify the the number of elements in the <CODE><STRONG><EM>weight</EM></STRONG></CODE> array. (Normally, allocate space for four elements.)
93</p>
94
95<h3><u>4. Correcting the Values</u></h3>
96
97The following function carries out both temperature correction and correction for gravitational acceleration.
98
99<p><em><CODE>double WBCGetTGCWeight(double total_weight_ave, WPADBLStatus *status);</CODE></em></p>
100
101
102<p>
103In the <CODE><STRONG><EM>total_weight_ave</EM></STRONG></CODE> argument, specify the average value obtained over a period of two seconds (120 samples) for the total of the weight values obtained by <CODE>WBCRead</CODE> at four different points. <font color="#FF0000"><u><strong>You must always execute correction before using the weight values. </strong></u></font> For more about the importance of correcting for temperature and gravitational acceleration, refer to <a href="#mark2">6. Balance Sensors</a>.
104
105
106</p>
107
108<h3><u>5. Sensors and Battery Lifetime</u></h3>
109<p>
110The balance sensors on each of the Wii Balance Board accessory's four corners will cease to operate when their remaining battery life drops below a certain threshold. However, the wireless module will continue to operate even below the threshold, causing data to continue to be sent from the Wii Balance Board accessory. All values of press will become zero at this time.<br><br>When the remaining battery life is below the threshold, the <code>WBCGetBatteryLevel</code> function will return zero. The application uses this function to check the remaining battery life; if zero is returned, prompt the user to replace the battery.
111</p>
112
113
114<a name="mark2">
115<h3><u>6. Balance Sensors</u></h3>
116</a>
117
118<p>
119Balance sensors have the characteristic of not completely returning to their original state after a weight is applied and then subsequently reduced; that is, they exhibit hysteresis. For example, assume that the zero point has been set. A person (or object) gets onto and then off of the Wii Balance Board accessory. Now, the state of the Wii Balance Board accessory is not exactly the same as its state when the zero point was set.<br>In this way, the unloaded state of the balance sensors changes every time a person (or object) gets onto and off of the Board. For this reason, <font color="#FF0000"><u><strong>you must always set the zero point before making an accurate measurement.</strong></u></font><br><br>
120
121The balance sensors are metallic (aluminum). The malleability of a metal changes with the temperature. Specifically, they are more malleable (easier to bend) at high temperatures and more stiff (difficult to bend) at low temperatures. More malleable balance sensors will yield heavier weight values, while more stiff ones will yield lighter weight values.<br><br>&quot;Weight&quot; changes in proportion to gravity. As a result, weight values must take gravitational acceleration into account. Gravitational acceleration differs slightly with latitude. Specifically, the earth's rotation applies the greatest centrifugal force to a latitude of zero (right on the equator), causing a smaller gravitational acceleration there. The end result is that weight values at the equator will be lighter, and weight values at the north and south poles will be heavier. <br><br>
122
123The <CODE>WBCGetTGCWeight</CODE> function corrects for both temperature and gravitational acceleration. Always use the <CODE>WBCGetTGCWeight</CODE> function to correct weight values when making accurate measurements. <BR><BR>The following steps summarize the ideal process for making accurate measurements:
124<p>1. Have the player step off of the Wii Balance Board accessory. <br>2. Set the zero point when there is no load. <br>3. Immediately have the player step onto the Wii Balance Board accessory and measure the player's weight. <br>4. Correct the measured weight value using the correction function. <br></p>
125
126
127</p>
128
129
130
131<h2>Caution</h2>
132<font color="#FF0000"><u><strong>For the HOME Menu library, use one that is exclusively made for the Wii Balance Board accessory. </strong></u></font> This is because the portion that processes remaining battery power is different from that used with the Wii Remote controller.
133
134<h2>Revision History</h2>
135
136<p>
1372008/02/22 Supplemented the description of the two-second average with information about 120 samples.<br>2007/12/06 Added a warning related to disconnecting a P4 link. Added a cautionary note on setting the zero point.<br>2007/11/15 Changed internal processing of the Wii Balance Board accessory's pairing information. Revised the text to reflect this. Added text regarding Sensors and Battery Lifetime.<br>2007/10/02 Changed the name of <CODE>WBCInit</CODE> to <CODE>WBCSetupCalibration</CODE>. Revised the text to reflect this.<br>2007/09/28 Corrected typos.<br>2007/09/26 Added more to the Wii Balance Board accessory description. Added the caution about obtaining the temperature.<br>2007/09/10 Added to the Wii Balance Board accessory description. Revised text in line with changes to the function format.<br>2007/08/31 Initial version.
138</p>
139
140<hr><p>RVL-06-0287-001-C<br>CONFIDENTIAL</p></body>
141</html>
142