How to best use CHDK-PTP for stable time-lapse system in Amazon forest?

  • 7 Replies
  • 2018 Views
Advertisements
Firstly, I need to mention that I am a bare neophyte when it comes to programming, which has been making my attempts at figuring this problem out much more difficult.  So explanations and examples that work up from the very basics will be greatly appreciated.

I am a graduate student in ecology trying to build a stable, self-contained time-lapse camera system to monitor forest canopy leaf dynamics in the Brazilian Amazon.  The barebones of what I need to do is:

1.) Capture .dng images at set intervals from a CHDK hacked camera (I'm currently working with the ELPH 500 HS).

2.) Insure that these images are accurately timestamped to time set by a GPS clock (for syncing to time series data from a PAR light sensor).

3.) Automatically transfer these images to a large hard drive.  This transfer could be by directly saving to the hard drive, or periodically transferring from the SD card followed by removal of the images copied over (i.e. endless memory type setup).

The system will be housed in a waterproof enclosure with external power (already designed and implemented).  It needs to be able to be left unattended for months at a time, so I need to make it as robust and stable as possible.

Preferably capture timing would be similar to that currently implemented in the Ultimate Intervalometer script ( http://chdk.wikia.com/wiki/Ultimate_Intervalometer ).  My first approach has been to try to use the CHDKPTP ( https://www.assembla.com/spaces/chdkptp/wiki/Home ) running on a Raspberry Pi (Raspbian OS), and the ultimate.lua script.  GPS time could then be also set on the Raspberry Pi, and which would then need to be used daily to set the camera clock.

However, I have not been able to figure out how to consistently start and stop ultimate.lua from the CLI interface of CHDKPTP.  Nor is it clear to me whether it is possible to create an automatic and stable system to stop the script at the end of each day, copy .dng images to an external hard drive connected to the RPi, clear images from the SD card, then start the cycle again the next day.

It seems like a better approach may be to somehow use the remoteshoot functionality via the CLI interface of CHDKPTP, combined with Linux’s crontab scheduler.  This would do away with the need to transfer images from the CF card to the external HD, as well as the GPS time stamp issue (as the RPi local time will be already set to a GPS clock).

However, I don’t know how to go about writing code for a fixed scheduler that would either:

a.) start CHDKPTP (via crontab), connect to the camera, specify the filepath to an external HD, take one .dng, disconnect the camera, then repeat this all day with one camera restart per day;

or:

b.) Once per day start a script via crontab and CHDKPTP that would run within the CHDKPTP CLI interface all day, taking images at a fixed interval, then shut down and restart the camera at the end of the day.

Any suggestions for how to most easily use CHDK and CHDKPTP to create a system with these functions will be greatly appreciated.
« Last Edit: 24 / June / 2014, 18:38:19 by photosynthesis »

a.) start CHDKPTP (via crontab), connect to the camera, specify the filepath to an external HD, take one .dng, disconnect the camera, then repeat this all day with one camera restart per day;
Give that you have a functioning Pi with a GPS dongle of some sort it would probably be best to not spend any time playing with CHDK scripting.   Sounds like all you need are a two command line scripts that run from crontab - one to do a "remoteshoot" and one to do a "restart"?

Ported :   A1200    SD940   G10    Powershot N    G16

Hello Waterwingz,

Yes, I have a functioning RPi, with GPS time and an automatic UPS powerdown/restart system.

I believe you are correct about the easiest solution being command line scripts.

I actually just got the remoteshoot command working with the following: chdk_wrapper.sh -i -c -e"rec" -e"rs -dng" -e"q"

However, -e"q" is not successfully terminating the CHDK-PTP connection.  Any thoughts?

Also, in the future I would very much like to implement multiple bracketed exposures by calling on an hdr.lua script.  I have one that works well for my purposes ( http://chdk.wikia.com/wiki/Ultra_HDR_Script ), but when I try to make it run via the CHDKPTP CLI using, for example, ".m=0; n=8; a=1; e=0; r=Enable; loadfile ("CHDK/SCRIPTS/UltraHDR.lua")()", in the command line I get a message saying "ERROR: . failed", and on the camera console a message saying "l value ***TERMINATED*** :80: attempt to call a nil value"

Strangely, yesterday I was able to get the ultimate.lua script running from the CHDK CLI, although I still got that same error message.

Of course, I would still need to figure out a way for these interval exposures to run, but save directly to the RPi external HD rather than the CF card...
« Last Edit: 24 / June / 2014, 21:39:32 by photosynthesis »

*

Offline nafraf

  • *****
  • 1303
I actually just got the remoteshoot command working with the following: chdk_wrapper.sh -i -c -e"rec" -e"rs -dng" -e"q"

However, -e"q" is not successfully terminating the CHDK-PTP connection.  Any thoughts?
Remove the -i option (interactive cli):
Code: [Select]
chdkptp -c -e'rec' -e'rs -dng'


Yes, I have a functioning RPi, with GPS time and an automatic UPS powerdown/restart system.
The only tricky bit might be getting the camera to power up.  You probably don't want to rely on it running for weeks on end if you don't have to - even with daily restarts.  The current thinking here on the forum is to rig a clamp that holds the On/Off button down permanently.  Then cycle the external power using a small relay or other circuit driven by the Pi or your UPS powerdown/restart system?

Quote
I believe you are correct about the easiest solution being command line scripts. I actually just got the remoteshoot command working with the following: chdk_wrapper.sh -i -c -e"rec" -e"rs -dng" -e"q"   However, -e"q" is not successfully terminating the CHDK-PTP connection.  Any thoughts?
CHDKPTP uses a special command line language called RPIL  ( reported to mean reyalp's ptp interface language).  Reyalp is the expert and although it's not too complicated,  I always find myself stumbling over the exact syntax so I'll leave it for him to weigh in when he comes by later tonight.

Quote
I have one that works well for my purposes ( http://chdk.wikia.com/wiki/Ultra_HDR_Script ),
Glad you like it.


Quote
but when I try to make it run via the CHDKPTP CLI using, for example, ".m=0; n=8; a=1; e=0; r=Enable; loadfile ("CHDK/SCRIPTS/UltraHDR.lua")()", in the command line I get a message saying "ERROR: . failed", and on the camera console a message saying "l value ***TERMINATED*** :80: attempt to call a nil value"  Strangely, yesterday I was able to get the ultimate.lua script running from the CHDK CLI, although I still got that same error message.
See my second comment above.

Quote
Of course, I would still need to figure out a way for these interval exposures to run, but save directly to the RPi external HD rather than the CF card...
There are probably a lot of ways you can do this.  For instance. you can add a bit of code to the script to watch for
USB messages and send back information about the names of the most recent DNG files. Or use remoteshoot(), examine the EXIF info in the resulting image and then issue more remoteshoot() commands with the Tv,Sv, and Av values specified.   Or you could ask reyalp to add an Ev adjust value to the remoteshoot command.  I'm sure there are other choices too - that's with 10 seconds of thought.

« Last Edit: 24 / June / 2014, 22:37:35 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online reyalp

  • ******
  • 11491
Also, in the future I would very much like to implement multiple bracketed exposures by calling on an hdr.lua script.  I have one that works well for my purposes ( http://chdk.wikia.com/wiki/Ultra_HDR_Script ), but when I try to make it run via the CHDKPTP CLI using, for example, ".m=0; n=8; a=1; e=0; r=Enable; loadfile ("CHDK/SCRIPTS/UltraHDR.lua")()", in the command line I get a message saying "ERROR: . failed", and on the camera console a message saying "l value ***TERMINATED*** :80: attempt to call a nil value"
There are (at least) two problems here:
1)
r=Enable
isn't correct, you need to give whatever number that corresponds to.
@values r Ignore Disable Enable
means that ignore is 0, disable is 1 and enable is 2.

2)
loadfile ("CHDK/SCRIPTS/UltraHDR.lua")()
For require and other camera side lua functions, you need to specify the full path starting with A/, like A/CHDK/SCRIPTS/UltraHDR.lua
Don't forget what the H stands for.

Hello Reyalp,

I apologize, the missing "A/..." was a typo.  So it is actually " loadfile('A/CHDK/SCRIPTS/UltraHDR.lua')() "

Changing 'Enable' to the corresponding number fixed the problem and I can now successfully start the script from the CHDKPTP CLI.  However, strangely I still always receive the "ERROR: . failed" message in the CLI.

Do you have any thoughts on how to capture at intervals (such as crontab or ultimate.lua would allow) with bracketed exposures (like UltraHDR allows), but save directly to an external HD of a RPi, getting the timestamp metadata from the RPi clock?

In any case, many thanks (to everyone here) for the great feedback!

*

Online reyalp

  • ******
  • 11491
Changing 'Enable' to the corresponding number fixed the problem and I can now successfully start the script from the CHDKPTP CLI.  However, strangely I still always receive the "ERROR: . failed" message in the CLI.
I'd guess you are using CHDKPTP r592. If this is true, you can update to r599 to avoid this message.
Don't forget what the H stands for.


 

Related Topics