RagnarJensen / Z-CAM-E1-IO

Controlling the Z CAM E1 through its I/O port.
The Unlicense
17 stars 2 forks source link

Zoom via UART #3

Open titou420 opened 5 years ago

titou420 commented 5 years ago

Hi Ragnar, first of all thanks for all these documents you put online, Im building a remote controller for the Zcam and I probably wouldn’t have succeeded without your help. My problem is that I can’t change the value of the zoom via the UART. I try to send the command CAMERA_CONFIG_LENS_ZOOM, found on the official doc but it's doest work.. My program of test is of type :

byte zoom1[] = {0xea, 0x02, 0x04, 0x0e, 0x30, 0x01, 0x00};
byte zoom2[] = {0xea, 0x02, 0x04, 0x0e, 0x30, 0x01, 0x01};
byte zoom3[] = {0xea, 0x02, 0x04, 0x0e, 0x30, 0x01, 0x02};
byte zoom4[] = {0xea, 0x02, 0x04, 0x0e, 0x30, 0x01, 0x03};

if(!digitalRead(BT1))
    sendCommand(zoom1, sizeof(zoom1));
  if(!digitalRead(BT2))
    sendCommand(zoom2, sizeof(zoom2));
  if(!digitalRead(BT3))
    sendCommand(zoom3, sizeof(zoom3));
  if(!digitalRead(BT4))
    sendCommand(zoom4, sizeof(zoom4));

If by chance you have done a zoom function on your project, your help would be very interssant for me.

Cheers, titou420

RagnarJensen commented 5 years ago

I'm sorry to say that I haven't done any zoom stuff, simply because I don't have any lenses with electrical zoom.

But I'm curios... which lens are you using?

It would be interesting to see the camera's responses to your zoom commands. In my code there is a readResponse function that is meant to be called immediately after a sendCommand. The sketch in the RC_PWM folder shows particularly well how to use it.

Also of interest is the camera's response if you zoom the lens manually to a couple of different settings and then send a GET CAMERA_CONFIG_LENS_ZOOM. Maybe we can dig out som info from that.

Cheers, Ragnar

titou420 commented 5 years ago

Hi ! I hadn't thought to verify if my lens was able to electrical zoom ... I use " Olympus M. Zuiko Digital 14-42mm / F3.5-5.6 II (EZ-M1442) " with " VCL-0637 S Lens" strapped onto the front, and they are not controlable electrically ... But for your information I made a program to test like this :

/* the clearBuffer functiun is here to prevent of recovering the past 
byte that we did not recover previously. */
if(!digitalRead(BT2)) {
    Serial.println("Test : Zoom");
    clearBuffer();
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);
    Serial.println("ZOOM1");
    sendCommand(setZoom1, sizeof(setZoom1));
    responseLen = readResponse(responseBuf);
    delay(1000);
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);
    Serial.println("ZOOM2");
    sendCommand(setZoom2, sizeof(setZoom2));
    responseLen = readResponse(responseBuf);
    delay(1000);
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);
    Serial.println("ZOOM3");
    sendCommand(setZoom3, sizeof(setZoom3));
    responseLen = readResponse(responseBuf);
    delay(1000);
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);
    Serial.println("ZOOM4");
    sendCommand(setZoom4, sizeof(setZoom4));
    responseLen = readResponse(responseBuf);
    delay(1000);
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);
  }

And the serial console give :

Test : Zoom
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]
ZOOM1
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 5
[!] => Réponse de la caméra : [ 0xEA 0x2 0x2 0x8E 0xFF ]
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]
ZOOM2
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 5
[!] => Réponse de la caméra : [ 0xEA 0x2 0x2 0x8E 0xFF ]
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]
ZOOM3
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 5
[!] => Réponse de la caméra : [ 0xEA 0x2 0x2 0x8E 0xFF ]
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]
ZOOM4
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 5
[!] => Réponse de la caméra : [ 0xEA 0x2 0x2 0x8E 0xFF ]
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]

We can see that sending the setZoom command don't change anything... A second test is for zoom manually and watch the response of the camera when sending a getZoom command :

if(!digitalRead(BT2)) {
    Serial.println("Test : Zoom");
    clearBuffer();
    sendCommand(getZoom, sizeof(getZoom));
    responseLen = readResponse(responseBuf);
    delay(1000);    
  }

So I zoomed at the minimum and press the button 2, here is what the console give me :

Test : Zoom
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]

And after I zoom at the maximum and press button 2, console :


Test : Zoom
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 7
[!] => Réponse de la caméra : [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0 ]

...... Not any difference so I think it's because my lens is not compatible with this functiun?

RagnarJensen commented 5 years ago

If your lens is in fact a 14–42mm 1:3.5–5.6 EZ, then it should have Electronic Zoom. The 14-42mm 1:3.5-5.6 II and IIR are manual zoom.

I have done some tests with my manual zoom lenses and I get the same response as you do. There is no difference whatever the zoom is set to.

Button B1: get zoom
Send buffer
Waiting for camera response...
Response length: 7
Response: [ 0xEA 0x2 0x4 0x8F 0x0 0x1 0x0  ]

The response from your zoom commands return an error.

ZOOM1
[!] => Commande envoyée.
[!] => En attente de la réponse...
[!] => Taille de la réponse : 5
[!] => Réponse de la caméra : [ 0xEA 0x2 0x2 0x8E 0xFF ]

The FF in the last byte of the response indicates an error. It would be 0x00 if the camera had accepted the command. It's entirely possible that a compatible lens is required. But, I have nothing to test with... :sob: