Wiimote remote IR-camera

JanJor

Member
Dear all, I took out the IR-camera from a Wii-mote remote control and used it to build the stand-alone camera that was made by "robotfreak", seehttp://letsmakerobots.com/node/7752

The reason: this would be the long sought-for solution for our robot location problem: the camera on the ceiling and an IR-led on the robot would do the trick!

I know the camera address and I used I2C protocolls to read out the camera, and I get the impression that in principle there is some contact between the camera and the picaxe. (Protocolls used: READI2C (variable,...) and READI2C location,(variable,...). Both protocolls give at least som coherent rows of numbers. However: waving an IR-led or a candle in front of the camera does not change the numbers (this should be the case).

My question now is the following: before diving into the details of the I2C protocolls used: it would seem that the camera needs some initiation (through writeI2C). This is also suggested on Robotfreak's website (see wii_remote_ir_sensor_sample.pde at his website). But the problem is: I tried that but it does not at all change the readout of the camera. So briefly: has any member of this forum experience with the readout of this Wii-mote camera?

Thanks very much in advance for your reaction.

Ronald
 

Technical

Technical Support
Staff member
Try this (not tested)

Code:
hi2csetup i2cmaster, 0XB0, i2cslow, i2cbyte
pause 10
 
hi2cout 0x30, (0x01)
pause 10
hi2cout 0x30, (0x08)
pause 10
hi2cout 0x06, (0x90)
pause 10
hi2cout 0x08, (0xC0)
pause 10
hi2cout 0x1A, (0x40)
pause 10
hi2cout 0x33, (0x33)
pause 10
 
  do
  hi2cin 0x36, (b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)
  debug
  loop
 
Last edited:

JanJor

Member
Thanks, Technical !

Dear Forum, dear Technical, thanks for your quick reply. I used the initialisation code as you suggested and that does the trick. For reading out the values of the camera, I used a somewhat different approach (your suggestion for reading did not work, but that will undoubtedly have to do with the strange output of the camera).
Anyway, the system works !!

Below, for those who might considring demolishing their Wii remote control and use the camera as a robot tracking system, I provide below my code that works (can ondoubtedly be made much, much better, but this is a mere code to prove that the camera indeed comes back with coordinates of an IR-led.

I've used Picaxes for years now, and this again shows: 1) if you can think of something, you can use the Picaxe to make it, and 2) the forum is great.

Thanks again.
Ronald


#no_data
setfreq m4

i2cslave 0xB0, i2cslow, i2cbyte
pause 500

pause 10

pause 500

writei2c 0x30, (0x01)
pause 100
writei2c 0x30, (0x08)
pause 100
writei2c 0x06, (0x90)
pause 100
writei2c 0x08, (0xC0)
pause 100
writei2c 0x1A, (0x40)
pause 100
writei2c 0x33, (0x33)
pause 100

beg:
do
readi2c (b0)
if b0 = 0 or b0 = 255 then aap
if b0 = 20 then ho
aap:
loop
ho:
sertxd (#b0," ")
if b0=0 then beg
 

Technical

Technical Support
Staff member
Your 'beg' section is flawed as you may fall out the bottom of 'ho'.
Looking at the spec you are only also reading byte 0, the lower 8 bits of the ten bit X result.

After a bit more reading this looks like better setup:

Code:
i2cslave 0xB0, i2cslow, i2cbyte
pause 500
 
 
writei2c 0x30, (0x01) ; camera on
pause 100
writei2c 0x30, (0x08)
pause 100
 
; now set sensitivity (data from [URL]http://wiibrew.org/wiki/Wiimote[/URL])
;00 01 02 03 04 05 06 07 08   1A 1B
;00 00 00 00 00 00 90 00 C0  40 00  Suggested by Marcan  
;00 00 00 00 00 00 90 00 41   40 00  Suggested by inio (max sensitivity)  
;02 00 00 71 01 00 64 00 fe   fd 05  Wii level 1  
;02 00 00 71 01 00 96 00 b4   b3 04  Wii level 2  
;02 00 00 71 01 00 aa 00 64   63 03  Wii level 3 (Suggested by Cliff)  
;02 00 00 71 01 00 c8 00 36   35 03  Wii level 4  
;07 00 00 71 01 00 72 00 20   1f 03  Wii level 5  
 
; Here we use 
;00 01 02 03 04 05 06 07 08   1A 1B
;00 00 00 00 00 00 90 00 C0  40 00  
 
; assuming power on reset is 0 anyway
writei2c 0x06, (0x90) ;sensitivity part 1
pause 100
writei2c 0x08, (0xC0) ;set sensitivity part 2
pause 100
writei2c 0x1A, (0x40) ;set sensitivity part 3
pause 100
 
; set the mode at address 0x33
; Basic  01
; Extended  03 
; Full  05
writei2c 0x33, (0x03) ;set the mode
pause 100
 
writei2c 0x30, (0x08)
pause 100
 
 
;Extended Mode 
;In Extended Mode, the IR Camera returns the same data as it does in Basic Mode,
; plus a rough size value for each object. The data is returned as 12 bytes, three bytes per object. Size has a range of 0-15. 
;
;This is the data format for each object: 
;
;   Bit  
;Byte  7  6  5  4  3  2  1  0  
;0  X<7:0>  
;1  Y<7:0>  
;2  Y<9:8>  X<9:8>  S<3:0>  
 
do
; read request
writei2c (0x37)
; read 8 bytes
readi2c (b1,b2,b3,b4,b5,b6,b7,b8)
; read last 4 bytes
readi2c (b9,b10,b11,b12)
 
loop
 

JanJor

Member
Camera working OK now !!

Dear Technical, thanks very much for your additional remarks in your E-mail of 24-1-2011.
It took some time and some further experimenting but the result is that the camera works perfect !!!
Below is the program that does the trick, including the right addresses (the most difficult part). And I finally dealt with a problem that you noticed: the final x- and y-coordinates are 10 bits long, and they are divided in some clever way over three bytes.
I now translate the three bytes into two words and sent them to the PC that's running a simple QBasic program that shows me on the screen (by a simple PSET (x,y) command) where the infrared diode (i.e.: the robot) is located.
Problems solved. Once more a thank you to the forum for the help.

For those interested in the hardware: see http://letsmakerobots.com/node/7752

Thanks, Ronald

Below is the software.

pause 1000
i2cslave 0xB0, i2cslow, i2cbyte
pause 500


writei2c 0x30, (0x01) ; camera on
pause 100
writei2c 0x30, (0x08)
pause 100
writei2c 0x06, (0x90) ;sensitivity part 1
pause 100
writei2c 0x08, (0xC0) ;set sensitivity part 2
pause 100
writei2c 0x1A, (0x40) ;set sensitivity part 3
pause 100
writei2c 0x33, (0x03) ;set the mode
pause 100
writei2c 0x30, (0x08)
pause 100


writ:

writei2c (54)

readi2c (b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12)

b0=b4
w10 = bit7*2
w10 = w10+bit6
w10=w10*255
w10=w10+b3

w11 = bit5*2
w11 = w11+bit4
w11=w11*255
w11=w11+b2

sertxd (" ",#w10," ",#w11," ",13,10)

pause 1500
goto writ
 
Top