Wireless Nunchuk picaxe interfacing
EDIT: problem solved
Hi,
Does anybody have any experiences of connecting wireless nunchuk to picaxe. I am working on this and can't find anybody who has tried it. Many people have succesfully made it with arduino (and many have had problems). I try to modify attached BASIC code according to arduino codes.( different nunchuks need different codes).
Could some of you multitalented arduino/picaxe gurus help me to figure out how to modify the code? Michael Dreher-a pioneer on this hack- has listed the needed steps(http://www.windmeadow.com/node/42):
1. The initialization sequence must be changed and because it takes some time before the controller is connected via the wireless connection it has to be done in a loop until it works
2. The decryption (^ 0x17 + 0x17) is then no longer needed
3. Send_zero () has to be called 3 times in a row
4. The TWI freq must be set to 400000
5. The controller type can be read to verify that you really have an Nunchuck
6. When an error occours, the controller must be reinitialized
It seems that number 1, 4, and 5 are essential on all nunchuks, need of other changes vary.
If you have any comments or could help with code, it would be very helpfull. I know very little about c languages and try to do this just through trial and error :)
EDIT: This code works (should work)with any cheap copy nunchuk, wireless or not. You should synco your wireless 'chuk during pause of initialization. Some normal knock off nunchuks wont work on i2cfast mode.
Symbol joystick_x = b10
Symbol joystick_y = b11
Symbol Accel_X = b12
Symbol Accel_y = b13
Symbol Accel_z = b14
Symbol Accel_buttons = b15 ' lower 2 bits of accel & Z,C button states
Symbol nunchukaddress = 0xA4
Init:
pause 3000
hi2csetup i2cmaster, nunchukaddress, i2cfast, i2cbyte
hi2cout (0xF0,0x55)
pause 1
hi2cout (0xFB,0x00)
pause 1
main:
readNunchuk:
hi2cout (0x00)
pause 1
hi2cin (joystick_x,joystick_y,Accel_X,Accel_Y,Accel_Z,Accel_buttons)
pause 1
debug
goto main



@ Sat, 2012-01-28 23:41
Edit:Another code:
I remove those ugly old codes.
I solved the problem. I think this can be useful to somebody. I couldn't find any cases somebody doing this with picaxe i had to work it out myself. Problems were that i didn't at first realize that picaxe needs 8-bit not 7-bit address. Another problem was that i tried first hicout 0xa4, (0xF0) etc. in initialization but i realized i have to just write them like they are in code above. Third issue was that picaxe automatically changes the last bit of address when reading i2c device which was confusing when translating the code from other platforms. Hard enough for a history teacher with no experience of programming.
these cheap nunchuk fakes are quite funny. You can get a i2c interfaced 3-axis accelometer as cheap as $3.88. And wireless ones are something 12$. BUT they won't work with same commands as original ones.
@ Sat, 2012-01-28 23:43
Arduino codes
Arduino codes for this hack:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1259091426/135