Extended time lapse with Internet connection and power saving - page 12 - General Help and Assistance on using CHDK stable releases - CHDK Forum

Extended time lapse with Internet connection and power saving

  • 123 Replies
  • 36995 Views
*

Offline Sdack

  • ***
  • 195
Re: Extended time lapse with Internet connection and power saving
« Reply #110 on: 30 / May / 2023, 07:00:59 »
Advertisements
Hi Anze,
I don't think I've been here since 2018 and I haven't done any timelapse in nearly as long, so I'm rusty as hell but I've had a lot of generous support on the forum so I'll try to point you in the right direction at least.
If your camera is supported and that's a big IF, I only know about the little point and shoot canon IXUS models, then the way the scripts work is..
  • Put CHDK onto the SD card of your camera (can't actually even remember if there's a special method but if you search around on here you'll find it
  • Set the SD card to be unwritable - this makes the camera read it in a different way and, when it finds the software it will boot into CHDK mode and show you a menu of options
  • If you want to run a script that isn't on the default install, you need to put the SD card in a computer and manually put the script into the scripts folder, so it's present and selectable in the menu once it's in the camera
  • Each script will have a bunch of options, including format / interval / exposure settings etc.
  • If you're wanting to direct connect to a computer via a USB cable, you'll still need the SD card with CHDK on it.
  • I've always used a Raspberry Pi to connect to my IXUSs and the script runs on the Pi, controlling the camera and part of the script tells the camera to send the images direct to a folder on the computer.
  • I'm pretty sure Multilapse is the one I used and it's very reliable.
  • You run Multilapse on the computer and it takes control of the camera
Hope that helps. I'm sure others will be more specific but that's the gist
Cheers and happy snapping
Sdack

*

Offline reyalp

  • ******
  • 14086
Re: Extended time lapse with Internet connection and power saving
« Reply #111 on: 30 / May / 2023, 17:38:39 »
Hi guys, I'm relative new to this (but have experience with CHDK before). I want  to use chdkptp together with timelapse script, but I am confused how exactly to do that.

So, I have Canon G11 powershot camera. I did run a couple of different timelapse scripts, but I don't know how to use it together with chdkptp. My main reason i need chdkptp is to transfer raw (or dng) files directly on a computers hard drive, because SD cards are just to small (raw picture taken every 5s consumes a lot of space).
I installed chdkptp on windows PC an I did transfer files over GUI (chdkptp-r964), but how to do it automatically? I came across multilapse script, but i don't know where to run it (on a raspberry pi or as a script on a camera), since there is no install or usage instructions.
INSTALL.TXT and USAGE.TXT do exist in the zip. Whether they are useful is a different question, but USAGE.TXT should at least give you some starting points. Some pages on the chdkptp assembla site may also be helpful:
https://app.assembla.com/spaces/chdkptp/wiki/CLI_Quickstart
https://app.assembla.com/spaces/chdkptp/wiki/Scripting_Guide

For your use case, there are two general approaches you can use:
1) Run a timelapse script on the camera, and periodically stop shooting to download all the available images. I believe this is the approach sdack used.
2) Run a script that uses remote capture to save the images directly to the PC

Two examples of the second approach
https://chdk.setepontos.com/index.php?topic=14302.0 dolomiti_timelapse used rawopint.lua with a "glue" script to run it from chdkptp remoteshoot

http://escursionisticivatesi.it/webcam/ is based on a chdkptp side script, code at https://github.com/alesanmanoweb/multilapse-CHDK

Quote
Can somebody please help me? I apologize if I posted this in a wrong topic.
Here is fine, I can split the thread later if needed.
Don't forget what the H stands for.

Re: Extended time lapse with Internet connection and power saving
« Reply #112 on: 31 / May / 2023, 01:04:10 »
Thank you both for quick response.
@Sdack: I did play with CHDK before with my canon powershot G11 camera, so I know it works. I even managed to get chdk ptp running under windows os.

@reyalp: Thank you for suggestions, I will test them out and let you know of the results. However, I didn't find INSTALL.txt file inside chdkptp-r964 directory yesterday. There is USAGE.txt and README.txt (read them both).

So, yesterday I installed raspbian on my raspberry pi 2, and I did manage to get chdkptp_gui running successfully. I was getting "could not find libiuplua52.so library" (or something like that), but this file is inside lib directory. Turns out i did not start the script correctly (i initiated it with the command: ./chdkptp_gui). But when I started it with "sh" it worked. I could take a photo and download files from camera. Now I just need to run multilapse script (i want to go with second approach, to run a script that uses remote capture to save the images directly to the PC), so today I will take a closer look at you suggestions and will let you know. Thank you both!

*

Offline reyalp

  • ******
  • 14086
Re: Extended time lapse with Internet connection and power saving
« Reply #113 on: 31 / May / 2023, 01:50:54 »
@reyalp: Thank you for suggestions, I will test them out and let you know of the results. However, I didn't find INSTALL.txt file inside chdkptp-r964 directory yesterday. There is USAGE.txt and README.txt (read them both).
Oops, you're right, it's in SVN but not in the zip  :-[. There's a copy at  https://app.assembla.com/spaces/chdkptp/wiki/Install but it sounds like you shouldn't need it.

Don't forget what the H stands for.


Re: Extended time lapse with Internet connection and power saving
« Reply #114 on: 01 / June / 2023, 00:38:44 »
Yesterday I've tried multilapse script and with some tweaking, it worked!  :D I had to comment LEDS commands (I don't really need them to be off) as I was getting
Code: [Select]
./multilapse: 4: ./multilapse: cannot create /sys/class/leds/led1/trigger: Directory nonexistent error.
But then, when commented, it basically worked. It shoots an image and stored it locally on raspberry pi! Hooray!!  :)

Now, I have just a couple of things to do.

1. Make a samba server on another machine, so RPi can send pictures to that remote location (should be an easy task)
2. Configure multilapse to shoot raw or dng photos (don't know where an how to do that)
3. Configure multilapse to shoot just on specific days in a week and hours (from monday to saturday from 6:00 to 18:00, also don't have a clue)
4. Use turnon and turnoff scripts to control camera power.

For the 4th problem, how exactly did you guys solve this? I have some ideas, for example, remove a camera housing and connect relay instead of power button?
Or, ensure the power button is always on somehow, and then control just power supply?

Some background, I use dummy battery, and there is electrical outlet nearby the location, so camera has enough power, but is the second option (power button always pressed) a reliable one?
Also, how to ensure the script will run a couple of months? I was reading other posts about that, and it was mentioned for stability,  the camera should power on and off each day ...

As for the second and third problem, any help would be much appreciated. I really can't thank you enough!

*

Offline reyalp

  • ******
  • 14086
Re: Extended time lapse with Internet connection and power saving
« Reply #115 on: 01 / June / 2023, 01:37:29 »
Yesterday I've tried multilapse script and with some tweaking, it worked!  :D I had to comment LEDS commands (I don't really need them to be off) as I was getting
Code: [Select]
./multilapse: 4: ./multilapse: cannot create /sys/class/leds/led1/trigger: Directory nonexistent error.
But then, when commented, it basically worked. It shoots an image and stored it locally on raspberry pi! Hooray!!  :)
The multilapse code is from 6 years ago, so differences like that in the raspberry pi OS behavior should be expected.

Quote
2. Configure multilapse to shoot raw or dng photos (don't know where an how to do that)
You can add format options in the remoteshoot commands around line 77 and 80. Use -craw for Canon raw or -dng for CHDK dng, and "help rs" for full details.

Quote
3. Configure multilapse to shoot just on specific days in a week and hours (from monday to saturday from 6:00 to 18:00, also don't have a clue)
You can use a cron job to start it particular times. To stop, you could either add conditions to the main loop (using os.date or os.time to get date/time in Lua).
Or you could use cron to stop it at particular times by sending a signal with kill. multilapse.lua uses the signal module (see the top few lines of the script) so it can gracefully handle SIGHUP and SIGTERM.

Quote
4. Use turnon and turnoff scripts to control camera power.

For the 4th problem, how exactly did you guys solve this? I have some ideas, for example, remove a camera housing and connect relay instead of power button?
Or, ensure the power button is always on somehow, and then control just power supply?
Maybe @manoweb can comment on the details, but my understanding is in that project, the cameras were modified to have the power switch effectively hardwired on, and then the power supply controlled through GPIOs on the pi.

Quote
Some background, I use dummy battery, and there is electrical outlet nearby the location, so camera has enough power, but is the second option (power button always pressed) a reliable one?
Physically holding it pressed may be tricky to do in a way that's both reliable and doesn't cause damage, see https://chdk.setepontos.com/index.php?topic=11434.0
Having it always in the pressed state can also cause some quirks in the Canon OS behavior, but at least with the cameras manoweb used, it didn't cause major problems (the =post_levent_to_ui"UnpressPowerButton" at the top of the script addresses something related to this, but I don't remember exactly what. Maybe something to do with screen / sensor off power saving)

Quote
Also, how to ensure the script will run a couple of months? I was reading other posts about that, and it was mentioned for stability,  the camera should power on and off each day ...
I wouldn't say you need to reboot it every day, but you probably want to reboot periodically (more often than once a month to avoid tick counter wrap at a minimum), and if you are only running from 6:00 to 18:00, it would make sense to have it powered off in between.

The cameras may also stop responding to USB with "communication error" after a certain number of images are shot, even if they're not actually on the card. See https://chdk.setepontos.com/index.php?topic=14446.msg147215#msg147215 for background. I'm not 100% certain, but my memory is this only gets triggered if you're in playback mode with too many images, so remote shooting may be OK.

Ideally, you want to be able to reboot the camera automatically if it crashes or hangs, which multilapse has logic to do if you get the external power supply control working. CHDK and the PTP remote control are hacks based on reverse engineering, so difficult to diagnose stability issues should not be unexpected.
Don't forget what the H stands for.

Re: Extended time lapse with Internet connection and power saving
« Reply #116 on: 01 / June / 2023, 02:53:46 »
Thank you for a quick reply. I am not at home right now, so can't really try all of your suggestions right now.

But regarding canon raw, should it look like this:

Code: [Select]
status, err = cli_cmd('remoteshoot -sd -craw=100000 image')
Will check help rs as soon as I can, but what exactly does -sd and 100000 mean? In CLI Quickstart guide, remoteshoot is mentioned, but not in the detail.
Also, should I add it to line 42 as well?

I did use cron job before, but on a DDWRT router (haha, I guess we are the kind of people, who are just not satisfied with off-the-shelf products  :lol ) I found it difficult to set up.
For my purpose, to simplify things, I just need it to start every day at 6:00 and stop at 18:00. So, I should write bash script, that autostarts every time RPi boots on. It then must check if it should be calling multilapse script (based on what time it is). Am I right or is this too complicated? Then in multilapse script, as you mentioned, I add condition to the main loop.
As I was looking at the code, I should probably add condition to shooting loop instead? Unless I initiate SIGHUP signal, to set restart variable to "true", so we exit the shooting loop?










*

Offline reyalp

  • ******
  • 14086
Re: Extended time lapse with Internet connection and power saving
« Reply #117 on: 01 / June / 2023, 03:15:13 »
Thank you for a quick reply. I am not at home right now, so can't really try all of your suggestions right now.

But regarding canon raw, should it look like this:

Code: [Select]
status, err = cli_cmd('remoteshoot -sd -craw=100000 image')
Will check help rs as soon as I can, but what exactly does -sd and 100000 mean?
The -sd is "subject distance", AKA focus distance, and the 100000 is the distance value so it should stay with -sd rather than being added to -craw

Quote
Also, should I add it to line 42 as well?
Yes.

Quote
For my purpose, to simplify things, I just need it to start every day at 6:00 and stop at 18:00. So, I should write bash script, that autostarts every time RPi boots on. It then must check if it should be calling multilapse script (based on what time it is). Am I right or is this too complicated?
Do you expect the pi to boot every day? Otherwise, you still need some mechanism to run the script every day, and the standard one to do that is cron.

On the other hand, you could just start multilapse at boot, and then modify the loop to not shoot before 6:00 or after 18:00 I guess.

Quote
Then in multilapse script, as you mentioned, I add condition to the main loop.
As I was looking at the code, I should probably add condition to shooting loop instead?
Yes, probably in the inner shooting loop.
Don't forget what the H stands for.


Re: Extended time lapse with Internet connection and power saving
« Reply #118 on: 02 / June / 2023, 02:19:40 »
So, I've been busy yesterday  :)

I did try remoteshoot in cli alone, to test the command. I had to change a couple of things in the script to make it work (naming, .cr2 instead of .jpg and one other thing but can't remember now). I also tried sdmode=MF and set sd distance and it worked!

Then, I dissassembled my camera and soldered two wires where the on/off scwitch is. I connected this two wires on a relay, which is controlled by Raspberry pi. It did sort of work, but now I have a problem. TURNON and TURNOFF scripts a written in a way, that on/off button is pysically always on, and we controll power suply with the relay instead. But we controll ON/OFF button on a camera. The difference is, button needs to be presed and then released to make a change. I think I'll hardwire power switch (always ON) and control power supply with relay. Based on a code in turnon and turnoff scripts I think this is how @manoweb  did it.

I also ran into an eror: I/O error. I suspect this is because when camera is turned off and then back on again, raspbian os initiates automount of some sort: it pops up a window to confirm what would i like to do with detected usb device. How can I disable this? I think this is the reason for I/O error, but I'm not 100% sure. Will post exact error message when I get home.

*

Offline reyalp

  • ******
  • 14086
Re: Extended time lapse with Internet connection and power saving
« Reply #119 on: 02 / June / 2023, 03:37:57 »

Then, I dissassembled my camera and soldered two wires where the on/off scwitch is. I connected this two wires on a relay, which is controlled by Raspberry pi. It did sort of work, but now I have a problem. TURNON and TURNOFF scripts a written in a way, that on/off button is pysically always on, and we controll power suply with the relay instead. But we controll ON/OFF button on a camera. The difference is, button needs to be presed and then released to make a change. I think I'll hardwire power switch (always ON) and control power supply with relay. Based on a code in turnon and turnoff scripts I think this is how @manoweb  did it.
It seems like scripting the button action should be pretty straightforward, you just need to hold it on for some brief period, which could just be a shell script the sleeps for a second or something.

However, since the powering off with the power button is a software thing, for some kinds of errors you'd still want to cut the power completely. It is possible to hang the camera in such a way it doesn't respond to the power button but remains on until you physically remove power.

Quote
I also ran into an eror: I/O error. I suspect this is because when camera is turned off and then back on again, raspbian os initiates automount of some sort: it pops up a window to confirm what would i like to do with detected usb device. How can I disable this? I think this is the reason for I/O error, but I'm not 100% sure. Will post exact error message when I get home.
See the discussion of udev under "Interactions with default software" in https://app.assembla.com/spaces/chdkptp/wiki/Install

The section mentioning "ENV{GPHOTO2_DRIVER}" should be what you need to prevent that from activating.

FWIW, if you install the "lite" raspberry pi os image, it doesn't come with any of the gphoto automount stuff (or a GUI, but you can add one). Not saying you should start over with that, just a data point.
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal