supplierdeeply

How to make a script for worst case test of battery life?

  • 4 Replies
  • 2261 Views
How to make a script for worst case test of battery life?
« on: 14 / February / 2011, 23:55:06 »
Advertisements
      I found my battery for A590is can shoot about more than 1000 pics with flash in burst mode. But in actrully using, the A590 will shut off in none CHDK mode after shooting no more than 400 pics. If it is in CHDK mode, the battery life will even shorter. I really want to test my battery how many pics can taken in worst case.
      Will someone can help me for write scripts to test my battery life?
      The script should can shoot repeatly from zoom in max to zoom out max  every time untill the battry run out.
       Sorry for my poorly english. Anyone can help? Thank a lot!

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: How to make a script for worst case test of battery life?
« Reply #1 on: 21 / February / 2011, 20:38:05 »
     I found my battery for A590is can shoot about more than 1000 pics with flash in burst mode. But in actrully using, the A590 will shut off in none CHDK mode after shooting no more than 400 pics. If it is in CHDK mode, the battery life will even shorter. I really want to test my battery how many pics can taken in worst case.
      Will someone can help me for write scripts to test my battery life?
      The script should can shoot repeatly from zoom in max to zoom out max  every time untill the battry run out.
       Sorry for my poorly english. Anyone can help? Thank a lot!
This posting might be of interest: http://chdk.setepontos.com/index.php?topic=2622.0

I created a script that might work on your camera. The first script I posted used the click "zoom-in" and click "zoom-out" mentioned in the CHDK USBasic users manual, however those didn't work on my SX20. The set_zoom command did work on my SX20. I've updated the script below to reflect the newer commands which worked on my SX20. Use caution, and good luck testing!

This script has an endless loop with zoom commands - use it at your own risk

Code: [Select]
rem Author SkyWalker9
@title Battery Test

rem Use at your own risk
rem This script zooms the camera lense in and out using an endless loop.

rem A-Series cameras have 9 or 15 zoom steps (0 to 8 or 14)
rem S-series cameras have 129 zoom steps (0 to 128).

rem get the maximum zoom steps for this camera
 x=get_zoom_steps
 x=x-2
 s=1

rem never ending loop to determine max number of shots on battery charge
rem zoom ranges low end of 1 and high end of 1 less than the max of camera

:repeat

   set_zoom 1
   sleep 600
   cls
   print "Shot: "s
   print " "
   shoot
   sleep 600
   s=s+1

   set_zoom x
   sleep 600
   cls
   print "Shot: "s
   print " "
   shoot
   sleep 600
   s=s+1

 goto "repeat"
« Last Edit: 22 / February / 2011, 12:16:27 by SkyWalker9 »

Re: How to make a script for worst case test of battery life?
« Reply #2 on: 28 / February / 2011, 08:38:31 »
      I found my battery for A590is can shoot about more than 1000 pics with flash in burst mode. But in actrully using, the A590 will shut off in none CHDK mode after shooting no more than 400 pics. If it is in CHDK mode, the battery life will even shorter. I really want to test my battery how many pics can taken in worst case.
      Will someone can help me for write scripts to test my battery life?
      The script should can shoot repeatly from zoom in max to zoom out max  every time untill the battry run out.
       Sorry for my poorly english. Anyone can help? Thank a lot!
This posting might be of interest: http://chdk.setepontos.com/index.php?topic=2622.0

I created a script that might work on your camera. The first script I posted used the click "zoom-in" and click "zoom-out" mentioned in the CHDK USBasic users manual, however those didn't work on my SX20. The set_zoom command did work on my SX20. I've updated the script below to reflect the newer commands which worked on my SX20. Use caution, and good luck testing!

This script has an endless loop with zoom commands - use it at your own risk

Code: [Select]
rem Thanks for SkyWalker9
@title Battery Test
n=1

:shot
    get_zoom r
    print "zoom level", r
    sleep 1000
    set_zoom 7
   

    print "Shoot  number", n
    shoot
    n=n+1
    get_zoom r
    print "zoom level", r
    sleep 1000
   
    set_zoom 0

    print "Shoot  number", n
    shoot
    n=n+1

 goto "shot"

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.

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: How to make a script for worst case test of battery life?
« Reply #3 on: 28 / February / 2011, 14:59:51 »
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:

Code: [Select]
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
« Last Edit: 28 / February / 2011, 23:09:40 by SkyWalker9 »


Re: How to make a script for worst case test of battery life?
« Reply #4 on: 01 / March / 2011, 09:35:37 »

Thank you very much?
It's really  cool. I will test it later :)

 

Related Topics