KAP & UAV Exposure Control Intervalometer Script - page 35 - Completed and Working Scripts - CHDK Forum

KAP & UAV Exposure Control Intervalometer Script

  • 1068 Replies
  • 408153 Views
Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #340 on: 11 / March / 2015, 12:21:19 »
Advertisements
Hello, I made a few modifications to the v3.3 KAP_UAV script (for CHDK v1.3). My focus was to adapt the script to flying a fixed wing with pixhawk autopilot and a cheap hobbyking relay adapter (using the scripts "PWM" mode).

Changelog vs stock 3.3:
- Added an option to use the external USB timer when reading USB pulse widths ("set_remote_timing" command)
- Added an option to stop the script after X minutes (useful to ensure the lens will retract if I cannot signal the script to stop)
- Added a buffer to the log routine, in order to prevent write delays on slow SD cards. The Log is written every 0.1 second
- Removed a limitation that prevented the camera to power off when setting "Total Shots" param to 0 (infinite shots)
- Customized the pwm_mode to suit my needs: a short pulse signals "shoot", and a longer pulse signals "stop script" (mission end)
- Added logging in a few places, the most interesting place is in the "pwm_mode(pulse_width)" function, it now logs the measured pulse width (useful for debugging purposes when using a cheap relay with poor timing control)


I hope somebody finds my modifications useful!
Naccio

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #341 on: 11 / March / 2015, 18:22:04 »
Hello, I made a few modifications to the v3.3 KAP_UAV script (for CHDK v1.3). My focus was to adapt the script to flying a fixed wing with pixhawk autopilot and a cheap hobbyking relay adapter (using the scripts "PWM" mode).

Changelog vs stock 3.3:
- Added an option to use the external USB timer when reading USB pulse widths ("set_remote_timing" command)
- Added an option to stop the script after X minutes (useful to ensure the lens will retract if I cannot signal the script to stop)
- Added a buffer to the log routine, in order to prevent write delays on slow SD cards. The Log is written every 0.1 second
- Removed a limitation that prevented the camera to power off when setting "Total Shots" param to 0 (infinite shots)
- Customized the pwm_mode to suit my needs: a short pulse signals "shoot", and a longer pulse signals "stop script" (mission end)
- Added logging in a few places, the most interesting place is in the "pwm_mode(pulse_width)" function, it now logs the measured pulse width (useful for debugging purposes when using a cheap relay with poor timing control)
Nice! 

I've actually been circulating a 3.4 beta version that has a set_remote_timing(1000) command included (but not optional).   When I release the 3.4 update I'll add your logging changes (per the MarkB conversation earlier in this thread this probably needs to use a longer interval than 10 seconds) and the shutdown after "n" minutes option.   I'll add your name to the script credits too.

FWIW, I'm also working on a GUI option (something like the ultimate intervalometer uses) :


even though nobody will see it when the kite/uav is airborne.

I'm currently thinking of waiting until CHDK 1.4.0 is release all of this - the improved memory handling and better script parameter options are probably worth the wait and that way I don't have to retest everything twice.

Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #342 on: 21 / March / 2015, 14:41:44 »
Firstly, thanks to all for this script, it looks like it will do *exactly* what I need it to :)

I'm having am issue getting it to run reliably on my Canon A560 (CHDK v1.3 installed). The time-lapse photos work fine, the first video is triggered fine but the script seems to crash when it should revert back to time-lapse photos.

There is an error message displayed on the screen:

Quote
:133 attempt to index global 'log' (a nil value)

I have logging enabled for the script (screen and SD card), I don't know much about the 'logging' process though - I can see a 'LOG' folder in the CHDK folder but it is empty (perhaps it's trying to write to a file that doesn't exist?)

Any assistance on resolving this issue would be much appreciated!

Thanks,

Adam

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #343 on: 21 / March / 2015, 15:12:14 »
I have logging enabled for the script (screen and SD card), I don't know much about the 'logging' process though - I can see a 'LOG' folder in the CHDK folder but it is empty (perhaps it's trying to write to a file that doesn't exist?)
The log file is actually stored in the root of the SD card (the top level directory folder) rather than the LOG folder.   It is called KAP.log.  If you can find that and post it here, it will make fixing this much easier.

Thanks.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #344 on: 21 / March / 2015, 16:44:53 »
Thanks for the reply, the output in the KAP.log file is below:

