Wiimote Project

General Wiimote and Technology => General Hardware Talk => Topic started by: sha on March 12, 2008, 09:19:33 AM

Title: red laser and I2C bus (done)
Post by: sha on March 12, 2008, 09:19:33 AM
http://www.youtube.com/watch?v=WsvK7Euwa-I
http://www.youtube.com/watch?v=ssMlodh2n4U
Title: Re: red laser and I2C bus (done)
Post by: Iceman1979 on March 12, 2008, 10:58:26 AM
What logic is in your micro controller? ie... what is it reading frome the camera, what kind of data are you getting from the camera? Is this micro controller communicating to the pc via the serial bus?

thanks
John
Title: Re: red laser and I2C bus (done)
Post by: sha on March 12, 2008, 02:42:48 PM
>What logic is in your micro controller? ie... what is it reading frome the >camera, what kind of data are you getting from the camera? Is this micro >controller communicating to the pc via the serial bus?

Hmm, microcontroller reads several bytes directly from camera using standard I2C bus. These bytes contain an inforamtion about coordinates and brightness of spots. What to do with this depends on project, here I just sending them to PC for demonstration via RS232.
Title: Re: red laser and I2C bus (done)
Post by: ZaPPZion on March 12, 2008, 05:10:02 PM
wow that's certainly amazing!
What kind of microcontroller did you use btw?
I think this is really some inventive stuff. The 200Hz frequency is quite a lot.
I've just had the I2C subject @ school, so i know what it takes. Didnt expect the camera to be accessed this easily :)
Great project!
Title: Re: red laser and I2C bus (done)
Post by: Iceman1979 on March 12, 2008, 07:50:12 PM
Quote
Didnt expect the camera to be accessed this easily

Me either... wow that is to cool. Makes me want to break out my micro controller and play with it :)
Title: Re: red laser and I2C bus (done)
Post by: inio on March 13, 2008, 02:52:00 PM
Did you build an I2C sniffer to RE the control signals?

Are you planning on documenting the I2C frames used to work with the camera?
Title: Re: red laser and I2C bus (done)
Post by: cptkoolbeenz on March 27, 2008, 11:23:05 PM
Do you have any more info/sample code for this hack?  I would really appreciate any insight, as I was about to use an I2C sniffer and do the same thing myself...
Title: Pixart IR Sensor I2C
Post by: Jojo on March 30, 2008, 02:16:26 PM
Here’s how I get this to work:
Remove Pixart sensor from wiimote.
The sensor needs a 25 MHz clock signal here’s a circuit and pinout:
http://www.kako.com/neta/2007-001/2007-001.html
Connect the Sensor to your MC (don’t forget the pullups)
The slave address is 0xB0.
Initialise like here
http://www.kako.com/neta/2006-019/wii_ir_test2_src.zip
http://www.kako.com/neta/2006-019/2006-019.html
Now send 0x38
Capture 8 Bytes from slave
Capture 4 Bytes from slave
(I’ve seen this by sniffing the Bus)
I’m not sure about how to interpret the data(Haven’t even tried this yet, maybe it’s like the basic report?)

Some tips:
Kako.com is Japanese I’ve used babelfish to translate to English http://babelfish.altavista.com/
You can connect the sensor to the extension port and use the wiimote as usual. (With 25MHz Clock extern)
If you have problems with desoldering the sensor you can carefully break the case of the sensor. There is a second SMD case around the cam. I’m not responsible on any damages!

Please share your experience with the community.
If somebody knows how to remove the IR filter please post it here!
Does somebody know if the sensor can be used with 5V?
Title: Re: red laser and I2C bus (done)
Post by: cptkoolbeenz on March 31, 2008, 08:15:12 PM
Very cool...  I am getting an I2C sniffer this week.  I will do my best to translate the websites to english - I know someone that can do it.

I will post any findings...

In the meantime, if anyone else has more info, please post!
Title: Re: red laser and I2C bus (done)
Post by: Jojo on April 01, 2008, 03:23:52 PM
http://picasaweb.google.com/7222428/Wiimote
Title: Re: red laser and I2C bus (done)
Post by: Antonio on April 04, 2008, 10:30:13 PM
Could this work with an Arduino Board?
Title: Re: red laser and I2C bus (done)
Post by: CaptainN on April 08, 2008, 04:46:09 AM
I still didn't get it work properly with my I2C / USB interface (Devantec). I'll try to initialize the IR sensor like in the routine Wii_IR_init(). Afterwards I send the suggested 0x38, so I'm not sure to which internal address?! I tried 0x00 and 0x30 but nothing works. If I request afterwards 8 bytes of data I get nothing back. Maybe there is a specific address again to read from? Any comments would be welcome!
Title: Re: red laser and I2C bus (done)
Post by: Jojo on April 08, 2008, 10:48:37 AM
Do you a get a ACK from 0xB0?
Title: Re: red laser and I2C bus (done)
Post by: Jojo on April 08, 2008, 11:42:05 AM
0xB0 is the slave address of the device. 0x38 the register or internal address to Read the IR Values from.

Sample Code:

#define TARGET_ADDR 0xB0
//[...]
//initialize
//[...]
u08 rxdata[14];
u08 buf[2];
buf[0]=0x38;
i2cMasterSend(TARGET_ADDR, 1, buf);//send 0x38 to slave 0xB0
i2cMasterReceive(TARGET_ADDR, 8, rxdata);//get 8 data Bytes from 0xB0
rxdata[8]=0;// null-terminate received string
rprintfStr(rxdata);
i2cMasterReceive(TARGET_ADDR, 4, rxdata);//get another 4 data Bytes from 0xB0
rxdata[4] = 0;// null-terminate received string
rprintfStr(rxdata);
Title: Re: red laser and I2C bus (done)
Post by: CaptainN on April 10, 2008, 04:13:18 AM
Thanks for the sample code. I start to get some values but they seem to be too random to correspond actually to the medium report 0x33 output format. (Tested with different positions of the led bar). Maybe the initialization is still wrong. Is the camera sending a specific ACK signal I could check?
My Devantec I2C board just gives me a SUCCESS (1) on sending data but of course I don't look for a specific response from the IR sensor.
Furthermore I write the data to the camera using I2C write for devices with 1 byte register, so the first init line looks like this:

(Interface I2C CMD, 1 Byte REG), (I2C Device Addr), (Device Internal REG), (Byte count), (Data)

0x55, 0x0B, 0x30, 0x01, 0x01

The original code was like:

buf[0] = 0x30; buf[1]=0x01;
Report_0x16...(0xB0, 2, buf);
usleep(delay);

Is there still a mistake in the initalization? Should I look for a camera response (which) after init? Is the IR sensor a device with a 1 byte register or should I send everything just to 0xB0?

If I connect the custom build board with SCL / SDA external to the Wii the IR sensor is just working fine...

Thanks!

Title: Re: red laser and I2C bus (done)
Post by: Jojo on April 13, 2008, 11:38:11 AM
Here the initialization code i've used:

void initWiiCam(void)
{
 u08 buf[16];
 u08 p0,p1,p2,p3;
// Setup IR Sensivity
// p0=0x72; p1=0x20; p2=0x1F; p3=0x03; // Sensitivity 1
   p0=0xC8; p1=0x36; p2=0x35; p3=0x03; // 2
// p0=0xAA; p1=0x64; p2=0x63; p3=0x03; // 3
// p0=0x96; p1=0xB4; p2=0xB3; p3=0x04; // 4
// p0=0x96; p1=0xFE; p3=0xFE; p3=0x05; // 5
   buf[0]=0x30; buf[1]=0x01; // ??
   i2cMasterSend(TARGET_ADDR, 2, buf);//if (== I2C_ERROR_NODEV)
   buf[0]=0x00; buf[1]=0x02; buf[2]=0x00; buf[3]=0x00; buf[4]=0x71; buf[5]=0x01; buf[6]=0x00; buf[7]=p0;
   i2cMasterSend(TARGET_ADDR, 8, buf);
   timerPause(100);
   buf[0]=0x07; buf[1]=0x00; buf[2]=p1;
   i2cMasterSend(TARGET_ADDR, 3, buf);
   timerPause(100);
   buf[0]=0x1A; buf[1]=p2; buf[2]=p3;
   i2cMasterSend(TARGET_ADDR, 3, buf);
   timerPause(100);
   buf[0]=0x33; buf[1]=0x03;
   i2cMasterSend(TARGET_ADDR, 2, buf);
   timerPause(100);
   buf[0]=0x30; buf[1]=0x08; // ??
   i2cMasterSend(TARGET_ADDR, 2, buf);
}

If you have to work with Slave Registers try to use buf[0] as Register Address and buf[1]... as Data Bytes.(I think you have done this already)
did you wait a view ms between the initialization steps?

If there is no point recognized by the cam all 12 Bytes received are 0xFF. If there's a Point the first 3 Bytes change.
Without initialization i get random values too. I think this results from a much to high sensitivity. I try to find some time next week to check out the data format.
Title: Re: red laser and I2C bus (done)
Post by: CaptainN on April 14, 2008, 07:09:44 AM
Thanks a lot for your help!

Finally I found the problem! I used always 0xB0 as device address but my I2C controller needs the 7 bit address and
automatically shifts it. So by using 0x58 instead of 0xB0 everything works as expected.

