Focus bracketing scripts sometimes stops at "shoot" command - page 7 - Script Writing - CHDK Forum

Focus bracketing scripts sometimes stops at "shoot" command

  • 76 Replies
  • 9237 Views
*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #60 on: 06 / January / 2013, 09:24:59 »
Advertisements
@lapser
The "insistent" wins, well done lapser !  :D
Actually, I just used Phil's idea of repeating the shot if it failed. I just repeat it in shoot() instead of making the script repeat it. Working together "wins".

I didn't expect the 2nd half of shoot1.lua to work. That's the part where it holds shoot_half down and takes shots without metering or focusing each shot. Does it work in single shot AND continuous mode? I changed it so it holds the shutter down until the shot starts now, rather than pulsing the shutter as before.

I've got a feeling that the problem is with the time it takes to focus. If the focus isn't ready when you try to take the shot, maybe it doesn't shoot. When the flash is charging, the voltage drops, and the focusing motor would be slower (just a theory).

shoot() waits for the flash to be ready, but doesn't check if the focus is ready. I'll have to experiment with this when I get the time.

One thing that would be interesting to try, is to see if your script works in half_shoot. Just start the script with:
Code: [Select]
press "shoot_half"
do
    sleep 50
until get_shooting = 1
When you do this, my new shoot() function uses shoot_full_only, so it doesn't re-meter each shot. But your set_focus calls might work in half_shoot. If they do, the script might hang again, but we could try to work that out too. You'll need to be in manual focus for this to work.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #61 on: 06 / January / 2013, 10:16:35 »
Quote
Does it work in single shot AND continuous mode?

All tests with flash.
- Did a 100 shoot loop in single shot mode without any problem.
- Next test in high-speed mode didn´t start the second part ... When I interrupted the script and started it again, it looped twice for every shot (this is consistent with my other hangs)
- One more test in high-speed, 100 shots in second part with no problem...

Last test with this script
Code: [Select]
rem Leif Karlsson
@title lapser
@param n Max number of steps
@default n 200

sleep 2000

  for s=1 to n
  press "shoot_half"
do
    sleep 50
until get_shooting = 1
   shoot
   get_focus f
   get_dof d
   g=f+d*2/3
   set_focus g
   print g,d
   if g>50000 then s=n
   if d<0 then s=n
  next s

end

Correct to use shoot ?
100 shots no problems.

*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #62 on: 06 / January / 2013, 19:03:55 »
All tests with flash.
- Did a 100 shoot loop in single shot mode without any problem.
- Next test in high-speed mode didn´t start the second part ... When I interrupted the script and started it again, it looped twice for every shot (this is consistent with my other hangs)
- One more test in high-speed, 100 shots in second part with no problem...
OK, that's interesting. So it hung after press "half_shoot" when there was a shoot right afterwards. That's the same shoot sequence I had in the version that hung before. Press "half_shoot" and hold "shoot_full" until the shutter opens.
Quote
Last test with this script
Code: [Select]
rem Leif Karlsson
@title lapser
@param n Max number of steps
@default n 200

press "shoot_half"
do
    sleep 10
until get_shooting = 1
sleep 2000

for s=1 to n
   shoot
   get_focus f
   get_dof d
   g=f+d*2/3
   set_focus g
   print g,d
   if g>50000 then s=n
   if d<0 then s=n
  next s
end
Correct to use shoot ?
100 shots no problems.
If the uBasic script works, then that means that focusing works in half_shoot, assuming it was focusing. Did you look at the pictures? Can you try it without the flash? It should be significantly faster in half_shoot.

I'm moved the press "shoot_half" to the beginning, since you only need to do it once. The sleep 2000 after that will hopefully give it time to focus.

I assume you were in manual focus when you ran the uBasic script? That's the only mode focus works in on my camera. But get_focus_ok() always returns true in manual focus. I'll have to see if I can fix that, so I can wait for focus to finish before shoot, and see if that prevents the hangs.

If you don't mind continuing the testing, I'll see if I can add a check for focus done that works in manual mode. I also added a print "shoot failed" message when that happens.

[EDIT]The sx260 crashes when you set_focus in half_shoot, so  forget about any further testing of that. Let's declare victory over this problem, and I'll get back to time lapse programming. Many thanks for all the help. I think the new shoot() function should be really useful, since it now works twice as fast in half_shoot. I'll post a new CHDK build for you with the fix and the testing code cleaned up soon.
« Last Edit: 07 / January / 2013, 00:53:55 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #63 on: 07 / January / 2013, 23:50:11 »
I have another theory that may be the cause of a lot of strange bugs like this. CHDK uses a lot of delays for the camera to respond. All the delays are based on the camera timer, which counts in milliseconds. My theory is that when the camera is really busy, a lot of time goes by with the camera blocking CHDK almost completely. In particular, I noticed that my lua script took seconds to run a short piece of code that usually finished in under 10 msec.

The relevant time delays are implemented in the "action stack" part of CHDK. It checks the camera time once per cycle, and exits when the time is greater than the target delayed time. If the camera is busy, this could be 1 cycle, so the camera might not recognize a key press that lasted 1 cycle. Normally a cycle is 10 msec, but a busy cycle might be much longer.

Anyway, I wrote a test build that can delay a specified number of cycles. The attached version does that in shoot, delaying 5 or 6 cycles between press and release shoot_full. For the test, shots alternate between this new way, and the old way. It prints what's happening to the script console, and should be saved in the log file if you start the script with print_screen 1.

If it misses a shot, it prints "shoot failed" and tries again. You should see this message with the old shoot, but if I'm right, the new shoot will always work.

I know you've done a lot of testing, but this would be a pretty important piece of information to know for the future. So will you run the script again, as usual, and post the log file with the results? Many thanks.

Code: [Select]
rem Leif Karlsson
@title lapser
@param n Max number of steps
@default n 200
print_screen 1
for s=1 to n
   shoot
   get_focus f
   get_dof d
   g=f+d*2/3
   set_focus g
   print g,d
   if g>50000 then s=n
   if d<0 then s=n
  next s
end
I've also updated shoot1.lua to use my new timing functions. Now you just press <set> to go to the next test. The last test holds shoot full down, and only works in continuous mode. You can set parameters for the shot interval in sec, and the number of shots per interval. If the interval is 10 seconds, and the shots per interval is 3, you'll do a quick burst of 3 shots every 10 seconds.

The nice thing about continuous mode, in addition to the speed, is that the pictures are displayed on the screen all the time, with review mode off. Does that work on your camera?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #64 on: 08 / January / 2013, 12:39:37 »
@lapser

Keep the tests coming  :D

I made 3 tests, see the attached logfiles.
They all ended with a crash (shoot new). Also some missed shots with both old and new shoot ...
« Last Edit: 08 / January / 2013, 12:44:49 by skrylten »

Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #65 on: 08 / January / 2013, 12:40:14 »
3:rd logfile

*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #66 on: 08 / January / 2013, 17:23:14 »
Keep the tests coming  :D
They all ended with a crash (shoot new). Also some missed shots with both old and new shoot ...
Yes, we're having fun now, eh? Were you in manual focus for these tests? Does it focus correctly if you're in auto-focus on your camera?  I need to print more camera status stuff at the beginning of the script.

I'm not sure getting the camera to crash is an improvement, but it's probably from the focus part. I get a lot of crashes from that on my camera.

If anyone is reading this (anyone... anyone... philmoz?), is there any way to tell when the focus is ready? get_focus_ok doesn't work with manual focus, and the g1x and sx260 won't set_focus unless they're in manual focus. Ms. Rock, meet Mr. Hardplace.

I've got a new version that saves the time and cycle count at various stages in the shooting process that should tell us something. I'll post it soon, hopefully tonight. Again, thanks for testing.

[I was getting pretty deep in the weeds with all these test modifications, so I decided to move on so I can finish my time lapse routines. Maybe I'll come back to it later, but for now, thanks again for the help in testing. I think we have the best solution to have shoot() re-shoot automatically if it fails, instead of returning with an error code. That seems to solve the bug without requiring any script changes.
« Last Edit: 09 / January / 2013, 12:22:14 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #67 on: 26 / January / 2013, 12:18:59 »
Here's another test build trying to get to the cause of the problem. This build adds a delay of 100msec after the camera says the flash is ready and it's ready to shoot... BEFORE pressing the shutter.

When a script is doing its own press and release of the shutter, there's always a delay at this point, which could explain why it works that way, and not with shoot().

I also found the variable:

        extern volatile long focus_busy;

My theory is that the camera may fail to shoot because it is still focusing. I plan to dig into the focus mechanism more in the near future. If this build fixes your shoot problem, we can explore this as the cause of the bug.

It should print out "SHOOT FAILED" if it didn't work. This version doesn't try to re-shoot, it just returns an error flag. So if you see "SHOOT FAILED" it's back to the drawing board.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #68 on: 27 / January / 2013, 10:02:22 »
Back to testing ...  :D
Tested with my original "shoot" script in this thread.

3 "SHOOT FAILED"  in about 100 shots.

Side note: I have seen two consecutive "missed shots" with Philmoz version, if that is to any help ...

*

Offline lapser

  • *****
  • 1093
Re: Focus bracketing scripts sometimes stops at "shoot" command
« Reply #69 on: 27 / January / 2013, 13:45:41 »
3 "SHOOT FAILED"  in about 100 shots.
Side note: I have seen two consecutive "missed shots" with Philmoz version, if that is to any help ...
Oh well, it was worth a shot.  I really need to reproduce the bug on my camera to figure it out, if it's figure outable.

That's interesting that you've had 2 missed shots in a row. I think I implied that I would eat my shorts if that ever happened. They don't taste too bad diced up and with ketchup. Next time, I'll wash them first, though. :)

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics