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

usb remote, focus and script problem SX230

  • 17 Replies
  • 6951 Views
*

Offline fx

  • *
  • 15
usb remote, focus and script problem SX230
« on: 08 / July / 2014, 09:41:14 »
Advertisements
Hi,

I am using a canon SX230, and have installed chdk on its 15 Gb SD card. (I have to make a 'firmware update' to load chdk when I turn the camera on).

CONFIGURATION:
I am trying to capture a slow phenomenon (growth of bacteria on  a petri dish over a timescale of a few days). I want to take  pictures every 20 min. I have also an AC power supply adaptor, so that the SX230 can run over very long periods without power supply shortage.

 I cannot use a simple timelapse script, because the lighting on the petri dish needs to be turned off between shootings (too much heating if left on).

I am using an Arduino microcontroler to repeatedly (a) turn light on (b) generate a 1 second 5V pulse on the usb input of the camera so as to trigger picture shooting , (c) turn light off (d) wait then cycle back to step(a).

I enabled "remote" on chdk setting, 1 push; I load the script CHDK\SCRIPTS\EXAM\remote.bas.

With chdk loaded (and not in the 'alt' mode), I  put the camera under manual setting for iso, speed, and focus distance; I also adjust zoom to the desired value, and set 'on' the automatic LCD turn off.
The LCD automanic shut off is important to avoid too much heating of the SX230.

Left in the standard mode (not in the 'alt' mode), the triggering (made by the Arduino) works nicely to shoot automatically at chosen time intervals