Hopefully this will prevent somebody else investing several days of work trying to figure out the error :-)
Title: Re: red laser and I2C bus (done)
Post by: Jojo on August 01, 2008, 07:47:28 PM
http://www.kako.com/neta/2008-009/2008-009.html
I2C communication with Pixart IR Sensor + Sourcecode(arduino)
Title: Re: red laser and I2C bus (done)
Post by: mobes on August 08, 2008, 10:26:25 AM
If you look at the schematic on the kako.com website for wiring the 25mhz crystal, there are two crystal capacitors as well as a 0.1uF capacitor. However, if you look closely at the photo of the soldered board, you can see the two crystal caps as well as another two blue caps. I am wondering what the purpose of the second blue cap is since it is not accounted for in the schematic? Does anyone know if it was left out of the schematic or if it is even necessary?

mobes
Title: Re: red laser and I2C bus (done)
Post by: Jojo on January 18, 2009, 07:48:48 AM
I have just found a german link: http://www.cczwei-forum.de/cc2/thread.php?threadid=1793
http://procrastineering.blogspot.com/2008/09/working-with-pixart-camera-directly.html
and a Blog entry from Johnny Chung Lee
Title: Re: red laser and I2C bus (done)
Post by: salamat on January 22, 2009, 05:07:20 PM
i'm trying to do this using PIC18f4550 could anyone help me i'm a bit confused in the i2c and initialization of the pixart camera.

johnny lee also used the same PIC but i'm using  a 40 pin instead of 44 pin PIC.

the 1st step is to initialize the camera right? but how??? via I2C?
Title: Re: red laser and I2C bus (done)
Post by: Jojo on January 23, 2009, 04:36:47 PM
To get started with PIC18f4550 I would recomend
to download MPLAB
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469
and MPLAB C Compiler for PIC18 v3.22 - Student Edition
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014
MCHPFSUSB v2.2 USB Framework - (Drivers and Demo Apps)
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en021940
Maybe read this for a quick start with PIC18f4550
http://eegeek.net/content/view/13/32/
Now you can use the template from eegeek(or rewrite it yourself) and implement IC
(for example use OpenI2C;EEByteWrite;EESequentialRead from C18 Lib(included in C18 Compiler))
http://ww1.microchip.com/downloads/en/devicedoc/C18_Lib_51297d.pdf
After this just port the initialisation... from the kako.com arduino sample code mentioned further in this thread.

good luck
Jojo
Title: Re: red laser and I2C bus (done)
Post by: salamat on January 29, 2009, 08:16:11 PM
thanks jojo


 we had successfully loaded our PIC18f4550 with the bootloader and we would be continuing our experiment with the pixart camera

i would post my progress or queries here.

thanks again



here's a picture of our pixart camera
(http://img136.imageshack.us/img136/5224/picture057nk4.th.jpg) (http://img136.imageshack.us/my.php?image=picture057nk4.jpg)
Title: Re: red laser and I2C bus (done)
Post by: benpaddlejones on January 29, 2009, 09:15:49 PM
salamat
Have you found a source to purchase just the camera?

If you have please post here for others.

benpaddlejones :)
Title: Re: red laser and I2C bus (done)
Post by: salamat on January 31, 2009, 05:24:40 AM
no sorry but i just removed the camera from an existing wiimote

Title: Re: red laser and I2C bus (done)
Post by: salamat on January 31, 2009, 08:38:51 AM
hey another problem here

can anyone clarify to me if your connecting the pic (micro controller)  to the camera via i2c would the voltage in the i2c affect the communication?

because in kako's intefacing using arduino kako used a I2C voltage conversion circuit using LTC4301L while in JCL's blog he just said to give the camera 3.3 volts and directly connect it to the SDA and SLA lines + the pull up resistors.

or to simplify my question is the camera 5volts tolerant?

thanks .. :)
Title: Re: red laser and I2C bus (done)
Post by: Jojo on February 01, 2009, 05:26:24 AM
Because there's no datasheet I think knowbody can answer that question.
But PIC18F4550 has 3,3 V tolerant inputs. So if you use 3,3V regulator for cam VDD just connect the sda + scl pullups to 3,3V (instead 5V) and it should work without voltage conversion circuit.
Title: Re: red laser and I2C bus (done)
Post by: salamat on February 07, 2009, 07:23:50 PM
hey were starting to connect the pic and the microcontroller to the pc the problem now is programming the pic. since most of you guys used arduino Micro's the initialization codes we would be using is different from your coding right?

JCL posted a sample initialization code in his blog but we think he left some parts out cause we suspect there are some missing lines.

anyone here knows PIC programming?