Giter Site home page Giter Site logo

Enabling UART mode about z-camera-doc HOT 24 OPEN

imaginevision avatar imaginevision commented on August 29, 2024
Enabling UART mode

from z-camera-doc.

Comments (24)

RagnarJensen avatar RagnarJensen commented on August 29, 2024 2

I have it working on the bench, using a real 24C02B EEPROM at address 0x51.
EEPROMs larger than 16Kbit cannot be used, because they use 2 byte addressing.

When the camera starts up, the first transaction on the i2c bus my logic analyzer sees is this:
zcame1_bootup_uart
The camera reads the first byte from device 0x51, which returns the value 3.
Note that you don't get any visible reaction from the camera at this stage. It's not until you actually start to send it commands that it does something.

Then it enters a loop, continually reading from device 0x48, which is a temperature sensor inside the camera:
zcame1_0x48
The sensor responds with the temperature value encoded in 12 bits.

The terminal program on my PC has macro key functionality, which enables me to send the required binary strings to the camera.
E.g. to switch to stills mode, I send these four binary bytes (here in decimal); 234, 2, 1, 3
which is 0xea 0x02 0x01 0x03 when expressed in hexadecimal.

It looks like a rat's nest, but it works... πŸ˜ƒ
z_cam_e1_uart_control_www

e1_io_pinout_www2

Cheers,
Ragnar

from z-camera-doc.

garciaanto avatar garciaanto commented on August 29, 2024 2

Sure:

#include <Wire.h>

void setup() {
  Serial.begin (9600);
  Wire.begin(0x51);
  Wire.onRequest(requestEvent);
}

void loop() {
  // :DD
}

void requestEvent() {
  Wire.write(0x03);
  Serial.println (" envΓ­o un 0x3");
}

from z-camera-doc.

garciaanto avatar garciaanto commented on August 29, 2024 1

I totally forgot this post that I opened. I have it also working.
In my case I couldnt make it works with eeprom but I used an small arduino instead. And to be honest I do not respond to the temperature query :)

To test it I just used a simple vb .net program to test some functions and more or less was working.
Also, I upgraded the cam to the WEB latest on using the manual process (just drop the image on the root folder)

Good luck!

from z-camera-doc.

garciaanto avatar garciaanto commented on August 29, 2024 1

Not sure if I understand your question. If you ask regarding the connections:

CAM side Arduino side
GND GND
SDA SDA
SCL SCL

If you want, you can also power up the arduino with the cam (CAM VCOM to Arduino Vin)

from z-camera-doc.

RagnarJensen avatar RagnarJensen commented on August 29, 2024 1

Yes, it is possible to focus "manually" with UART commands. I put "manually" in quotes, because the camera must be in AF mode for it to work. EDIT: Later experiments show that the camera does react to focus commands when in MF mode.

I've been experimenting with some of the commands in "Z-Camera-Doc/expansion/expansion.md" and so far I've been able to

  • Switch back and forth between MF and AF.
  • Switch back and forth between Movie and Stills mode.
  • Take stills pictures.
  • Record movies.
  • Query the camera for the lens focus position.
  • Set the lens focus position.
  • Control the focus speed (how fast the lens changes to a new focus position)

In the screenshots from my logic analyzer below, Async 0 is the camera's RX line, i.e. commands from my computer to the camera. Async 1 is the camera's TX line, responses from the camera to my computer.

If I send this, which is the GET CAMERA_CONFIG_LENS_FOCUS_POSITION command,
image
the camera responds with
image
The four bytes highlighted in yellow hold the current lens position. In the pic above it's focused at infinity. When focused at its near limit, the camera's response on the query is
image
Note the change in the yellow framed bytes. I have only tested with one lens (Olympus 25mm/1.8) so far, but I suspect the position values for close focus and infinity might be different for other lenses.

Finally, by sending SET CAMERA_CONFIG_LENS_FOCUS_POSITION commands, it is possible to position the focus point anywhere between the end points.

Command to set focus to near limit - focus position in the four bytes framed in yellow:
image

Command to set focus to infinity:
image
Command to set focus somewhere in-between:
image

I'm still very much in exploratory mode. I feel that the documentation on the UART commands is somewhat lacking in details... 😜
So, I've been doing a lot of trying out things, testing and experimenting. But at least I now know the key press sequence to reset the camera to factory defaults by heart πŸ˜†

I'll be away for a while, but I'll try to do a little write-up and maybe some code example when I get back.

Cheers, Ragnar

from z-camera-doc.

skadiexe avatar skadiexe commented on August 29, 2024

0x51 is 0xA3 shifted 1 bit right. it is the same 7-bit adress.
1 or 0 in LSB means Read or Write while accessing eeprom

p.s. my camera do not have any activity on i2c overall, always logic 1 on SDA/SCL

from z-camera-doc.

CGFlyer85 avatar CGFlyer85 commented on August 29, 2024

@RagnarJensen , that wonderful ! Is there any way we can talk about all of this, and if possible if you can help me make it work my side, off course if you need something in compensation (wink, wink) I'm okay with that's.

from z-camera-doc.

skadiexe avatar skadiexe commented on August 29, 2024

@garciaanto could you show the sketch?

from z-camera-doc.

CGFlyer85 avatar CGFlyer85 commented on August 29, 2024

@garciaanto do you have a wiring Shem for the Arduino ?

from z-camera-doc.

CGFlyer85 avatar CGFlyer85 commented on August 29, 2024

@garciaanto, that's it. On your sketch, where do I need to put my code ? For example if I whant to focus forward or backwards ?

from z-camera-doc.

CGFlyer85 avatar CGFlyer85 commented on August 29, 2024

Is it even possible to do this ? Because that really one thing that I need, be able to manually focus thought the I/O port...

from z-camera-doc.

CGFlyer85 avatar CGFlyer85 commented on August 29, 2024

@garciaanto did you find a way to manually focus with it ? Don't seem to find the code to use...

from z-camera-doc.

garciaanto avatar garciaanto commented on August 29, 2024

@CGFlyer85 wait wait...
My code the only thing that do is to enable the cam in uart mode. I mean, the little sketch that I wrote its only to let the cam boot on UART mode.

Once the cam is in UART mode, you can send commands to TX RX. You can find all availables command in " Z-Camera-Doc/expansion/expansion.md"

You can do that with arduino, or with vb .net or any other app.

from z-camera-doc.

MechtEngineer avatar MechtEngineer commented on August 29, 2024

@garciaanto would you mind posting some simple example Arduino code using the commands from the Github "Z-Camera-Doc/expansion/expansion.md"? For example, changing from the default video mode to stills mode?

If I can connect to the Z-CAM via I2C without having to use an EEPROM, that would be amazing!

from z-camera-doc.

MechtEngineer avatar MechtEngineer commented on August 29, 2024

@RagnarJensen You have made some excellent progress in the area of manually focussing the camera via UART commands. Would you mind posting your order of commands from camera startup to manual focus at infinite? Even better (and perhaps more convenient for you), some code would be excellent for this procedure.

My plan was to do something like the following:

  1. Use CAMERA_CONFIG_FOCUS_METHOD (Command No. 22, Hex 0x16) to change the focus from Automatic Focus to Manual Focus
  2. Use CAMERA_CONFIG_MF_DRIVE (Command No. 33, Hex 0x21) to "set MF drive". I'm not sure what "set MF drive" actually means ("Set MF drive" is used as an example in the Github expansion.md file).
  3. Use CAMERA_CONFIG_LENS_FOCUS_POSITION (Command No. 52, Hex 0x34) to change the focus to infinite. I was hopping that infinite focus would be as simple as 0xFF, but from your post above, it seems like that is not the case.

from z-camera-doc.

MechtEngineer avatar MechtEngineer commented on August 29, 2024

@RagnarJensen I noticed that in your focus commands, the third byte is 0x07, whereas the UART documentation says the third byte in UART SET CONFIG commands should be 0x04. Is there any reason for you changing it to 0x07?

from z-camera-doc.

RagnarJensen avatar RagnarJensen commented on August 29, 2024

@MechtEngineer The third byte is the length of the command or the response. E.g. in the GET CAMERA_CONFIG_LENS_FOCUS_POSITION command it is 0x02 and in its response it is 0x13.

I have no idea what the set MF drive command is supposed to do. I've only looked at it briefly, but I think I saw the focus position in the responses. And in their example, the length byte of it seems to be wrong.

from z-camera-doc.

RagnarJensen avatar RagnarJensen commented on August 29, 2024

I have actually never written code for an Arduino before... 😳 This is my very first attempt ever, so go easy on me...

I have a couple of Teensy 2.0s left over from another project. I didn't write any code for them, other people did. I just integrated stuff.

The Teensy is a very close relative to the Arduino, it uses the ordinary Arduino IDE for coding stuff. So, I thought "how hard can it be?" Yes, famous last words, I know πŸ˜‰ It turned out not being too hard after all. I have managed to slap together a proof-of-concept sketch that actually does some things OK.

From the comments in the code:
"What this sketch can do:

  • Simulate an i2c EEPROM, to make the camera configure itself for UART mode.
  • At start-up, it waits for the camera to come alive.
  • At start-up, it sets the camera to Stills mode.
  • At start-up, it sets focus mode to AF.
  • At start-up, it focuses the lens to infinity.
  • Press button 0 to toggle between MF and AF.
  • Press button 1 to slew focus between infinity and closest focus. Press again to go in the other direction.
  • Press button 2 to focus farther away, in a step-wise fashion. There are five steps.
  • Press button 3 to focus closer, in the same steps as above.
  • Press button 7 to take a picture.
  • Blinks the on-board LED in different patterns, to show status."

The code so far is of the "ugly hack" variety. It's definitely not pretty, but it may serve as an example for how to do UART communications with an Arduino.

I have set up a repository where I will publish the results of my experiments. You can find the sketch there.
RagnarJensen/Z-CAM-E1-IO

test_setup
Bitscope oscilloscope/logic analyzer, breadboard, camera, batteries as focus targets and a CVBS monitor.
The grey, furry things on the camera are Rycote Micro Windjammers.

--
Ragnar

from z-camera-doc.

RagnarJensen avatar RagnarJensen commented on August 29, 2024

I've been messing around with my Arduino code and have now pushed a new sketch to my repo. It can do everything the earlier one did, but I've added analog input.

From the comments in the code:
"What this sketch can do:

  • Take analog input (e.g. from a potentiometer) and focus the lens based on the analog value."

focus_control_by_analog_input
When I move the slider, the lens focus follows. It actually works pretty well πŸ˜ƒ

The code is still ugly as sin. I'll clean it up later. Maybe... πŸ˜€

Cheers, Ragnar

from z-camera-doc.

MechtEngineer avatar MechtEngineer commented on August 29, 2024

@RagnarJensen Wow! This is absolutely magnificent! Thanks for all of your effort in posting your code and circuit. Outstanding stuff. I salute you!

from z-camera-doc.

RagnarJensen avatar RagnarJensen commented on August 29, 2024

Using flash with the E1. That's the reason I got interested in the I/O port, the API and UART control in the first place.

I've been mucking about with my Arduino code and I've added a resistor and a transistor to the breadboard. I can now trigger a flash from the controller. There are limitations, though. The electronic shutter's slow read-out speed and delays of varying duration in the camera make for some interesting challenges.

Head over to my repo for more info.

first_flash_pic_with_zcam_e1
This is my very first successful picture taken with the Z CAM E1, using electronic flash as illumination.

@Chenel000 Thanks for the postcard πŸ˜„

from z-camera-doc.

Chenel000 avatar Chenel000 commented on August 29, 2024

Nice you like it @ @RagnarJensen

from z-camera-doc.

Chenel000 avatar Chenel000 commented on August 29, 2024

Currently I am working on building my drone where I expect to fly the Z E1 cam and use the connectors you send me, and really I miss to have time now to work on the programming side to configure and manage the camera. I expect soon to be able to join the team to work on this but first I need to finish with the flying platform.
My congratulations for job you are doing.

from z-camera-doc.

gius19 avatar gius19 commented on August 29, 2024

Hi,
I found these resources on Z cam E1 looking in internet for help.
I am interested in this camera for setting up a group of 4 cams to take pictures at the same time and then to stitch in pano pictures.
I will use manual fisheye lenses, no need to focus. Before buying I would need to to know if this cam may comply some requisites.

  1. I have a sony camera and for this purpose I use the function "enable picture without lens": is it possible to do the same with Zcam E1?
  2. Is it possible to set "aperture priority" and set a maximum limit in exposure time (e.g. not more than 1/1000s)?
  3. I would like to connect all the cams (via usb or other ports, connecting cables) to take a picture simultaneously. Is there a port for wired shutter release?

Thank you in advance for any hints and help.

Giuseppe

from z-camera-doc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.