PROBLEM:
Things appears to go smoothly, BUT:
When looking at the series of pictures taken over few days, it appears that the focus is not steady from one picture to the other.  :(
Would someone have an idea of why this occurs ????

ALTERNATE ASSAY:
I have written a small script, so as to force a fixed value of focus, and make this script the one to be executed, in the chdk settings.
remot1.bas:

@title Remote button

while 1
    wait_click 1
    if is_key "remote" then gosub "Foo"
wend

end

:Foo
set_focus 247
rem  set zoom 35 (zoom setting does not seem to work on the SX230)
shoot
print get_focus
print get_zoom

return


* * * * *
After that I have loaded chdk via firmware update, I get out of the 'alt' mode so as to set the value of the zoom, and extend the lens out; at that time, I get the message "interrupted".

PROBLEM:
after that manual setting of the zoom,
 the script only works when I leave the SX230 in th 'alt' mode. (Otherwise, shooting is indeed triggered, but apparently without going through the above script remot1.bas. (no printed values, and no proper focus).

Why is that ???  What is the way to go ?


(I would not mind leaving the chdk running, but I would then need tu turn on and off the LCD so that the SX230 does not heat too much.)

Thanks for the help!



Re: usb remote, focus and script problem SX230
« Reply #1 on: 08 / July / 2014, 10:15:05 »
Scripts only only run in ALT mode. You have two different things happening here - script based shooting in ALT mode and built-in CHDK USB remote shooting when not in ALT mode.

You need to add a set_aflock statement to your script and possibly a set_focus statement too.  These both work much more reliably with CHDK 1.3.0 so upgrade to that if you have not already done so.

As far as the LCD goes, you can turn that off with the set_LCD_display statement in 1.3.0.

Update : you may find this helpful : http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page
« Last Edit: 08 / July / 2014, 10:23:49 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: usb remote, focus and script problem SX230
« Reply #2 on: 08 / July / 2014, 12:36:20 »
(I have to make a 'firmware update' to load chdk when I turn the camera on).
No, you don't have to if you make the card bootable and lock it (use http://zenoshrdlu.com/stick/stick.html to install).

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #3 on: 09 / July / 2014, 12:47:57 »
Scripts only only run in ALT mode. You have two different things happening here - script based shooting in ALT mode and built-in CHDK USB remote shooting when not in ALT mode.

OK, I get the point !
You need to add a set_aflock statement to your script and possibly a set_focus statement too.  These both work much more reliably with CHDK 1.3.0 so upgrade to that if you have not already done so.

The camera is set in the "manual mode", with manual focus. I also set the various focus modes to off.
I then switch to the 'alt' mode with scripting (see below).

while 1
    wait_click 1
    if is_key "remote" then gosub "Foo"
wend

end

:Foo
set_lcd_display 1
sleep 500
rem console_redraw
set_aflock 0
set_focus 230

sleep 500
shoot
print get_focus
print get_zoom
console_redraw
set_aflock 1
set_lcd_display 0

return


I the script use the set_focus, it seems to work, BUT (i) the distance "displayed" briefly on the LCD (detailled info) does not seem to always correspond to  the value set via the script, and (ii) the focus is still displaying some level of erratic changes from picture to picture (examining 100 pictures taken via the script). (when I look at the print get_focus while being near the camera, it prints the value set by set_focus 230).

Any idea of what might perturb the focus ? could it be the set_aflock 0 ?

These both work much more reliably with CHDK 1.3.0 so upgrade to that if you have not already done so.

I use presently CHDK 1.2; I will follow your advice to upgrade to 1.3

As far as the LCD goes, you can turn that off with the set_LCD_display statement in 1.3.0.
OK, I used your suggestion

Update : you may find this helpful : http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page
Yes, thanks for the tip.



*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #4 on: 09 / July / 2014, 12:51:26 »
(I have to make a 'firmware update' to load chdk when I turn the camera on).
No, you don't have to if you make the card bootable and lock it (use http://zenoshrdlu.com/stick/stick.html to install).

I thought initially  that there was a 4gb limit to have the automatic CHDK boot.
I will follow your suggestion.
(I am however more concerned for now bu the somewhat erratic focus that I get)

Re: usb remote, focus and script problem SX230
« Reply #5 on: 09 / July / 2014, 15:09:12 »


I thought initially  that there was a 4gb limit to have the automatic CHDK boot.

That limit only applied to cameras released prior to 2012 as they could only boot from a FAT16 partition.  FAT16 partitions are limited to a maximum size of 4G.  Newer cameras will boot from a FAT32 partition which can be much larger.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: usb remote, focus and script problem SX230
« Reply #6 on: 09 / July / 2014, 15:16:12 »
Any idea of what might perturb the focus ? could it be the set_aflock 0 ?
Use set_aflock 1 to lock the focus, not set_aflock 0

« Last Edit: 09 / July / 2014, 15:26:40 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #7 on: 16 / July / 2014, 09:15:29 »
(I have to make a 'firmware update' to load chdk when I turn the camera on).
No, you don't have to if you make the card bootable and lock it (use http://zenoshrdlu.com/stick/stick.html to install).

Hi Srsa_4c,

I got the "Stick" software you advised (link in the quote)  installed on my WinXP PC, and got a very smooth behaviour, in my back and forth tests between CHDK1.2 ("stable"), and CHDK1.3, while getting automatic install with auto-boot for CHDK.

I used a 16GB SD card.

During the number of back and forth tests I did,

No formatting had to take place, so the pictures on the SD card were not altered by CHDK changes, the personal scripts that I had on the sd card (in CHDK/EXAM) where not altered by CHDK changes .

Therefore, I could switch CHDK between 1.2 and 1.3 with no hastle at all .

Thanks  :)


*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #8 on: 16 / July / 2014, 12:08:07 »
Any idea of what might perturb the focus ? could it be the set_aflock 0 ?
Use set_aflock 1 to lock the focus, not set_aflock 0

Hi Waterwingz,

I took quite a sizeable delay to come back to you.

I have been experimenting along the lines you suggested, i.e.
 (a) use CHDK1.3, and
 (b) use set_aflock


I got actually extremely frustrated with myself,
 power-cycling, testing varous script options, extracting the SD card, making another test, etc...
("bienvenue au club" ... )

I am now under CHDK1.3, and using an "SX230 HS"

%%%%%%%%%%%%%%%%
I select in CHDK the following options :

Enhanced Photo Operations:
overrides disable: no
(but no overrides selected in the list)
disable overrides at startup: no

save raw: no
script:
autostart: yes
script shoot delay: 1
parameter set : 0
save param: off

chdk settings:

alt mode button: display
  remote parameters:
      enable remote: yes
      switch type: onePush
      control mode: normal
      enable synch: no

disable lcd off: never


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

I select in the SX230 HS camera the following options:
retraction of objective: 1 min
eco: no auto extinction
        display off: 10 sec


I selected the manual mode,
iso 100,  1/80,  f4, manual focus

also I selected:

AF zone: center
numerical zoom: off
zoom over AF point: off
AF servo: off
continuous AF: off
AF beam: off
point zoom MF: off
map man secur: off
display: maintain

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

The script I have now is the following:

it uses set_aflock, but with quite mixed results, as detailled later.

it makes one beep after an initial set_focus followed by set_aflock 1
it makes two beeps when completing the subroutine "foo", that is accessed when the script detects the remote swich is operated (for debugging, I have a manual push-button switch, associated with a 9v battery; this is connected at one end of a usb cable (the other end of the cable is plugged into the usb port of the camera).

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


set_focus 110
sleep 1000
rem 3000
set_aflock 1
sleep 1000
rem 2000
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 1000

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


* * * * * * * * * * * * * *

After power cycling, and automatic chdk boot,

the script starts as expected (while the lens is still retracted),  I get one beep, and the display prints "foc adj".

when pressing the remote switch, the lens extends, the screen display the current image to be taken, and some focus takes place; however no picture is taken, there is no shutter sound; I then hear two beeps, meaning the the subroutine foo has essentially done its job. The screen goes off, the green led if off.

The green led stays off for a time that is linked to the choice of "display off: 10 sec" (see earlier section): indeed, the green light stays off for about 10 sec with "display off: 10 sec" , and about 1 minute for "display off: 1 min"

when pressing again the remote switch[BUT (otherwise CHDK fails and need powercycling) I PRESS THE REMOTE ONLY when the green led has come back lighted up]

Then the screen goes alive again, a picture is taken, I get two beeps, the screens turns off, the green light goes off for a while, until it is green again.
This can go on for as many cycles that I want, unless I press "funcSet", the button I have chosen for exiting the alt mode.

When however reviewing the pictures that have been taken:
 (i) the requested focus  (set_focus 110) is NOT  followed
 (ii) WORSE, there is actually autofocus at EACH image taken ( varying the distance between the SX230, and the screen of my PC with a document displayed on it  taken as subject), before hitting the remote switch.  I can see autofocus occuring on the SX230 display when it gets alive.

I tried also to have initially a short distance (5 cm) between the PC screen (as image to be taken) and the SX230 objective, reasoning that the first stage (where no picture is taken) might actually perform an autofocus; however during the next stages where an image is taken (remote switch), autofocus is occuring for every single image taken, keeping a focussed image foe each shoot (when I analyze the results) even if I vary the distance to the PC target screen.


I tried then a different procedure, with the SAME program.

After power-cycling, and chdk automatic boot, script launch, and hearing a single beep:
I make the following list of actions:
1) I press the shutter button, it prints "INTERRUPTED", and exits the script, while still in the 'alt' mode.
2) I hit the 'alt' button (the "disp" button), and exit the 'alt' mode.
3) I half-press the shutter, the lens extends out.
4) I press again the 'alt' button, to enter the 'alt' mode
5) I press full the shutter, WHILE the screen target is at a chosen distance of its target PC screen (I typically choose a short distance of about 5cm): it starts the script, AND AUTOFOCUS TAKES PLACE, it can bee seen on the transiently live SX230 display.
6) when the green led is back "on", I hit the remote button. The screen gets live and displays the current image to be taken, NO FOCUS TAKES PLACE (if the PC screen target is now at 1 meter, the image taken is blurred) , a picture is taken with shutter sound; I then hear two beeps, meaning the the subroutine foo has essentially done its job. The screen goes off, the green led if off. 


