Assignment 0: Until The End Of Time

In this very simple project, you are going to make your PowerShot behave like a really smart digital stopwatch.

A Really Short Project Using CHDK Lua Scripting

Once activated, your Lua script, until.lua, should measure how long it takes to see a change in the scene it is pointed at. Thus, for example, if you start the script at the beginning of a race with the camera pointed at the finish line, it will record the precise time that somebody arrives at the finish line. There are a few details....

Although it would be easy to have the camera do things like count down and fire the strobe to start the race, you don't have to do that here. In fact, your script doesn't even have to show the elapsed time while it is waiting -- it just needs to display the elapsed time when it sees the scene change. That time should be displayed in minutes, seconds, and 1/10ths of a second. For example, a time of 62.3 seconds should display as 1:02.3 and 12 seconds should display as 0:12.0.

Inside CHDK, you can read the current time as an integer in 1/1000s unit using get_tick_count(), so it's quite easy to measure the difference between two times. It is a little harder to print that number in the notation I've specified because CHDK doesn't support floating point, but not too hard when you think about it as separate formulas for computing each digit of the fractional seconds display.

That leaves the incredibly complex issue of how to detect when the scene the camera is watching has changed. Fortunately, there is an evil little function you can use for that called md_detect_motion(), which takes a whopping 16 arguments! No problem. I'm going to tell you what each should be. In order, the arguments should be:

That function will not return until it either times out or sees motion -- and you should assume it returned because it saw motion.

There should be two parameters to your script that can be set by the script user:

Stuff To Know About

Obviously, the first step is loading CHDK into your camera. You don't need to build CHDK from sources in order to run your own Lua scripts.

You probably have never used Lua before. It's ugly, but fairly powerful. The CHDK version is only missing a few features, most notably floating-point arithmetic, from the full Lua language and has many additional CHDK-specific functions. There are a number of Lua scripts that you can and should use as references for how to do what you need to do. Be aware that most scripts are not written in Lua, but uBASIC -- they will not be so helpful, and many are old and/or specific to particular camera models.

To make things easier, I've created a reference card for CHDK Lua which you can get from here.

Due Dates, Submission Procedure, & Such

Before you can submit anything, you must register with the class server.

You will be submitting source code (for your Lua script, until.lua), a make file (which does nothing much for this project), and a very short, simple HTML-formatted, "implementor's notes" document that discusses any issues in implementation or problems with functionality. In that document, be sure to also briefly answer the question: Does the motion detect sensitivity really need to be changed for different lighting conditions? The CHDK documentation for md_motion_detect() suggests it does, but our application is really expecting a pretty large change, so maybe we can just keep sensitivity low (e.g., use a relatively high number like 36).

For full consideration, your project should be submitted no later than September 27, 2016. Submit your .tar or .tgz file here:

Your email address is .
Your password is

Which type of student are you?
Undergraduate registered for EE599
Graduate registered for EE699 Cameras as Computing Systems