Lens serial communication

Wifi, USB, GPS, Grips, Mics, Ext Power, Lens, Flash

Re: Lens serial communication

Postby leegong » Tue Aug 12, 2014 7:36 pm

@astrocow ,
In D5100 , the first byte is enum{0x6 , 0xE} ,
how about try 0x2 - 0xF for CMD_0xE0 ?
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

Re: Lens serial communication

Postby astrocow » Tue Aug 12, 2014 9:04 pm

0x02,04,06,08,0A,0C,0E: relative
0x03,05,07,09,0B,0D,0F: absolute
I couldn't find anything else affected by the byte value.

For the AF stepping, the 4th (last) byte for CMD_0xE0 ranges from 00 to 3E (62 steps).
I've been able to control the focus distance using a trimpot connected to the Arduino, reading the voltage off it, and converting it into a number between 00 and 3E. This gives me the full range of focal distances for my lens, but the step increment has a pretty poor resolution, i.e. a value changing by 1 would move the focus by a relatively large amount, compared to smoothly adjusting the focus by hand.

*Edit 1: going over the maximum distance ( >0x3E, or some value, I'm guessing 0x20 when the focal distance switch is set to Infinity-0.5m) causes CMD_0x3E to fail. It starts working immediately after I have manually shifted the focus back to before the limits.

*Edit 2: I have found that sometimes, CMD_0xE0 does not move the focus to the right position; but calling CMD_0x28 will cause the lens to shuffle towards the right spot, sometimes taking multiple calls of CMD_0x28. I've added CMD_0xEC 80 50 07 (move to closest focus, then infinity) to the init sequence of my program and it seems to have helped a lot. My program sequence now consists of sending CMD_0x28, followed by CMD_0xEC, before entering the trimpot analog reading loop.

I still don't know what the 2nd and 3rd bytes do.
astrocow
 
Posts: 11
Joined: Mon Aug 04, 2014 6:54 pm
Been thanked: 4 times

Re: Lens serial communication

Postby leegong » Wed Aug 13, 2014 1:48 am

astrocow wrote:0x02,04,06,08,0A,0C,0E: relative
0x03,05,07,09,0B,0D,0F: absolute
I couldn't find anything else affected by the byte value.

Good findings !
astrocow wrote:I still don't know what the 2nd and 3rd bytes do.

PLease take a look at this post :
viewtopic.php?f=8&t=1437&start=150#p9465
The 2nd byte is always 0x00 in D5100 .
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

Re: Lens serial communication

Postby astrocow » Wed Aug 13, 2014 11:39 pm

I've ran CMD_0xE0 01 XX XX 00 for various values of XX and I've not been able to detect any difference. However, the range of the last byte seems to depend on which position the lens was stopped in before losing power.
For example, I can put the lens on my camera, adjust focus to somewhere in the middle, power the camera off, then connect the lens to my Arduino. CMD_0xE0 XX XX 00 would move the lens to the midpoint, and reduce its effective range accordingly, so sending a CMD_0xE0 XX XX 30~ would move the lens to its closest focus.

I don't know if there is a command to reset the 'zero position' for lenses, but I've noticed the first two bytes returned from CMD_0x28 (I don't know about the other bytes, didn't check them) are different, depending on where I've managed to set the zero position for the lens. I'll investigate this once I get more time, probably next week.
astrocow
 
Posts: 11
Joined: Mon Aug 04, 2014 6:54 pm
Been thanked: 4 times

Re: Lens serial communication

Postby leegong » Fri Aug 15, 2014 3:15 am

@astrocow ,
In order to verify how the last two bytes for CMD_0xE0 represent focus amount ,
could you please send CMD_0xE0 with different focus amount , then send out CMD_0x28
and check CMD_0x28.response.field0xA , field0xD :
Lens_CMD_0x28.response.field0xA = FocusPosition
Lens_CMD_0x28.response.field0xD = Distance Info ; distance information : d [m] = 2^( (x-80)/6)
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

Re: Lens serial communication

Postby leegong » Sun Aug 17, 2014 7:22 am

Lens_CMD 0xC3 is not supported in D5100 , but it is supported in D800 ,
i think that Lens_CMD 0xC3 is similar to CMD 0xC5 ,because CMD 0xC3
and CMD 0xC5 share the same bit flag which is used to request
sending lens CMD in D800 FirmWare A .
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

Re: Lens serial communication

Postby john_zhou » Sun Aug 17, 2014 4:30 pm

leegong wrote:Lens_CMD 0xC3 is not supported in D5100 , but it is supported in D800 ,
i think that Lens_CMD 0xC3 is similar to CMD 0xC5 ,because CMD 0xC3
and CMD 0xC5 share the same bit flag which is used to request
sending lens CMD in D800 FirmWare A .


I have captured data with same lens on diffrent camera body, so yes, 0xC5 is a evolved version of 0xC3.
0xC3 have 6 bytes response from lens, and 0xC5 has 8. 0xC5 added 2 extra bytes at position 0 and 1, others are same.
john_zhou
 
Posts: 3
Joined: Sun Jun 22, 2014 7:26 pm
Been thanked: 2 times

Re: Lens serial communication

Postby leegong » Thu Aug 21, 2014 1:52 am

Lens CMD_0x28 response.field0x4 and field0x5 look like KD1 and KD2
respectively (no direct evidence yet , just guess) , which are stated in patent US4896181 .
However i begin to understand why CMD_0x28 is necessary for focusing commands
such as 0xE0 , because TMP19 has to get the current KD for AF driving amount calculating .
Attachments
KDparameter.jpg
KDparameter.jpg (70.53 KiB) Viewed 5016 times
KD.jpg
KD.jpg (143.16 KiB) Viewed 5016 times
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

Re: Lens serial communication

Postby astrocow » Thu Aug 21, 2014 4:38 pm

Sorry I took so long, had a different project due. I've attached a csv file of the returned values of CMD_0x28 after stepping the focus distance by 0x01 every 500ms, starting from infinity.
Attachments
lensinfodump.csv
Set lens to move by 1 step every 500ms (CMD_0xE0 00 FF 00 01), then send CMD_0x28 and log the response
(28.56 KiB) Downloaded 228 times
astrocow
 
Posts: 11
Joined: Mon Aug 04, 2014 6:54 pm
Been thanked: 4 times

Re: Lens serial communication

Postby leegong » Fri Aug 22, 2014 7:36 pm

After i read astroncow's CSV , then read related codes again and again ,
just realized lens CMD 0x26 .response (8bytes) are indeed 4 groups of
possible KD1 and KD2 :
lens CMD 0x26 .response.field00 , field01 == lens CMD 0x28 .response.field02 , field03
lens CMD 0x26 .response.field02 , field03 == lens CMD 0x28 .response.field04 , field05
lens CMD 0x26 .response.field04 , field05 == lens CMD 0x28 .response.field1C , field1D
lens CMD 0x26 .response.field06 , field07 == lens CMD 0x28 .response.field0x24 , field0x25
i'm sure each group is in the similar form as that of KD1 , KD2 stated in patent US4896181 ,
these lens data above are referenced widly in AF task0xA , especially when calculate input
for lens focusing CMDs , an eaxmple is shown in the following pic ,
but i admit that the progress of AF is still a mess to me .
Attachments
exponent.png
leegong
Core Developer
 
Posts: 2143
Joined: Mon Mar 19, 2012 12:21 am
Location: Hangzhou , China
Been thanked: 553 times

PreviousNext

Return to External Hacks

Who is online

Users browsing this forum: No registered users and 1 guest

cron