No focus is taken place at steps 6, in contrast to the mode of operation presented earlier: if the PC screen target is now at 1 meter when hitting the remote button, I see no transient autofocus on the SX230 display, and when reviewing the images taken, the image taken are all  blurred is the targert distance was maintained large): this is just fine as it implies that there is ONE AND ONLY ONE autofocus taking place (at step 5), and this occurs right at the beginning of the series of the captured images.

When the green led is back on again, I can hit again the remote switch, and another image is taken STILL WITH NO AUTOFOCUS.
The process of taking further images with no further autofocus can be continued at will.


* * * * *
SEE NEXT POST FOR CONCLUSIONS      (because exceeding max total post char count= 7500...)

*

Offline fx

  • *
  • 15
Re: usb remote, focus and script problem SX230
« Reply #9 on: 16 / July / 2014, 12:18:05 »
Any idea of what might perturb the focus ? could it be the set_aflock 0 ?
Use set_aflock 1 to lock the focus, not set_aflock 0

(END OF MY LAST RESPONSE...)

* * * * *
CONCLUSIONS:

auto-starting my script  (presented in my last post)  brings an incorrect behaviour (autofocus at every image that is triggered remotely) :o

2°) killing the started script, exiting the alt mode, having the lens extend in the manual mode, then going back to the alt-mode, and starting the script via the full-press on the shutter, (i) does autofocus upon full-press of the shutter, and importantly, (ii) DOES NOT MAKE ANY FURTHER AUTOFOCUS


3) I get something that is usefull for me (no autofocus at every image, and this is important in the bacterial growth that I want to monitor, as some water condensation may occur in the top cover of the petri dish I am using. This condensation eventually accumulate as a "liquid corner" under the top cover, and it severely disturbs correct focusing, preventing focus on the level wher bacteria growth occurs.

I am therefore happy (my efforts brings something I can use), BUT, it is somewhat of a residual conceptual and practical pain not being able to set the focus via CHDK. I actually need for starting collecting images (with no autofocus during the series), to first (one single autofocus) aim at a mock target placed at the distance that I want for the whole series.

4) I also played with the chdk option of Override Subject distance, "on", 120
When I set that, I get CHDK go to hell when the script is started (needing then powercycling to get back handle on the SX230). I dis not pursue that way, as I got fedup with powercycling...


If you have survived through this lenghty post...,
SUGGESTIONS FOR IMPROVEMENTS,
i.e. CHDK focus setting and scripting  that delivers a chosen focus, and survives while the display is turned off and on)...

 are wellcome ! :xmas





 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal