Thank you very much!
I will test it in my A590. I write a script myself.It can work. But there still some defect in both of my script and yours. The shoot number can not record in the SD card. And the cammera can not shoot if the SD card is full.
From your previous comments I thought that you might be using a SD card that could hold all of the shots during the process. Since the process for erasing photos is more involved on your camera (especially to erase all at once), it isn't easy to code into a UBasic script, so I added:
-
Number of Shots parameter to allow you to shoot a set amount of shots and then stop the script to allow you to delete the images on the SD Card and then restart the script. The counter will restart at 1 for each run, so you'll just have to keep track of the shots you take each time. The final shot will be recorded on the SD Card. If you use a large enough SD Card that will hold all of the shots, then just set the "Number of Shots" parameter to 0 and it will shoot until the batteries voltage runs down.
-
FilNum parameter to allow you to change the LOG file number for each run just in case you wanted to save each run separately. This will also allow you to compare the battery voltage changes later (see following comments regarding the battery voltages). This parameter can only be 1 to 1000; if the parameter is zero or less, it will be changed to 1 by the script.
Note: There is a special circumstance where the power may not be sufficient to complete the writing of the LOG file to the SD card and the old file will be erased and no file will be written to the SD Card. Therefore, I added a safe guard to work around this problem by using a "toggle-switch" of sorts that will write the first file using the FilNum value set in the parameter and then the next write will use the FilNum+1000 (i.e. if FilNum is set to 2, the first write will be to LOG_0002.TXT, and the next will be LOG_1002.TXT, the third LOG_0002.TXT again, etc.). If the last write is unsuccessful, at least you will still have the next to last recorded file.
Since you want to record the last shot number I also added a couple of other things to your script above. I added the ability to record:
- last shot taken
- zoom step when shot is taken
- date & time
- battery voltage when the script was started (in millivolts)
- battery voltage just after shot is taken (in millivolts)
I added the battery voltage in case you wanted to know how low the battery voltage drops before the camera shutdowns on its own. The information for the last shot taken is in the file "LOG_xxxx.TXT" located in the CHDK/LOGS folder on your SD Card. Each new shot rewrites the "LOG_xxxx.TXT" file so that only the last shot info will be saved. If you change the FilNum parameter, then each LOG file name will also change (i.e. if you change FilNum to 3, then the LOG file name will be saved as "LOG_0003.TXT"). Here is what a sample of the "LOG_xxxx.TXT" file looks like:
Date: 28/2/2011
Time: 14:44:0
Shot number: 5
Zoom level: 7
Batt start: 5161 mv
Batt now: 5151 mv
I noticed that the position of some of the sleep statements needed to be changed. There usually needs to be sleep statements after the zoom statements to allow time for the camera to focus the lens and there needs to be a sleep statement after the shoot statement to allow the camera more time. Using your basic pattern of programming, I moved most of your statements into the subroutine at the bottom and reduced the number of lines of code needed. Here is your script rewritten:
rem Thanks for SkyWalker9
@title Battery Test
@param c Number of Shots
@default c 1
@param B FilNum
@default B 1
if B<=0 then B=1
if c=0 then c=999999
n=1
W=get_vbatt
:shot
get_zoom r
print "zoom level", r
set_zoom 7
gosub "save_shotnum"
get_zoom r
print "zoom level", r
set_zoom 0
gosub "save_shotnum"
goto "shot"
:save_shotnum
sleep 1000
z=get_time 0
y=get_time 1
x=get_time 2
m=get_time 3
o=get_time 4
p=get_time 5
shoot
sleep 600
V=get_vbatt
get_zoom q
print_screen B
print "Date: "m"/"o"/"p
print "Time: "x":"y":"z
print " "
print "Shot number:", n
print " Zoom level:", q
print " "
print "Batt start: "W" mv"
print "Batt now: "V" mv"
print_screen 0
if B<1000 then B=B+1000 else B=B-1000
n=n+1
if n>c then goto "done"
return
:done
end