CHDK Motion Detect Plus Script
To enable a vertical column on the right side choose
Region: In
Start Column: 3
End Column: 3
Start Row: 1
End Row: 3
To enable the top two rows choose
Region: In
Start Column: 1
End Column: 3
Start Row: 1
End Row: 2
To enable a vertical column on the left side choose
Region: In
Start Column: 1
End Column: 1
Start Row: 1
End Row: 3
Bonus Tip
With the region set to 2 (Out) the motion detection script will exclude motion from the active grid box. This allows you to define the unselected areas as the place where motion will be detected.
52 Responses to “CHDK Motion Detect Plus Script”
Leave a Reply
Note: Comments will have spelling errors corrected before they are posted. If you have a specific question please provide your email address so I can send you a direct reply.




I have tried without success to access the code from my memory card. I have a Canon SX40HS. I take a photo, I then go to the play, displaying the photo, I turn on my camera then press function set and disp at the same time, nothing happens.
Anybody know what I am doing wrong?
You need to have CHDK installed and loaded before you are able to use the Motion Detect Plus Script. Once CHDK is running on your camera you can then load the Motion Detect Plus Script in the CHDK ALT menu using the Scripting Parameters window.
A handy way to install CHDK on your memory card so it boots automatically is to use the Cardtricks utility:
http://chdk.wikia.com/wiki/CardTricks
To open the CHDK ALT menus you need to press the shortcut button on your Canon SX40HS camera. For more details on how to use CHDK with your specific camera model look in the readme.txt file that came with your copy of CHDK.
Regards,
Andrew Hazelden
I have just installed CHDK on my SX40HS, and run your script. Once motion is detected it seems to continue to take shots. Is there a way to limit the number of shots or time period please?
Ideally I would like it to detect a bird landing on a rock, take shots while it is perched, then stop and reset when the bird flies off (and be ready for the next bird landing)
Is this possible please?
Hi Jon.
I did some testing this morning with the CHDK Motion Detect Plus script.
If the image review feature is turned on there appears to be an issue where the script takes photos continuously after the first motion detect trigger. On my camera a simple fix for this problem is to turn off the image review feature in the Canon menu. This will result in the camera taking a single photo when it detects motion.
Regards,
Andrew Hazelden
Hi Andrew
That seems to have solved the problem - thanks.
Two further questions though please;
1) Is it possible to use the script with high speed burst mode (8fps)?
2) I tested the script this afternoon, and when I returned to the camera after 30 minutes it had powered down (with the lens still out)I have the power save option set to off, but maybe you can suggest what I may have done wrong.
Thanks again
Jon
Hi Jon.
1. It would be possible to modify the LUA script to take a series of photos once a motion event is detected.
2. If the camera is off with the lens out, either your camera battery died or CHDK locked up. Eject the battery and put it back in to reboot the camera.
This morning I set up my Canon Powershot camera for an all day motion detection test. To power the camera I'm using an ACK-DC10 external power supply module with a dummy battery module.
Hi there. Thanx for your script and your time/work Andrew Hazelden.
Unfortunately this script does not work correctly on ixus 220 aka elph 300hs.
"There appears to be an issue where the motion detection function doesn't reset for the next photo unless the image review mode is disabled. To disable the image review feature, open the main Canon menu by pressing the menu button on your camera. Scroll down to the option labeled Review and set it to Off."
Even if I set review to OFF. The problem persists.
I have the latest stable build: ixus220_elph300hs-100c-1.0.0-1892-full_ALPHA
Hi Frojnd.
Thanks for your message.
I'm interested in hearing more about the Motion Detection Plus script issue on the Canon IXUS 220 camera. Could you describe what happens when you try to run the script? Does the software get stuck in a continuous photo taking loop?
Regards,
Andrew
Hi Andrew!
My problem is similar to Frojnd´s.
I have the canon sx40 with the last chdk and the camera keeps shooting until shooter pressed. Review is off, AF beam is off.
Thank you.
Hi Frojnd.
It appears the issue you are experiencing is due to the script's motion detection "trigger sensitivity" threshold. I have an updated script that has a lower default sensitivity and provides control over the parameter.
After I run a camera test on my lawn for a day to make sure it works I will post the improved script.
Hi Armando & Frojnd.
I have posted a new version of the Motion Detect Plus script. Hopefully this update will work better on the Canon Powershot sx40 and IXUS 220 cameras.
Thank you very much, Andrew!
Thanks for the great script love it. How can I mod the script to take multi-shots when motion is detected? Thanks.
Hi Todd.
I will add a multi-shot feature to the next version of the Motion Detect Plus script. It might be a few days before I get around to it.
Regards,
Andrew
Dear Andrew
I have downloaded you script Motionp.lua (Thank you for making that possible).
My camera is a Cannon sx40hs.
I have the same problem like Armando, my camera keeps on shooting after the first picture until shutter is pressed.
Review is set to Off.
AF beam is set to Off.
Can you help ?
Best regards:
Tom Jensen.
Hi Tom.
Try increasing the Motion threshold value. This will reduce the camera's sensitivity and stop the camera from taking continuous photos. Open the CHDK scripting parameters window and adjust the script's Motion Threshold value to a higher number. You could try a higher value like 36 to see if it helps.
Regards,
Andrew
Dear Andrew.
Thank you for your quick reply. I went up to 40 but it did not help. Any idea of what else I can try?
Best regards:
Tom Jensen.
Tom,
Try setting your camera from continuous mode to single shot mode. If that doesn't help you could try setting the CHDK options back to their defaults by going to the CHDK Miscellaneous Stuff menu and selecting Reset Options to Default...
Dear Andrew.
Thank you very much.That solved all my problems.
Best regards:
Tom Jensen.
I'm still having trouble with the lag of the motion detection. When I tested it by waving my hand in front, it didn't take the picture until well after my hand had already passed. I have turned off all the AF stuff as well as the picture review. Did I miss something?
Hi Rich.
It might be possible to speed up the Motion Detect Plus script's responsiveness using the CHDK lightning detection scripts as reference. There are a few parameters that have to be balanced so a motion detection script doesn't go in a continuous photo taking cycle.
Regards,
Andrew
Hi, I have a Canon 720IS camera I have installed the script but I have a problem. When the camera detect motion. The camera don´t make the photo, it takes about ten seconds. My question is The camera can to make the photo when detect motion? In this moment no after ten seconds.
Thanks
Luis
I have downloaded you script Motionp.lua
Thank you for publishing the script.
My camera is a Cannon PowerShot S2 IS running chdk "s2is-100f-1.1.0-2079-full"
I have a similar problem like Armando. My camera keeps on shooting after the first picture until shutter is pressed. This would be indoors.
Review is set to Off.
AF is set to single
AF beam is set to Off.
I've tinkered with the Motion threshold from 12, 24, 36 and even 40.
What am I missing?
Thanks,
Matthew H
Hi Mathew.
I updated the Motion Detect Plus script to version 0.3. This should fix the motion threshold issue.
Regards,
Andrew
I was having problems with the script not working with my S3 powershot - multiple shots taken once motion occurred. Didn't seem to matter what threshold I used - once triggered, wouldn't stop taking shots. I made a change to the script which has fixed the problem - change the variable zones to mot. Prior to doing this, I added a line in the script to display the value of zones to see what it was doing when motion detected, and it would return a number based on how many zones had detected motion, so would always remain >0.
To fix, open the script in notepad and change all instances of the word zones to mot in the lower part of the program.
Anyway, an easy fix which may work for others having trouble getting it to work currently on their cameras. What I don't understand is why the script works on some but not all cameras.
Regards,
Paul
Hi Paul.
Thanks for your comment and tip. Would you be able to send me a copy of your revised script so I can test the changes on my Canon PowerShot SD780IS? My email address is andrewhazelden@gmail.com
Regards,
Andrew Hazelden
There is absolutely no way to make this work on the ELPH300 HS...I have tried EVERY possible combination of setting, camera setting, etc. No matter what, the camera is ALWAYS stuck in a continuous loop.
Hi Bryan,
Try adding sleep(250) as a new line after the line print(q .. " Shots Taken" ) near the end of the program. You may also need to increase the value a bit if it still false triggers - perhaps sleep(500) or more, but 250 fixed mine. My post above seemed to work for some scenes, but not for others. Since adding the sleep line, I have not had any further issues with false triggering after initial motion detection.
Regards,
Paul
I played around with this on my S3 IS today and FINALLY got it to stop continuously shooting. The trick: Put a sleep() after the shoot().
I changed my script around to take in an interval - param e. I then put a sleep() in for the same amount of time after the shoot(). e is expressed in 1/4 seconds. (e = e*250)
I don't know if it needs to sleep that long. I don't know if there's a constant value that would work. But as soon as I put the sleep in things settled down. I was able to use very low threshold values with no problem.
Hi. I updated the Motion Detect Plus script to version 0.3.1. This build includes the suggestions from Paul H on how to reduce the continuous photo issue and adds a "Number of Shots" attribute that Todd Higgins was interested in.
Regards,
Andrew Hazelden
Hi, I'm still getting the continuous shot issue. Mine is an SX40 HS and no matter what I do the loop continues.
All AF settings off, I've had the motion threshold up to 70 still the same.
Any ideas as to what this may be?
Hi Andy.
Try turning off image review in the Canon menu.
Also, could you try setting your SX40 HS camera to take the photos in single shot mode?
Try set the script shoot delay (.1s) to 5 or upwards.
Hi Andrew,
Your Motion Detect Plus works great on my sx40hs, thank you very much. I had previously started to download another before realizing it was uploaded in 2008! I liked the easily variable sensitivity, and the grid with active/inactive squares, and the shot count on the scree. On one day only the count continued to display; albeit only for a fraction of a second; throughout all of the afternoon whilst taking over 70 normal manual photo's, which I liked, however I have tried but I have not been able to repeat this effect.
Whilst using your script on my sx40 I tried it with 'Movie Digest' enabled, and most of the time it worked well, although sometimes freezing CHDK and shutting the camera down with lens extended. I have not yet determined the consistent differences between settings for those shots that continued to detect motion and take a photo and a 'Movie Digest', and those which froze CHDK.
'Movie Digest' on the sx40 is an interesting mode which saves a short film starting 2 to 4 seconds BEFORE the 'take a photo' button is pressed!! AND happily responds also to a CHDK simulated 'button pressed'. Unfortunately the film saved is only 640 x 480, but when coupled with your Motion Detection script it ALMOST GUARANTEES a film of the event which triggered the photo, be it a lightning flash or something else very fast!
I don't think 'Movie Digest' is much good for its stated purpose; an optional brief audio recording filed with the photo would be much better; but used as an adjunct to motion-detected image capture it is VERY useful.
Are you aware of that excellent shortcut someone (sorry, don't have his name) just highlighted?: a half-press of the 'take a pic' button plus a left press of the rocker dial takes several cameras; including the sx30 and the sx40; straight into 'Manual Focus' mode and focused where the Auto mode set it!
Thanks again.
Bill
Hi Bill.
I'm happy to hear the Motion Detect Plus script works on your camera. I haven't had a chance to personally use a Canon Powershot sx40 yet but the new Movie Digest feature sounds interesting.
Regards,
Andrew
Andrew, I am trying to run the Motion Detect Plus script on an IXUS 100, but when I try to run the script, it does not start up the camera. Any ideas ?
Andy
Hi Andy.
What build of CHDK are you running? After you load the script in the CHDK Script menu you have to click the camera's shutter button to start running the Motion Detect Plus script.
Hi Andrew, thanks for getting back to me, I am running the latest version of CHDK, ixus100_sd780-100c-1.1.0-2447-full_BETA.zip, and the latest Motion Detect Plus script.
I start up CHDK, and have the motion detect script as autostart. It comes up and says it is about to start before you press the shutter button!
Should I switch off the autostart? I see from reading your blog that you have the same camera, albeit an American version.
Thanks
Andy
Hi, just tried it with autostart switched off, and I can now press the shutter release to power it up. When I press the Alt button, I get Motion Detect Plus in the bottom left corner, then when I press the shutter release button, it displays the 3 seconds to start message, then the "Starting" message, then the LCD switches off, and it appears dead, but with the lens out and open!
Andy
Hi Andy.
The Motion Detect Plus script expects the camera to be in photo mode to work. Since the Ixus 100 starts in playback mode that is what causes the error.
In the next version of the script I will look into adding code to verify the camera is in photo mode before starting.
Regards,
Andrew
Hi, presumably you have the same issue on your SD780. How do you get around it on there?
Andy
Hi Andy.
I installed CHDK on the camera's SD card and set it to boot when the card is in 'locked mode'.
I start my Canon SD780IS camera in review mode and then switch the camera over to photo mode. At this point I enable the ALT mode by tapping the DISP button quickly. With the ALT mode text onscreen I start the Motion Detect script by pressing the shutter button.
Sorry if I am being thick here, but would that not stop the card from being usable if it is locked, or does CHDK get round that?
Should I try and make mine bootable?
Andy
Andy,
CHDK uses the lock state switch on the SD card to enable/disable booting. In this mode the camera can still write to the SD card.
The CHDK wiki has a good page on enabling booting on your SD card:
http://chdk.wikia.com/wiki/Prepare_your_SD_card
I am using an SX260 HS with your Motion Plus script. I have turned off focus assist beam, auto focus continuous, autostart is off, continuous shooting is off, I am using CHDK build 2542. My camera shoots continuously, until I stop it and never fires with motion, just when I push the button. Other people are having success with your script, so I know it works. Shouldn't it also work with mine?
Hi Norman.
Could you try changing the
sleep(250)setting on line 167 tosleep(1000). This will give your Powershot SX260HS camera time to pause between each motion detect cycle.Thanks for the suggestion, Andrew, but it did not work. I changed the sleep setting to 1000 and it did the same thing, shot 5 exposures and waited, then started on another set of 5 when I approached the camera to interrupt the script.
Hi Andrew,
Thanks so much for your motion detector. Amazing that this can work in a point and shoot. I have a Wingscapes Bird Cam, which is a bit of a disappointment, and I'm very exciting about potentially getting bird pictures with your program. I'm using an SD1200 IS.
Please pardon the naive mix of questions -- I'm a total newbie at this and an old guy, making it even worse. Here goes:
1. Under Script, I don't know what number to use for parameters
2. Under Extra Photo Operatons, I don't know how what to set for disable override, autobracket, and value factor.
3. Under Misc Stuff, I don't know what to set Disable LCD.
It gets worse. For the camera itself, does auto vs. program mode make a difference?
No matter what I set the threshold at, the pictures take several seconds to fire and the actual motion may take several seconds or more to start the sequence.
The camera shuts down and no longer senses about 45 seconds after the last picture. I haven't yet gotten an external power supply, so maybe that will make the difference?
Finally, when you make a parameter change, is there a save function? Sometimes the changes are there the next time I work on it, while sometimes the changes have gone away.
Again, my sincere apologies for this huge list of questions, and I thank you again for your program and what seems to be your infinite patience. I am working on a newbie cheat sheet that I'll send you for using for inquiries from any similar old strugglers such as myself as soon as I fine tune things a bit.
Best, Joel
Hi Andrew,
Got some of the above straightened out. The prolonged time taken between shots was due to inadvertent setting of RAW imaging, which causes a long delay between shots with the SD1200. Also, I now have an external power source and have built a housing using a Plano dry box, and that is working well.
Still need some help with the rest of the questions, although it seems to be working much better for the most part without knowing what I'm doing...
Thanks for your help.
Joel
Andrew,
Should have added that with the external power supply, the camera no longer shuts down until I turn it off.
Thanks again. Joel
Hi Joel.
I'm glad to hear your camera is working better with the motion detect script.
If you would like to read more about shutter speed overrides you can check out this blog post CHDK Shutter Speed Overrides Explained.
If you are using the same photo overrides between multiple power ON/OFF cycles you may want to turn off the clear overrides @ start option in the Extra Photo Operations menu.
I would suggest you lock the camera into a the program mode. It is a good idea to select a white balance setting like sun, cloud, tungsten, etc... so the white balance doesn't change during the duration of your image recording session.
The easiest way to disable the LCD is to plug in the composite video output cable for your camera. This will tell the camera to turn off the LCD display. (You don't have to plug the other end of the cord into anything.)
Regards,
Andrew
I have tried both your program (motionp) and the one it is based on (motion) on a Canon S95 in manual mode with manual focus for hummingbirds coming to my feeder.
"motion" will take the shot, only one of course. "motionp" will also take the shot(s), however if the subject does not stay in the AF frame it refocuses the lens to objects in the background rather than holding the MF. I tested this by first focusing close on my hand and then triggering each of the programs by moving my hand through and out of the grid field. "motion" holds the BG in a blur, but "motionp" refocuses to the BG.
I see that all your a-z are the same as the original program. What could be doing this?