Close

I2C on OPT8241

A project log for 3D-ToF scanner

Project uses OPT8241 3D-ToF sensor, CycloneV FPGA with HPS and Linux OS

ianislav-trendafilovIanislav Trendafilov 08/24/2016 at 23:410 Comments

I have connected the opt8241 sensor over I2C. I have disabled sensor clock by setting MCLCK to 0. Power consumption of adapter board is ~1.8 mA. Then I have sent the i2c commands. Command output :

 # i2cdetect 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- 58 -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

 # i2cdump 2 0x58
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2, address 0x58, mode byte
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9a    ...............?
10: 88 10 00 00 00 00 00 00 00 00 01 00 00 00 00 00    ??........?.....
20: 00 9f 20 00 00 00 00 00 00 80 00 00 00 00 00 00    .? ......?......
30: 00 d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00    .?..............
40: 00 00 00 00 0e 00 00 00 00 00 00 00 00 01 00 00    ....?........?..
50: 00 00 00 00 00 80 00 00 00 00 00 01 00 00 06 f0    .....?.....?..??
60: 10 54 f4 4c 00 00 00 00 00 00 00 00 44 00 00 00    ?T?L........D...
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
80: 00 80 a0 44 00 00 00 08 01 09 01 09 a1 00 53 08    .??D...??????.S?
90: 00 00 08 00 00 00 03 d0 00 00 81 00 00 03 f0 00    ..?...??..?..??.
a0: 00 81 00 00 00 00 00 00 00 d2 52 00 00 81 d2 52    .?.......?R..??R
b0: 00 00 81 00 00 00 00 00 00 00 00 00 00 00 00 00    ..?.............
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
d0: 00 53 5b 00 00 81 01 00 00 00 00 00 00 00 00 00    .S[..??.........
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

As you can see, sensor has I2C address of 0x58. I have tried warming the sensor thus increasing temperature. Output from i2cdump has not changed.

Next I have tried write operations. Script I am using is:

for i in `seq 0 255`
do
     address=$(printf "0x%.2x" $i);
     i2cset 2 0x58 $address 0x7f;
done;
It requires user input, to execute commands, which is good for step-by-step interaction. If you wish to overwrite full memory, you have to add "-y" argument to i2cset command.

First I have tried writing 0x0A. To simplify output I am showing output only when I write a full row (like 0x00 to 0x0F, then 0x10 to 0x1F and so on). Writing on row 0x40 have changed output on row 0x20. I should investigate this in the future. Power consumption on all logic have remain 1.8mA.

      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
-00: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9a    ?..............?
+00: 0a 0a 0a 00 00 00 00 00 0a 00 0a 0a 0a 0a 0a 0a    ???.....?.??????

-10: 88 10 00 00 00 00 00 00 00 00 01 00 00 00 00 00    ??........?.....
+10: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0b 0a 0a 0a 00 0a    ??????????????.?

-20: 00 9f 20 00 00 00 00 00 00 80 00 00 00 00 00 00    .? ......?......
+20: 0a 0a 0a 00 0a 0a 0a 0a 02 8a 0a 0a 0a 0a 0a 0a    ???.????????????

-30: 00 d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00    .?..............
+30: 0a d0 0a 0a 0a 0a 0a 00 0a 0a 0a 00 00 00 00 00    ???????.???.....

-20: 0a 0a 0a 00 0a 0a 0a 0a 02 8a 0a 0a 0a 0a 0a 0a    ???.????????????
+20: 0a 0a 0a 00 0a 0a 0a 0a 02 0a 0a 0a 0a 0a 0a 0a    ???.????????????
 30: 0a d0 0a 0a 0a 0a 0a 00 0a 0a 0a 00 00 00 00 00    ???????.???.....
-40: 00 00 00 00 0e 00 00 00 00 00 00 00 00 01 00 00    ....?........?..
+40: 0a 0a 0a 00 0e 00 00 00 00 00 00 00 00 0b 00 00    ???.?........?..
 
-50: 00 00 00 00 00 80 00 00 00 00 00 01 00 00 06 f0    .....?.....?..??
+50: 00 00 00 00 00 80 00 00 00 00 00 01 0a 0a 0a 0a    .....?.....?????

-60: 10 54 f4 4c 00 00 00 00 00 00 00 00 44 00 00 00    ?T?L........D...
+60: 0a 0a 0a 0a 0a 0a 0a 0a 00 0a 0a 0a 0a 0a 0a 0a    ????????.???????

-70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
+70: 0a 0a 0a 0a 0a 00 00 00 00 00 00 00 00 00 00 00    ?????...........

-80: 00 80 a0 44 00 00 00 08 01 09 01 09 a1 00 53 08    .??D...??????.S?
+80: 0b 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????

-90: 00 00 08 00 00 00 03 d0 00 00 81 00 00 03 f0 00    ..?...??..?..??.
+90: 0a 0a 0a 0a 00 00 0a 0a 0a 0a 0a 00 00 0a 0a 0a    ????..?????..???

-a0: 00 81 00 00 00 00 00 00 00 d2 52 00 00 81 d2 52    .?.......?R..??R
+a0: 0a 0a 00 00 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ??..????????????

-b0: 00 00 81 00 00 00 00 00 00 00 00 00 00 00 00 00    ..?.............
+b0: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????

-c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
+c0: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????

-d0: 00 53 5b 00 00 81 01 00 00 00 00 00 00 00 00 00    .S[..??.........
+d0: 0a 0a 0a 0a 0a 0a 0a 00 00 00 00 00 00 00 00 00    ???????.........

After that I wrote 7F to all addresses. Power consumption is now 47mA

      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
-00: 0a 0a 0a 00 00 00 00 00 0a 00 0a 0a 0a 0a 0a 0a    ???.....?.??????
-10: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0b 0a 0a 0a 00 0a    ??????????????.?
-20: 0a 0a 0a 00 0a 0a 0a 0a 02 0a 0a 0a 0a 0a 0a 0a    ???.????????????
-30: 0a d0 0a 0a 0a 0a 0a 00 0a 0a 0a 00 00 00 00 00    ???????.???.....
-40: 0a 0a 0a 00 0e 00 00 00 00 00 00 00 00 0b 00 00    ???.?........?..
-50: 00 00 00 00 00 80 00 00 00 00 00 01 0a 0a 0a 0a    .....?.....?????
-60: 0a 0a 0a 0a 0a 0a 0a 0a 00 0a 0a 0a 0a 0a 0a 0a    ????????.???????
-70: 0a 0a 0a 0a 0a 00 00 00 00 00 00 00 00 00 00 00    ?????...........
-80: 0b 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????
-90: 0a 0a 0a 0a 00 00 0a 0a 0a 0a 0a 00 00 0a 0a 0a    ????..?????..???
-a0: 0a 0a 00 00 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ??..????????????
-b0: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????
-c0: 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a    ????????????????
-d0: 0a 0a 0a 0a 0a 0a 0a 00 00 00 00 00 00 00 00 00    ???????.........
+00: 00 7f 7f 00 00 00 00 00 7f 00 7f 7f 7f 7f 7f 7f    .??.....?.??????
+10: 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 00 7f    ??????????????.?
+20: 7f 7f 7f 00 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f    ???.????????????
+30: 7f d0 0f 7f 7f 7f 7f 00 7f 7f 7f 00 00 00 00 00    ???????.???.....
+40: 7f 7f 7f 00 7f 7f 7f 7f 7f 7f 7f 7f 1f 7f 00 00    ???.??????????..
+50: 00 00 00 00 00 80 00 00 00 00 00 01 7f 00 06 f0    .....?.....??.??
+60: 10 54 f4 4c 00 00 00 00 00 00 00 00 44 00 00 00    ?T?L........D...
+70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
+80: 00 80 a0 44 00 00 00 08 01 09 01 09 a1 00 53 08    .??D...??????.S?
+90: 00 00 08 00 00 00 03 d0 00 00 81 00 00 03 f0 00    ..?...??..?..??.
+a0: 00 81 00 00 00 00 00 00 00 d2 52 00 00 81 d2 52    .?.......?R..??R
+b0: 00 00 81 00 00 00 00 00 00 00 00 00 00 00 00 00    ..?.............
+c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
+d0: 00 53 5b 00 00 81 01 00 00 00 00 00 00 00 00 00    .S[..??.........
 e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
 f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

I have then executed the 7F write, one address on a time and found power consumption increases when writing to address 0x08. I then tried writing single bit values at a time (0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80). Power consumption changes only when writing 0x04. To test that I have wrote !(0x04)=0xFB. There was a bit of power increase (suggesting some logic is wired. I have found that this is value 0x80. To test that I have write value !(0x80&0x04)=0x7B . (My multimeter is 22000 count and has microAmp range. All power consumption values are rounded for representation purposes)

i2cset -y 2 0x58 0x08 0x00 # Power consumption is 1.8mA
i2cset -y 2 0x58 0x08 0xfb # Power consumption is 1.9mA
i2cset -y 2 0x58 0x08 0x04 # Power consumption is 42mA
i2cset -y 2 0x58 0x08 0x80 # Power consumption is 1.9mA
i2cset -y 2 0x58 0x08 0x7b # Power consumption is 1.8mA


At the end - it seems that writing 0x04 to address 0x08 on device 0x58 is enabling opt8241 logic. To verify that I will have to write the FPGA data acquisition logic IP next weeks.

Discussions