2008-05-26

My Mac talks to the HF100

If you're tired of going into the menu over and over again just to set something there's a solution. Let your Mac do it. All you need is a ZephIRTM. This USB device enables you to use your computer to control almost any piece of equipment designed for infrared remote control. You can train it's software to simulate any remote control and on top of that everything can be controlled via AppleScript.

My ZephIR arrived today and after an hour of "training" and trial and error my HF100 listens carefully to my Mac. I recorded all of the 20 buttons of the Canon WL-D88 wireless controller and also submitted the component to the ZephIR data base.To download it open the ZephIR application, click on "WebztIR" then navigate to Canon > Camera > HF100_WL_D88 and double-click the remote (you must be connected to the internet).

For instance the following command would toggle the on-screen displays:

fire zephir command "DISP" of component "Canon HF100 WL-D88"

The really interesting thing is that the supplied software allows to build custom remotes with buttons that execute a batch of AppleScript commands at once. To get a reliable response I recommend adding a delay before fireing a subsequent command.

If you use File > Open Dictionary in the Script Editor and select the ZephIR application you'll see that it offers a repeating and delaying option:

fire zephir command v : Send a fire command to the ZephIR™.
fire zephir command text : name of command
of component text : the target component
[repeating integer] : override the designated repeat count of the code (minimum 1, maximum 35)
[delaying integer] : wait the number of ticks (60 ticks per second) before firing (minimum 0, maximum 300,default is 10)
→ text : The reply returns a status string if the request fails otherwise it is empty.

Below is a first try which allows to set normal autofocus or instant autofocus with a single mouse click. All I have to do is to make sure that the ZephIR aims at the remote sensor of the HF100 before I press a button. Watching the ZephIR wading through the menus is fun and about ten seconds later the new AF mode is set. Note that the connection depends on a light path and that the ZephIR acts blindly. If there's an interruption in the connection either through bad placement or by unintentionally concealing the connection you'll end up anywhere in the menu. Also note that the following example is for the HF100. The HF10 let's you choose between the SD card and the internal memory so there may be one additional menu item. Adjust the code accordingly.

The AppleScript for setting iAF looks like this:

(*SET iAF*)
fire zephir command "MENU" of component "Canon HF100 WL-D88"
fire zephir command "RIGHT" of component "Canon HF100 WL-D88" delaying 120
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "SET" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "UP" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "SET" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "MENU" of component "Canon HF100 WL-D88" delaying 60

As you can see the required AppleScript is straightforward and the possibilities are numerous. Everything you can do with the wireless controller can be simulated and even more.

Controlling a timelapse recording where the HF100 takes a photo every minute for one hour requires just four lines of AppleScript. Note that storing a photo takes about 4 seconds so the minimum possible interval is 5s.

(*TIME LAPSE*)
repeat 60 times
   fire zephir command "PHOTO" of component "Canon HF100 WL-D88"
   delay 60
end repeat

The HF100 only offers a two second SELF TIMER delay when it is triggered by the wireless controller. You also have to activate the SELF TIMER in the menu before each and every recording. The following code allows one-click self timed recordings with a delay of 10 seconds. The "beep sound" is the actual system alert sound which can be altered in the OS X System Preferences.

(*SELF TIMER*)
repeat 10 times
   beep
   delay 1
end repeat
beep 2
fire zephir command "START-STOP" of component "Canon HF100 WL-D88"

How's about a remote controlled 10s recording?

(*TIMED RECORDING*)
fire zephir command "START-STOP" of component "Canon HF100 WL-D88"
delay 10 + 1
fire zephir command "START-STOP" of component "Canon HF100 WL-D88"

Smooth computer controlled zooming is now easy (set the zoom speed to the slowest speed ">" in advance):

(*ZOOM IN*)
fire zephir command "ZOOM T" of component "Canon HF100 WL-D88" repeating 35 delaying 1

Precise focus shift or rack focus (press set and toggle to FOCUS first). The correct repeating number must be found by trial and error:

(*FOCUS SHIFT*)
fire zephir command "UP" of component "Canon HF100 WL-D88"
fire zephir command "RIGHT" of component "Canon HF100 WL-D88" delaying 60 repeating 20

The following code initalizes the card (use it with caution!):

(*INITIALIZE CARD*)
display dialog "This will initialize the card. Continue?" 
fire zephir command "MENU" of component "Canon HF100 WL-D88"
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 120
fire zephir command "RIGHT" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "SET" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "SET" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "DOWN" of component "Canon HF100 WL-D88" delaying 60
fire zephir command "SET" of component "Canon HF100 WL-D88" delaying 60
delay 5
display alert "The card has been initialized." 
fire zephir command "SET" of component "Canon HF100 WL-D88"
fire zephir command "MENU" of component "Canon HF100 WL-D88" delaying 60

The ZephIR application itself is scriptable. A slightly altered version of the 10s recording example above would look like this in Apples Script Editor (or any application that supports AppleScript):

AppleScript is very powerful just take a look at the AppleScript Language Guide for details. Right now I'm only scratching the surface.

Next you can see the AppleScript integrated into an Automator workflow that copies the recordings to your computer. Unfortunately you can't access the SD card in recording mode. You must manually switch to playback mode and connect the USB cable. The camcorder turns into a "dumb" harddisk and only becomes responsive again when you eject the camera and disconnect the USB cable. Considering this it's far easier to take the SD card out and put it into a card reader.

So far I only controlled recording but imagine using the ZephIR connected to a MacBook Air to control a High-Def presentation delivered by the HF100.

No comments: