usb remote, focus and script problem SX230 - page 2 - Script Writing - CHDK Forum  

usb remote, focus and script problem SX230

  • 17 Replies
  • 6457 Views
Re: usb remote, focus and script problem SX230
« Reply #10 on: 16 / July / 2014, 12:29:32 »
Advertisements
Sorry, tl;dr

I'll try to find an hour to read and understand what you've written tonight.

On a quick look at your script, you need to set_focus after you use the set_aflock command - not before.  You could also try set_MF 1 rather than set_aflock 1, again before the set_focus command.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: usb remote, focus and script problem SX230
« Reply #11 on: 16 / July / 2014, 12:48:36 »
Also, replace the click shoot_full with a shoot command. More later when I've had a chance to read more carefully. But using click does not give the camera time to actually take a picture.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #12 on: 16 / July / 2014, 13:17:13 »

I'll try to find an hour to read and understand what you've written tonight.

On a quick look at your script, you need to set_focus after you use the set_aflock command - not before.  You could also try set_MF 1 rather than set_aflock 1, again before the set_focus command.

Hello Waterwingz,

I just tried :

a) your first suggestion "set_focus after you use the set_aflock command - not before", in the script just posted.  The behaviour is exactly the same.

b) your second suggestion:
set_mf 1 rather than set_aflock 1  (using the same script for the rest)

I now get something that is different: with the regularly auto-started script,
(i) the first image taken is out of focus (suggesting that the set_focus took over, which is nice!!!)
(ii) the subsequent images are focussed, suggesting the "set_lcd_display 0" killed the mf state.


I then tried a modified script (see below) , where I enforce 'mf' every time after "set_lcd_display 1" occurs

*****************
rem "modifiedScript.bas"


rem Simple USB Remote Shoot script, manual focus
rem Usage: Select "Enable Remote" in "Remote parameters" and start this script.
@title Remote button




set_mf 1
sleep 200
set_focus 110

sleep 1000
print"foc adj"
playsound 4

while 1
    wait_click 1
      if is_key "remote" then gosub "Foo"
      if is_key "set"    then gosub "emergency"
   rem "erase"     
wend

end

rem **********************************

:Foo

set_lcd_display 1
sleep 200
rem CRITICAL MODIF BELOW $$$$$$$$$$$$$$$$$$$$$$$
set_mf 1
sleep 200
set_focus 110
sleep 1000
rem CRITICAL MODIF END $$$$$$$$$$$$$$$$$$$$$$$
click "shoot_full"
sleep 2000

set_lcd_display 0
sleep 1000

playsound 4
sleep 400
playsound 4
return

rem **********************************
:emergency
set_lcd_display 1
set_aflock 0
sleep 500
print "EMERGENCY ALT EXIT!"
sleep 3000
exit_alt
return

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

... I get now :

(i) NO AUTOFOCUS WHATSOEVER
(ii) SCRIPTED CHDK-SET FOCUS DISTANCE FOR EVERY SINGLE SHOOT (REMOTELY TRIGGERED)


GREAT !!!  :xmas :xmas

Re: usb remote, focus and script problem SX230
« Reply #13 on: 16 / July / 2014, 13:46:44 »
Glad you figured it out! 

I'd still suggest you use  shoot rather than click shoot-full.

 You probably also want to change the final set_aflock 0 to set_MF 0.
« Last Edit: 16 / July / 2014, 13:51:15 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: usb remote, focus and script problem SX230
« Reply #14 on: 16 / July / 2014, 14:08:25 »
Also,  if you had called the get_sd_modes() function it would have told you that either set_mf  or  set_aflock should have worked. 

Can you retest using set_aflock after each set_lcd_display command like you did with set_mf ?   

I'll add a note a few places in the wiki about set_mf / set_aflock and set_lcd_display.  I believe this was discussed in the forum thread for set_lcd_display ( http://chdk.setepontos.com/index.php?topic=10551.msg106496#msg106496 ) but not resolved.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #15 on: 17 / July / 2014, 04:32:00 »
Also,  if you had called the get_sd_modes() function it would have told you that either set_mf  or  set_aflock should have worked. 

Can you retest using set_aflock after each set_lcd_display command like you did with set_mf ?   

I'll add a note a few places in the wiki about set_mf / set_aflock and set_lcd_display.  I believe this was discussed in the forum thread for set_lcd_display ( http://chdk.setepontos.com/index.php?topic=10551.msg106496#msg106496 ) but not resolved.

Hello Waterwingz,

thank you very much  for having looked in detail in my script, and offering further suggestions.

I will try them.

However, I started yesterday a very long series of automatic image aquisition, that might last through the comming wee-end; this prevent me from testing your suggestions right away, because I have only one camera.

I will do the  testing next week.

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #16 on: 21 / July / 2014, 13:48:05 »
Also,  if you had called the get_sd_modes() function it would have told you that either set_mf  or  set_aflock should have worked. 

Can you retest using set_aflock after each set_lcd_display command like you did with set_mf ?   

I'll add a note a few places in the wiki about set_mf / set_aflock and set_lcd_display.  I believe this was discussed in the forum thread for set_lcd_display ( http://chdk.setepontos.com/index.php?topic=10551.msg106496#msg106496 ) but not resolved.

Hello Waterwingz,

I have tried to make the tests you sugested:

1) get_sd_over_modes:   the value obtained is 6, i.e. bit 2 and 4 are set.

2) when replacing set_mf 1 by  set_aflock 1, at all the occurences, chdk goes blasted, I get back control by power cycling.

3) I tried to replace the ' click "shoot_full" ' by shoot: then it does autofocus at each image again !!
hence the 'click "shoot_full" ' is instrumental to get the right behaviour with no autofocus


the slightly modified (working) script is pasted at the end of the post.

* * *
Some other miscellaneous tests, and some difficulties:

A) I also tried to set the zoom.
I could *not* get it to work, when I placed
set_zoom_speed 50
sleep 200
set_zoom 30
sleep 1000
at the begining of the program, (presumably because the lens is not extended at that stage)
but it worked when I place those lines within the "foo" subroutine

B) I played with set_tv, it worked fine; however 'print "TV", get_tv'  results in a script error Tv 0000
Any suggestion about this problem ?

C) In an effort to get the lens extended out (and be then able to set the zoom at the beginning of the program), I  tried  to put 2 lines:
shoot
sleep 2000

 right at the beginning of the program. Nothing is shooted, and the lens does not extend
I duno why.

D) I also played with print statements within the "foo" subroutine: nothing visible is printed...
I get the printed data on screen only when I go through the "emergency" subroutine, that exit the alt mode.
what should I do to get the printed data visible within the "foo" subroutine  ?


* * * *
Here below is the present version of the script. It works in the auto-run mode, and a single beep is heared when it starts.
Then taking pictures is triggered by pressing a remote usb switch *only when the green led is back "on" again, after a shooting*. (as indficated before, there is no image taken the first time the remote button is pressed but the lens extents out, the zoom is set, and the focus is set; Shooting occurs at all subsequent remote pressing (provided the green led is back on before pressing).


* * *
rem Simple USB Remote Shoot script, manual focus
rem Usage: Select "Enable Remote" in "Remote parameters" and start this script.
@title Remote button


rem set_av 384
sleep 200
print "av", get_av
rem print "tv", get_tv

set_mf 1
sleep 200
print "Started OK!"
sleep 2000
playsound 4
rem print  get_sd_over_modes >>6
rem   "zoom step:", get_zoom_steps >>>126

while 1
    wait_click 1
      if is_key "remote" then gosub "Foo"
      if is_key "set"    then gosub "emergency"
   rem "erase"     
wend

end

rem **********************************

:Foo

set_lcd_display 1
sleep 200
set_zoom_speed 50
sleep 200
set_zoom 30
sleep 1000
set_mf 1
sleep 200
set_focus 220
sleep 1000
click "shoot_full"
rem shoot
sleep 2000
 
print "AV: ",get_av
sleep 3000

set_lcd_display 0
sleep 1000

playsound 4
sleep 400
playsound 4

return

rem **********************************
:emergency
set_lcd_display 1
set_mf 0
sleep 500
print "EMERGENCY ALT EXIT!"
sleep 3000
exit_alt
return

* * * *


Thanks for your help  :)

Re: usb remote, focus and script problem SX230
« Reply #17 on: 21 / July / 2014, 18:08:03 »
1) get_sd_over_modes:   the value obtained is 6, i.e. bit 2 and 4 are set.
Thanks. 
Technically that's bits 2 and 1 (link > numbering usually start with zero for the least significant bits) or  0000110 binary.   Which means that (based on testing earlier this year) CHDK should allow set_focus() to work when the camera is in AFL (autofocus lock) or MF (manual focus) modes.  It will not set_focus() if neither of these are selected.

Quote
2) when replacing set_mf 1 by  set_aflock 1, at all the occurences, chdk goes blasted, I get back control by power cycling.
Not good - that's not supposed to happen.


Quote
3) I tried to replace the ' click "shoot_full" ' by shoot: then it does autofocus at each image again ! 
hence the 'click "shoot_full" ' is instrumental to get the right behaviour with no autofocus

Also not supposed to happen if set_mf 1 or set_aflock  1 has happened.  But we probably need to fix the other errors in this script before looking too closely at this.

Quote
set_zoom_speed 50
This is not needed or used on most cameras.

Quote
at the begining of the program, (presumably because the lens is not extended at that stage)
but it worked when I place those lines within the "foo" subroutine
That's normal for the reason you just mentioned.  The lens won't zoom if you are in playback mode and its not extended.

Quote
I played with set_tv, it worked fine; however 'print "TV", get_tv'  results in a script error Tv 0000
The set_tv function is obsolete and should not be used. And there is no get_tv function.  You may want to use this as a reference :  http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page#All_Scripting_Functions

Quote
In an effort to get the lens extended out (and be then able to set the zoom at the beginning of the program), I  tried  to put 2 lines: shoot sleep 2000 right at the beginning of the program. Nothing is shooted, and the lens does not extend I duno why.
Try this :
Code: [Select]
if get_mode = 0 then goto "in_rec"
  sleep 1000
  set_record 1
:wait_rec
  sleep 100
  if get_mode <> 0 then goto "wait_rec"
:in_rec
sleep 500

Quote
D) I also played with print statements within the "foo" subroutine: nothing visible is printed...
I get the printed data on screen only when I go through the "emergency" subroutine, that exit the alt mode.
what should I do to get the printed data visible within the "foo" subroutine  ?
Not sure but there is also no get_av function (you are trying to call it).

I'll add an editorial here.  Once again, any uBASIC program longer than 10 lines proves to be painful to debug.  Lua offers much better error checking - it finds more things wrong for you rather than the script just not working.  It also offers much more understandable error messages.  And it lets you use multicharacter variable names so that its easy to understand what each variable is used for.

« Last Edit: 21 / July / 2014, 18:21:53 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics