G1X locking autofocus when screen is off (for timelapse with intervalometer) - Script Writing - CHDK Forum

G1X locking autofocus when screen is off (for timelapse with intervalometer)

  • 8 Replies
  • 3892 Views
Advertisements
I'm using my Canon G1X with an intervalometer to create timelapse videos. However there is a (known) problem that the camera defaults to AF once the screen is turned off / folded back. This means that I to use manual focus, I have to keep the screen on, which kills my battery really really fast.

Does anyone know of a solution to this using CHDK? Someone on DPR posted that it's possible by adding "af_lock(1)" to his CHDK timelapsing script:
http://forums.dpreview.com/forums/thread/3202733

However:
1) I can't get a response from him.
2) I'm a novice in CHDK.
3) I don't want to use CHDK for timelapsing, I'd rather keep my intervalometer. But I'm willing to activate a script that locks the MF if possible.

Any help would be GREATLY appreciated!!

*

Offline lapser

  • *****
  • 1093
if(get_focus_mode()~=1)then
  set_aflock(1)
end

In my experiments with the G1X and sx270, set_aflock(1) ALWAYS autofocuses before it locks. But it may not autofocus successfully, so you can end up with a blurry time lapse. I've tried set_focus(mm) but set_aflock(1) still focuses again.

The G1X has a manual focus mode. I always set manual focus before entering <alt> mode and starting the script. If you set_aflock when in manual focus mode it crashes the sx260 and doesn't work, so I put the test for manual focus before the set_aflock.

To enter manual focus mode, press the left cursor button twice, then set button, and then use the dials to change the focus. If you half press the shutter button and hold it, then press the left cursor, it enters manual focus mode at that focus position, although you can still use the focus dial.

You want to set the manaul focus a little in front of infinity. I usually try to focus on a tree at least 10 meters away if I'm using wide angle. Google "hyperfocal distance" for more info.

If you want to do the time lapse with the screen off, the down cursor button changes the display. It cycles through normal display, extra stuff display (like the tilt indicator), and totally off. If you turn it totally off, then press the <alt> button, then the shutter button, it should start the script with the display off.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Online philmoz

  • *****
  • 3156
    • Photos
if(get_focus_mode()~=1)then
  set_aflock(1)
end

In my experiments with the G1X and sx270, set_aflock(1) ALWAYS autofocuses before it locks. But it may not autofocus successfully, so you can end up with a blurry time lapse. I've tried set_focus(mm) but set_aflock(1) still focuses again.

The G1X has a manual focus mode. I always set manual focus before entering <alt> mode and starting the script. If you set_aflock when in manual focus mode it crashes the sx260 and doesn't work, so I put the test for manual focus before the set_aflock.

To enter manual focus mode, press the left cursor button twice, then set button, and then use the dials to change the focus. If you half press the shutter button and hold it, then press the left cursor, it enters manual focus mode at that focus position, although you can still use the focus dial.

You want to set the manaul focus a little in front of infinity. I usually try to focus on a tree at least 10 meters away if I'm using wide angle. Google "hyperfocal distance" for more info.

If you want to do the time lapse with the screen off, the down cursor button changes the display. It cycles through normal display, extra stuff display (like the tilt indicator), and totally off. If you turn it totally off, then press the <alt> button, then the shutter button, it should start the script with the display off.

set_aflock(1) works best when used like this:
Code: [Select]
  press("shoot_half")
  repeat sleep(50) until get_shooting() == true
  set_aflock(1)
  release("shoot_half")

It's similar to pressing the AFL button so if you haven't already got focus it tries to get focus first - even if you are in MF mode.

However it's not possible to completely turn off the display and still keep MF on the G1X (plus many other cameras).
As soon as you turn off the display, either with the DISP button or by closing the screen, the camera switches back to autofocus. So far I don't think anyone has found a way around this.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline lapser

  • *****
  • 1093
set_aflock(1) works best when used like this:
Code: [Select]
  press("shoot_half")
  repeat sleep(50) until get_shooting() == true
  set_aflock(1)
  release("shoot_half")
It's similar to pressing the AFL button so if you haven't already got focus it tries to get focus first - even if you are in MF mode.
I found that just set_aflock(1) worked if you're not in manual focus mode, without the "shoot_half". However, I always start a time lapse in manual focus mode so I'm sure of the focus being correct.
However it's not possible to completely turn off the display and still keep MF on the G1X (plus many other cameras).
As soon as you turn off the display, either with the DISP button or by closing the screen, the camera switches back to autofocus. So far I don't think anyone has found a way around this.
I didn't realize that, but that's exactly what happens.

I guess you need to turn off the display with set_backlight(0). It turns on again with every picture, so you have to put  set_backlight(0) in the sleep loop. I have this in my time lapse script under development, with a display toggle on/off by pressing "set". I actually like the display flash, since it lets you know the camera is working.

I also added this in the restore() function, which is called when a script exits:
Code: (lua) [Select]
function restore()
  hfile:close()
  set_backlight(1)
  set_aflock(0)
end
"hfile" is my log file instead of using print_screen. I like to run a time  lapse until the battery dies, usually around 2 hours. But on the G1X, hfile never closed and was lost, unfortunately. When I used print_screen, it closes the file with low battery shut down.

Do you know if restore() is called during low battery shut down? I may need to go back to print_screen.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Online philmoz

  • *****
  • 3156
    • Photos
set_aflock(1) works best when used like this:
Code: [Select]
  press("shoot_half")
  repeat sleep(50) until get_shooting() == true
  set_aflock(1)
  release("shoot_half")
It's similar to pressing the AFL button so if you haven't already got focus it tries to get focus first - even if you are in MF mode.
I found that just set_aflock(1) worked if you're not in manual focus mode, without the "shoot_half". However, I always start a time lapse in manual focus mode so I'm sure of the focus being correct.
The problem is that the sometimes the first 'shoot' after power up doesn't respect the MF setting and refocuses.
See this thread http://chdk.setepontos.com/index.php?topic=8886.msg92779#msg92779 - I found the same issue on the G1X.

Quote
I also added this in the restore() function, which is called when a script exits:
Code: (lua) [Select]
function restore()
  hfile:close()
  set_backlight(1)
  set_aflock(0)
end
"hfile" is my log file instead of using print_screen. I like to run a time  lapse until the battery dies, usually around 2 hours. But on the G1X, hfile never closed and was lost, unfortunately. When I used print_screen, it closes the file with low battery shut down.

Do you know if restore() is called during low battery shut down? I may need to go back to print_screen.

I don't know if CHDK gets any notification of a shutdown so I'm not sure it's possible to close any open files or call the 'restore' function.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline lapser

  • *****
  • 1093
Quote
I also added this in the restore() function, which is called when a script exits:
Code: (lua) [Select]
function restore()
  hfile:close()
  set_backlight(1)
  set_aflock(0)
end
"hfile" is my log file instead of using print_screen. I like to run a time  lapse until the battery dies, usually around 2 hours. But on the G1X, hfile never closed and was lost, unfortunately. When I used print_screen, it closes the file with low battery shut down.

Do you know if restore() is called during low battery shut down? I may need to go back to print_screen.

I don't know if CHDK gets any notification of a shutdown so I'm not sure it's possible to close any open files or call the 'restore' function.

Phil.
With print_screen, it looks like CHDK closes the file after each call, so it's not lost in shutdown.
[edit: just tested it and print_screen log file is lost with shut down - it would still be nice to make the below modification to print_screen]

My only problem with print_screen() is that you can't set a unique file name. You old log is lost each time you run the script. This is one solution:
print_screen(os.date("%H%M"))
This creates a file with the time in it: log_mmss.txt

Would it be possible to modify CHDK so if you call print_screen() with an argument that's longer than 4 characters, it just uses the argument as the file name, appending ".txt" or ".log" at the end? Then I could do this and have a completely unique log file each time the script runs:

print_screen(os.date("%y%m%d%H%M"))
======
Also, I posted my version of the script to set hyperfocal distance at:
http://chdk.setepontos.com/index.php?topic=8886.msg93202#msg93202
« Last Edit: 14 / November / 2012, 23:17:39 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

However it's not possible to completely turn off the display and still keep MF on the G1X (plus many other cameras).
As soon as you turn off the display, either with the DISP button or by closing the screen, the camera switches back to autofocus. So far I don't think anyone has found a way around this.
You sound very convincing - I guess I'll have to take your word for it and stop searching for solutions if even the geniuses here couldn't figure it out. That's REALLY discouraging. As far as I can tell the screen is currently limiting the number of shots I can get in a single run, not anything else (time/number of photos)... and due to the poor placement of the tripod screw, you can't even change the battery mid-session without mounting the camera off the tripod. :( :( :(

Use an external lead-acid battery and dc\dc converter.

That is what I do.

David


*

Offline lapser

  • *****
  • 1093
You sound very convincing - I guess I'll have to take your word for it and stop searching for solutions if even the geniuses here couldn't figure it out. That's REALLY discouraging. As far as I can tell the screen is currently limiting the number of shots I can get in a single run, not anything else (time/number of photos)... and due to the poor placement of the tripod screw, you can't even change the battery mid-session without mounting the camera off the tripod. :( :( :(
Actually, the solution is to use set_backlight(0) in the script. Add this function:
Code: (lua) [Select]
function sleeper(t)
  set_backlight(0)
  sleep(t)
end
Then change all the calls to sleep(time), into calls to sleeper(time).

I get about 2 hours of time lapsing on the G1X using this solution. If you need more time, you can use an external power source. If you have A/C available, this is the one I bought.

http://www.amazon.com/gp/product/B008SH82CU/ref=oh_details_o04_s00_i00

I also use a cheap A/C inverter plugged into the car lighter socket for power, and it works fine.

For backpacking, I bought an 8.4V battery, but I haven't plugged it into the G1X yet (waiting on connectors). We had a discussion that 8.4V might be too high for the G1X, which use 7.4 volt batteries. However, a fully charged battery is 8.2 Volts, which is the high value CHDK uses for the G1X, so 8.4 volts should work fine. I noticed that the A/C adapter above shows around 60% battery charge.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics