Author Topic: red laser and I2C bus (done)  (Read 29845 times)

Offline Jojo

  • *
  • Posts: 9
  • Karma: +1/-1
    • View Profile
Reply #15 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.



Offline CaptainN

  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Reply #16 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 :-)



Offline Jojo

  • *
  • Posts: 9
  • Karma: +1/-1
    • View Profile
Reply #17 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)



Offline mobes

  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Reply #18 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



Offline Jojo

  • *
  • Posts: 9
  • Karma: +1/-1
    • View Profile
Reply #19 on: January 18, 2009, 07:48:48 AM



Offline salamat

  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Reply #20 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?



Offline Jojo

  • *
  • Posts: 9
  • Karma: +1/-1
    • View Profile
Reply #21 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



Offline salamat

  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Reply #22 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



Offline benpaddlejones

  • Support Admin
  • *
  • Posts: 1178
  • Karma: +49/-0
    • View Profile
    • Inter.Connect.Ed
Reply #23 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 :)


See my full profile and links on my Google Profile: http://www.google.com/profiles/benpaddlejones


Offline salamat

  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Reply #24 on: January 31, 2009, 05:24:40 AM
no sorry but i just removed the camera from an existing wiimote




Offline salamat

  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Reply #25 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 .. :)



Offline Jojo

  • *
  • Posts: 9
  • Karma: +1/-1
    • View Profile
Reply #26 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.



Offline salamat

  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Reply #27 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?