2015MAR21 20:37:09 KAP 3.3 started - press MENU to exit
2015MAR21 20:37:09 CHDK 1.3.0-4043 a560 100a Mar  4 2015
2015MAR21 20:37:09 Mode:AUTO,Continuous_AF:0,Servo_AF:17
2015MAR21 20:37:09  Tv:1/100 max:1/2000 min:10 ecomp:0.0
2015MAR21 20:37:09  Av:4.0 minAv:2.8 maxAv:8.0
2015MAR21 20:37:09  ISOmin:100 ISO1:400 ISO2:800
2015MAR21 20:37:09  MF mode:0  Video:1 USB:0
2015MAR21 20:37:10  AvM:2 int:15 Shts:5 Dly:0 B/L:0
2015MAR21 20:37:10 setting zoom to 0 percent step=0
2015MAR21 20:37:16 1) IMG_5329.JPG
2015MAR21 20:37:16  meter : Tv:1/8 Av:2.8 Sv:200 -213:-213
2015MAR21 20:37:17  actual: Tv:1/5 Av:- Sv:800
2015MAR21 20:37:17          AvMin:2.8 NDF:NDout foc:1.1m
2015MAR21 20:37:28 Video mode started. Button:false

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #345 on: 21 / March / 2015, 17:13:43 »
Thanks for the reply, the output in the KAP.log file is below:
As it happens,  I too have an A560 and get the same crash (which doesn't happen with my S100 or A1200 or G10).

I'll see what I can find out.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #346 on: 21 / March / 2015, 18:12:26 »
Okay - found the problem.  Not really sure why it's camera specific but adding a short delay after releasing the shutter button when halting video cures the problem.

Test script here :  xkap_uav.lua
Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #347 on: 22 / March / 2015, 07:46:33 »
Hello Waterwingz ,

I am using this script since a lot of time and it's working great!

I'm using it on a S100 camera for photomapping purposes , in order to geotag the pictures I need to do a correlation between the hour/minute/second when the picture was done and the hour/minute/second when my autopilot recorded the corresponding coordinates.

My autopilot records 4 time per second the coordinates (longitude,latitude,altitude) , so for 1 picture I have 4 possible locations. To be easier to geotagg the image with the right values is possible to have also on KAP.log file the second divided to 4 or 2 timeframes ? So to have HH/MM/SS/xx where xx represent 00 / 25 /50 /75 th of a second ?

Also , to better understand , the hour recorded in the log is the hour when:
- the picture is recorded on the memory card;
- camera start to focus to take the picture;
-the script gives the "command" to the camera to take the picture ?

Thank you.


Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #348 on: 22 / March / 2015, 10:25:36 »
I'm using it on a S100 camera for photomapping purposes , in order to geotag the pictures I need to do a correlation between the hour/minute/second when the picture was done and the hour/minute/second when my autopilot recorded the corresponding coordinates.
Just curious here - do you use the S100's GPS capability here?  Or is it too slow / inaccurate to be useful?

Quote
My autopilot records 4 time per second the coordinates (longitude,latitude,altitude) , so for 1 picture I have 4 possible locations. To be easier to geotagg the image with the right values is possible to have also on KAP.log file the second divided to 4 or 2 timeframes ? So to have HH/MM/SS/xx where xx represent 00 / 25 /50 /75 th of a second ?
The camera's system clock only provides the time to a one second resolution and that's what the script currently uses.  The internal tic timer is more accurate - it works in 10 mSec increments.  There have been several discussions about this on the forum :

link > EXIF timestamp with milliseconds precision from GPS
link > Display time with milliseconds
link > Need help with script that can show timestamp in recorded video file.

and it looks like philmoz may have actually implemented a tic time 10 msec accuracy time stamp that gets save in the EXIF tags in CHDK DNG files.  In the last link,  fudgey found that just adding the tic timer to the system clock value seemed to stay sync'd as well.

So if you are using CHDK DNG files you already have pretty much as accurate a timestamp as CHDK / Canon is going to be able to produce.  Although I suppose we could go one more step and use the recently discoverd high precision timers to go down to 1 mSec or better with some more CHDK core coding work.

The drawback to using DNG files of course is the extra time it takes to store them - which will slow down your maximum shot rate quite a bit.

So having said all that,  I think it might be possible learn from what philmoz did and implement better resolution in kap_uav.lua by using reyalp's new script shooting hooks (hook_shutter()).  I'm not sure how good the absolute accuracy of the timestamps would be but the relative accuracy from one to the next should be pretty good.

Would that work?

Quote
Also , to better understand , the hour recorded in the log is the hour when:
- the picture is recorded on the memory card;
- camera start to focus to take the picture;
-the script gives the "command" to the camera to take the picture ?
I'm afraid it's pretty much your first case.  The time stamp is when the actual log file entry is record in the log.  Which happens after quite a bit of additional code that collects shot data and formats it.   That has not been a problem to date but it would be trivial to record the actual time stamp at the moment the shutter is commanded to release.  With a bit more work (see my comments above) the script raw shooting hooks could get even closer to when the actual image is taken.
« Last Edit: 22 / March / 2015, 10:46:13 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #349 on: 22 / March / 2015, 12:21:03 »
I did a little more playing with this idea of combining the tic timer and the os system time.  Wrote a script to do that and had it periodically check that the rollover from 990 mSec to 000 mSec happens in sync with the OS time.

Looks pretty good on the cameras I tested - including my S100 and my very old A560.

I guess that makes sense though.  The camera likely only reads the current date & time from the RTC chip at power-up.  After that,  the tic timer maintains the date & time so it will by default be sync'd with the reported time!

So without over thinking this,  I think I can easily add this to the script and use the hook_shutter() function to give me about 20 mSec of resolution on the exact time the camera starts each shot.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics