ArduCAM PTZ: FocuserAutoFocus.py won't focus, colors wrong, need range/step values

Hi all, I’m working with the PTZ-Camera-Controller (running the Python scripts on the controller, Focuser.py / FocuserAutoFocus.py / FocuserExample.py).

Good news: FocuserAutoFocus.py no longer bugs out, so the crash seems to be gone. Bad news: I still haven’t managed to actually get it focusing.

I also have a color problem — the colors in the captured image aren’t the true ones. The table shows up brown instead of blue, and the texts look black and red instead of black and blue. Any idea what’s going on there?

And one more thing: what are the good values to set for the focus zone range and the step size? I’m not sure I have sensible numbers in there.

Thanks!

Hi, thanks for posting and sorry for the slow reply — the engineer handling this was out of office due to COVID-19.

Let’s take the two things separately:

  1. Focus/zoom range and step size — can you paste the current values you have in Focuser.py? In particular the OPT_ZOOM and OPT_FOCUS blocks.

  2. The wrong colors — that’s often tied to the IR-cut state rather than the sensor itself. If the IR-cut filter isn’t open when it should be, you’ll get exactly the kind of color shift you’re describing.

Also, which version of the code are you on right now? Have you reloaded the latest commit?

Thanks for getting back to me. I reloaded the codes and I also tested the IR cut — that part seems OK.

For reference I used the IR-cut setting as: 0 → closed | 1 → open. I set it so it should be open.

I also found this commit while digging around, seems related to the focus zone range/step values:

On the focus side, I had to modify the range and step size of the focus zone in Focuser.py myself. Current settings are:

OPT_ZOOM : {
    "REG_ADDR" : 0x01,
    "MIN_VALUE": 0,
    "MAX_VALUE": 20000,
    "DEF_VALUE": 0,
    "RESET_ADDR": 0x01 + 0x0A,
},
# OPT_ZOOM : {
OPT_FOCUS : {
    "REG_ADDR" : 0x00,
    "MIN_VALUE" : 0,
    "MAX_VALUE" : 20000,
    "DEF_VALUE": 0,
    "RESET_ADDR": 0x00 + 0x0A,
},

So I set MAX_VALUE to 20000 for both OPT_ZOOM and OPT_FOCUS. Files I’m touching are Focuser.py and FocuserAutoFocus.py — I also have the Focuser.py & FocuserExample.py that were committed about 2 weeks ago with the proper values already modified, but I’m not sure I’m using those ones.

I don’t have any logs to share yet, the auto focus just never settles so nothing obvious gets printed. I’m planning to keep working on the focusing over the next days.

Attaching the screenshot of what I’m seeing:

image_77311290101672210172023.png

You can see the color issue pretty clearly there — the table is brown and the text isn’t the right blue.

Thanks, that screenshot helps a lot.

On the focus/zoom side: the values you pasted look like the ones that were already corrected in the repo. The fix landed in Focuser.py & FocuserExample.py about 2 weeks ago — the proper range/step values were modified in those two Python files, so you shouldn’t need to hand-edit the MIN/MAX yourself. Please pull and use that latest committed code (Focuser.py and FocuserExample.py) rather than the older copies you’ve been modifying, then try again. Your local edits and the committed ones may be conflicting right now, which could be why focus never settles.

On the color side: this is still under investigation, but the most likely cause is the IR-cut filter state. If the IR-cut isn’t actually open when you capture, the colors won’t be true — that matches the brown/red shift you’re seeing. Can you double-check the IR-cut state directly in the code and confirm it reads 1 (open)? Encoding is 0 → closed | 1 → open.

If anything still misbehaves after switching to the latest code, let us know and we’ll dig further.

OK that makes sense. So to be explicit, the steps for me right now are:

  1. Download and use the latest code — Focuser.py & FocuserExample.py — committed ~2 weeks ago, since the proper values are already modified in those two files.
  2. Check the IR-cut setting and confirm it’s set to 1 (open).

Is that it? And if the colors are still off after confirming IR-cut = 1, what should I check next?

Yes, that’s exactly it:

Step 1: Download and use the latest committed code (Focuser.py & FocuserExample.py, committed about 2 weeks ago). The correct focus/zoom range and step values are already in those two files — you shouldn’t need to override MIN_VALUE/MAX_VALUE by hand anymore.

Step 2: Verify the IR-cut. Encoding is 0 → closed | 1 → open, so confirm it’s 1 (open) when you capture. The wrong color rendering is very likely tied to the IR-cut not being open.

Step 3: If any problem remains after that, report back here with what you see and we’ll continue from there.

For reference, the commit that covers the focus zone range/step changes is the one you linked:

And in Focuser.py the settings you were editing should look like this once you’re on the latest code:

OPT_ZOOM : {
    "REG_ADDR" : 0x01,
    "MIN_VALUE": 0,
    "MAX_VALUE": 20000,
    "DEF_VALUE": 0,
    "RESET_ADDR": 0x01 + 0x0A,
},
OPT_FOCUS : {
    "REG_ADDR" : 0x00,
    "MIN_VALUE" : 0,
    "MAX_VALUE" : 20000,
    "DEF_VALUE": 0,
    "RESET_ADDR": 0x00 + 0x0A,
}

To summarize where we are: use the latest Focuser.py & FocuserExample.py instead of your local modifications, and confirm the IR-cut is open (1) for the color issue. If the auto focus still doesn’t settle or the colors are still off after that, post back and we’ll keep investigating — we haven’t fully closed out the color root cause yet.