I am testing out a Wii Nunchuck with the FEZ_Components_Wii.cs library and am getting some unexpected results.
My wires are connected to the Domino like so:
Ground to Ground
Power to 5V
SDA to Di2
SCL to Di3
I placed some Debug statements in the Reset() method of class FEZ_Components_Wii like so:
Debug.Print(“Failed to connect”);
Debug.Print(“Connection to Wii Controller Established”);
Here is some sample the output. Notice that the XY values never change and the “Failed to Connect” repeats excessively even though I see the connect message happening. I also don’t understand the other output regarding the Type and Bytes.
I am hoping someone can tell me something about this. Thanks
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Connection to Wii Controller Established
GC: 3msec 28320 bytes used, 36060 bytes available
Type 0F (STRING ): 144 bytes
Type 11 (CLASS ): 1884 bytes
Type 12 (VALUETYPE ): 204 bytes
Type 13 (SZARRAY ): 1884 bytes
Type 15 (FREEBLOCK ): 36060 bytes
Type 17 (ASSEMBLY ): 19116 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 288 bytes
Type 1D (OBJECT_TO_EVENT ): 168 bytes
Type 1E (BINARY_BLOB_HEAD ): 156 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 636 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 27 (FINALIZER_HEAD ): 144 bytes
Type 31 (IO_PORT ): 108 bytes
Type 33 (I2C_XACTION ): 48 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 2460 bytes
Analog X: 129 Analog Y: 132 Accel X: 523 Accel Y: 523
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Failed to connect
Analog X: 129 Analog Y: 132 Accel X: 523 Accel Y: 523
Failed to connect
Thank you for looking at my post. Below are some code snippets. Can the Architect please describe the disabling of the GC messages? I am using a wired Nunchuck. Thanks
// From Program.cs
public static void Main()
{
while (true)
{
Debug.Print(" Analog X: " + FEZ_Components.Wii.Nunchuk.AnalogStickX + " Analog Y: " +
FEZ_Components.Wii.Nunchuk.AnalogStickY +
" Accel X: " + FEZ_Components.Wii.Nunchuk.AccelerateX + " Accel Y: " + FEZ_Components.Wii.Nunchuk.AccelerateY);
Thread.Sleep(500);
}
}
//From FEZ_Components_Wii.cs
// The only thing I edited from the download are the debug statements
// that indicate connection is made or not.
public static bool Reset()
{
// Initialize NumChuck by sending 0x40, 0x00
I2CDevice.I2CTransaction[] NumChuckInitializeTrans = new I2CDevice.I2CTransaction[1];
NumChuckInitializeTrans[0] = I2CDevice.CreateWriteTransaction(new byte[] { 0x40, 0x00 });
if (NumChuckDevice.Execute(NumChuckInitializeTrans, 100) == 0)
{
Debug.Print(“Failed to connect”);
Connected = false;
return false;
}
else
{
Debug.Print(“Connection to Wii Controller Established”);
Connected = true;
return true;
}
}
The initialize is above the while loop which I omitted for brevity.
// This demo is for the Nunchuk controller. If you are using Classic controller then
// replace FEZ_Components.Wii.Nunchuk with FEZ_Components.Wii.ClassicController
FEZ_Components.Wii.Nunchuk.Initialize();
// blink LED with speed according to Nunchuk analog stick Y position
// Remember to add the LED component driver
FEZ_Components.LED OnboardLED = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
All I2C devices have manufacturer assign address, Wii has 0x52,
real time clock DS1307 has address = 0x68, etc.
It is some kind of ID so the master and slave could communicate since all the I2C devices use the same SCL and SDA pins.
You can find out more about the I2C in the Beginner e-Book, page 83
Looking at this today I noticed some charing around the chip.
I think what happened is that because this is an after market Wii controller from MonoPrice.com it may not like the higher voltage like the official Nintendo controller tolerates. As such mine if fried.
I ordered another one but will need to add a resistor to the power pin to reduce the voltage.