CHDK Wiki
Register
m (typo)
Tag: Source edit
 
(82 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{| align="right" style="border-collapse:collapse; font-size: x-small;"
+
{| style="border-collapse:collapse; font-size: x-small;" align="right"
 
| __TOC__
 
| __TOC__
 
|}
 
|}
''Using just an inexpensive push button switch, a converted USB cable, and a small battery, you can construct a remote device that will allow you to control the operation of your CHDK-enabled camera.''
+
''Using just an inexpensive push button switch, a converted USB cable, and a small battery, you can construct a remote device that will allow you to control the operation of your CHDK-enabled camera. If you want software control over USB, see [[PTP Extension]]''
   
 
==Background==
 
==Background==
[[File:Usbr.png|thumb|left|100px|USB Remote]]
+
[[File:Usbr.png|left|100px|USB Remote]]
 
Since its earliest inception, CHDK has provided a simple method of operating a Canon P&S camera from a remote switch connected to the camera's USB port. Built-in functionality allowed basic "press half" and "press full" actions - with the additional ability to synchronize the release of the shutter between multiple camera connected to a common control unit. There was also a limited remote zoom functionality, useful for coordinating the zoom position when many cameras were connected together.
 
Since its earliest inception, CHDK has provided a simple method of operating a Canon P&S camera from a remote switch connected to the camera's USB port. Built-in functionality allowed basic "press half" and "press full" actions - with the additional ability to synchronize the release of the shutter between multiple camera connected to a common control unit. There was also a limited remote zoom functionality, useful for coordinating the zoom position when many cameras were connected together.
   
Line 14: Line 14:
 
The current CHDK version of USB remote operation introduced a modular concept for the selection of what device is connected to the camera and how the camera reacts to that device. A logic block diagram is shown below - click to obtain a full-size view.
 
The current CHDK version of USB remote operation introduced a modular concept for the selection of what device is connected to the camera and how the camera reacts to that device. A logic block diagram is shown below - click to obtain a full-size view.
   
[[File:Usb_remote_logic_diagram_large.png|thumb|322px|USB Remote Logic Diagram]]In operation the state of a remote device connected to the USB port is converted to one the following states:
+
[[File:Usb_remote_logic_diagram_large.png|800px|USB Remote Logic Diagram]]
  +
  +
In operation the state of a remote device connected to the USB port is converted to one the following states:
   
 
*switch released
 
*switch released
Line 22: Line 24:
 
*switch full pressed
 
*switch full pressed
   
and action is taken based on the output module selected via the CHDK Remote menu. In addition, values indicating number of activations (pulse count) and a duration of each activation (pulse width / pulse gap) is also maintained for use by CHDK scripts.
+
and action is taken based on the output module selected via the CHDK Remote menu.
  +
  +
In addition, values indicating number of activations (pulse count) and a duration of each activation (pulse width / pulse gap) is also maintained for use by CHDK scripts.
  +
  +
<br style="clear: both" />
   
 
==Supported Hardware ==
 
==Supported Hardware ==
[[File:Usb_cable_release_v2_0_800.png|thumb|130px|Homemade Switch]]
+
[[File:Usb_cable_release_v2_0_800.png|right|130px|Homemade Switch]]
 
CHDK now supports the use of several different remote control devices to control a set of camera shooting functions.
 
CHDK now supports the use of several different remote control devices to control a set of camera shooting functions.
[[File:Ricon_ca-1.jpg|thumb|130px|Ricoh CA-1]]
+
[[File:Ricon_ca-1.jpg|right|130px|Ricoh CA-1]]
 
For basic shooting functions, a simple switch can be used to provide 3V-5V from set of batteries to the USB connector power pin on the jack on your camera. Details about how to build such a device can be found below.
 
For basic shooting functions, a simple switch can be used to provide 3V-5V from set of batteries to the USB connector power pin on the jack on your camera. Details about how to build such a device can be found below.
   
Line 35: Line 41:
 
A list of sources for USB remote switch devices is posted at the bottom of this page : [[USB_Remote_V2#Links|Links]] .
 
A list of sources for USB remote switch devices is posted at the bottom of this page : [[USB_Remote_V2#Links|Links]] .
   
===Homemade USB remote cable===
+
===Homemade USB Remote Cable===
   
 
A popular method for remotely triggering CHDK-enabled cameras involves constructing a simple triggering device from a 3V CR2032 coin battery, a USB extension cable, and a push switch. The camera's USB cable is then attached to the camera at one end and to the triggering device by the other end.
 
A popular method for remotely triggering CHDK-enabled cameras involves constructing a simple triggering device from a 3V CR2032 coin battery, a USB extension cable, and a push switch. The camera's USB cable is then attached to the camera at one end and to the triggering device by the other end.
Line 51: Line 57:
 
Here's a different schematic, click for a larger view :
 
Here's a different schematic, click for a larger view :
   
[[File:0001_USB_Remote_Shutter_Wiring_Diagram_-1.jpeg|thumb|left|640px|Alternate USB Remote Schematic Diagram]]
+
[[File:0001_USB_Remote_Shutter_Wiring_Diagram_-3.jpeg|left]]
  +
<br style="clear: both" />
   
  +
===Note: combined USB & Video Connector===
 
'''Note :''' newer Powershots now have a combined USB + video connector; to use both video and USB remote feature a "splitter" cable is necessary.
+
Newer Powershots now have a combined USB + video connector; to use both video and USB remote feature a "splitter" cable is necessary.
 
*http://www.achillies.com/CHDK_Files/USB_Splitter.htm
 
*http://www.achillies.com/CHDK_Files/USB_Splitter.htm
 
*http://chdk.setepontos.com/index.php?topic=294.msg64551#msg64551
 
*http://chdk.setepontos.com/index.php?topic=294.msg64551#msg64551
 
 
The HTC splitter is actually wired correctly for the usb and video composite cable but the non standard shields do not fit the body of the camera or allow the video cable into the connector. You can alter the connector to fit the body if you are VERY CAREFUL and pry off the male connector shield and shave off the edge to fit the camera, then, open the case and pry open the non standard square looking female connector to allow the canon video cable to fit, then press the case back together. Works very well no soldering small parts. Just be careful prying it apart.
 
The HTC splitter is actually wired correctly for the usb and video composite cable but the non standard shields do not fit the body of the camera or allow the video cable into the connector. You can alter the connector to fit the body if you are VERY CAREFUL and pry off the male connector shield and shave off the edge to fit the camera, then, open the case and pry open the non standard square looking female connector to allow the canon video cable to fit, then press the case back together. Works very well no soldering small parts. Just be careful prying it apart.
  +
<br style="clear: both:" />
   
   
   
===Homemade USB remote cable with wireless adapter===
+
===Homemade USB Remote Cable with Wireless Adapter===
[[File:IMG_2336.jpg|thumb|364px]]
+
[[File:IMG_2336.jpg|364px|right]]
To make a CHDK remote that will allow you to also connect a Canon wireless remote you need modifiy things a little bit.
+
To make a CHDK remote that will allow you to also connect a Canon wireless remote you need modifiy things a little bit. [[User:Colon247|Colon247]] added a 2.5mm jack with 3 connectors, so you can use Canon 2.5mm wireless remote by plugging it into the jack and bypassing the CHDK remote circuit.
   
  +
<br style="clear: both:" />
[[User:Colon247|Colon247]] added a 2.5mm jack with 3 connectors, so you can use Canon 2.5mm wireless remote by plugging it into the jack and bypassing the CHDK remote circuit.
 
   
[[User:Colon247|Colon247]] uploaded a full size image of his prototype original. You can go much smaller but he decided he would upload this image so you can see how it is all connected.
 
   
.
 
   
  +
<br style="clear: both:" />
.
 
   
==Enabling USB Remote operation==
+
===Improvised USB Remote Using a USB Charger===
[[File:USB_Remote_01.png|thumb|250px]]
+
[[File:CHDK-Improvised-Remote USB-Charger.jpg|364px|right]]
  +
If you own a portable USB charger with a USB A output, you can use it as an improvised USB remote for CHDK. Simply utilize your regular USB cable that you would have used to connect your camera to your computer. In many cases, this is a plain and inexpensive USB A to Mini USB B cable.
To enable USB remote operation, go to the CHDK Remote parameters menu and select Enable Remote.
 
   
  +
The sequence of turning the charger on and off again will create a "OnePush" event (see below). Configured this way, the CHDK camera will auto-focus when turning the switch to the “on” position, and then take the photo when turning the switch back to the "off" position.
When this option is selected, the USB port on the camera will no longer be available for uploading picture files or ptp operations.
 
   
  +
While this is certainly kind of clumsy, as you will need to flick a switch back and forth instead of just pressing a button, with a bit of exercise this also works quite nicely for bracket shots.
   
  +
This is by far sufficient for your first experiments with CHDK's USB remote functionality. You can purchase other inexpensive battery driven "USB Emergency Charger" devices :  [http://www.youtube.com/watch?v=NicNGwm0c3E video link here]
   
  +
===Alternative inputs===
  +
As of CHDK 1.5, some CHDK ports support alternative hardware inputs in addition to the USB port. If available, alternate inputs will be listed under "Input Channel" in the remote menu, described below. The other settings, logic and script function generally behave the same regardless of input. These inputs may be useful when the USB port is used for other purposes, or when supplying an external +5V is inconvenient.
   
  +
Support for these is currently limited to a few models, but is easy to add on cameras with the required hardware, so please request [https://chdk.setepontos.com/index.php?board=6.0 in the forum] if you want this feature on a camera that doesn't currently support it.
   
  +
'''Note : ''' The alternate inputs have different electrical requirements from the standard USB remote. Consult the forum threads linked below for more information.
   
   
  +
<br style="clear: both:" />
   
  +
==Enabling USB Remote operation==
==Switch Types==
 
[[File:USB_Remote_02.png|thumb|250px]]
+
[[File:USB_Remote_01.png|250px|right]]
  +
To enable USB remote operation, go to the CHDK Settings > Remote Parameters menu and select Enable Remote.
   
  +
'''Note : '''When this option is selected, the USB port on the camera will no longer be available for uploading picture files or PTP operations.
===None===
 
Default setting at start-up. Indicates that no USB device is to be monitored. Useful when a script will be interacting with the USB port.
 
   
  +
<br style="clear: both" />
   
  +
==Input Channel==
  +
[[File:USB_Remote_InputCH-01.png|250px|right]]
  +
===USB===
  +
Standard USB +5v, as documented above.
   
   
Line 100: Line 117:
   
   
  +
[[File:USB_Remote_InputCH-02.png|250px|right]]
  +
===HDMI HP===
  +
HDMI hotplug detect. On models with an HDMI connector, the remote can be triggered by connecting the HDMI +5v and HDMI hotplug detect pins. [https://chdk.setepontos.com/index.php?topic=13451.0 Forum thread]
   
   
[[File:USB_Remote_03.png|thumb|250px]]
 
===OnePush===
 
Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch initiates a "full-press" state for 100 mSec. There is no mechanism to cancel a "half-press" once this sequence is started. Also note that the "half press" will timeout after 10 seconds even if USB power is still applied.
 
 
   
   
   
[[File:USB_Remote_04.png|thumb|250px]]
+
[[File:USB_Remote_InputCH-03.png|250px|right]]
===TwoPush===
+
===ANLG AV===
  +
Analog AV detect. On models where standard def video out is combined with the USB port (Canon adapter AVC-DC400/AVC-DC400ST) the remote can be triggered by grounding the detect pin. [https://chdk.setepontos.com/index.php?topic=13451.0 Forum thread]
Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch and then immediately pressing the again switch in less than 1/2 second initiates a "full-press" state. Full press state continues while the switch is held. Failing to immediately press the switch the second time will cancel the sequence.
 
   
   
   
   
[[File:USB_Remote_05.png|thumb|250px]]
 
===CA-1 ===
 
Used with a Ricoh CA-1 switch device. Half pressing the button causes the CA-1 to create a 30 mSec pulse that initiates a "half press" state. Releasing the switch at that point will generate 2x30 mSec pulses that cancel the shooting sequences. Full pressing the button will create a 150 mSec pulse that will initiate a "full press" state for 100 mSec.
 
   
  +
[[File:USB_Remote_InputCH-04.png|250px|right]]
  +
===A/D CH===
  +
Battery thermistor A/D. On models with a Canon proprietary Lithium battery, the battery temperature terminal can be used to trigger the remote. The remote is triggered by a specific resistance on the terminal. [https://chdk.setepontos.com/index.php?topic=10385.msg112252#msg112252 Forum thread]
   
   
Line 125: Line 141:
   
   
==Control Modes==
 
CHDK control modes support the translation of input device activation sequences into specific camera operations.
 
   
  +
==Switch Types==
[[File:USB_Remote_06.png|thumb|250px]]
 
  +
[[File:USB_Remote_02.png|250px|right]]
  +
 
===None===
 
===None===
  +
Default setting at start-up. Indicates that no USB device is to be monitored. Useful when a script will be interacting with the USB port.
Tells CHDK to do nothing with switch inputs. Allows the input devices to operate - useful for scripting modes.
 
   
   
Line 136: Line 152:
   
   
  +
[[File:USB_Remote_03.png|250px|right]]
  +
===OnePush===
  +
Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch initiates a "full-press" state for 100 mSec. There is no mechanism to cancel a "half-press" once this sequence is started. Also note that the "half press" will timeout after 10 seconds even if USB power is still applied.
   
   
   
[[File:USB_Remote_07.png|thumb|250px]]
+
[[File:USB_Remote_04.png|250px|right]]
===Normal===
+
===TwoPush===
Reacts to the state of the input device. On half press it places the camera in "half press" mode to focus, set exposure and flash settings. On full press it places the camera in "full press" mode to take the actual photograph.
+
Also used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch and then immediately pressing again in less than 1/2 second initiates a "full-press" state. Full press state continues while the switch is held although the picture will be taken on entry to full press state. Failing to initiate the second press within 1/2 second will cancel the sequence.
Supports sync mode - see below.
 
   
   
   
  +
[[File:USB_Remote_05.png|250px|right]]
  +
===CA-1 ===
  +
Used with a Ricoh CA-1 switch device. Half pressing the button causes the CA-1 to create a 30 mSec pulse that initiates a "half press" state. Releasing the switch at that point will generate 2x30 mSec pulses that cancel the shooting sequences. Full pressing the button will create a 150 mSec pulse that will initiate a "full press" state for 100 mSec.
   
  +
<br style="clear: both" />
   
  +
==Control Modes==
[[File:USB_Remote_08.png|thumb|250px]]
 
  +
CHDK control modes support the translation of input device activation sequences into specific camera operations.
  +
  +
===None===
  +
[[File:USB_Remote_06.png|250px|right]]
  +
Tells CHDK to do nothing with switch inputs. Allows the input devices to operate - useful for scripting modes.
  +
<br style="clear: both" />
  +
  +
===Normal===
  +
[[File:USB_Remote_07.png|250px|right]]
  +
Reacts to the state of the input device. On half press it places the camera in "half press" mode to focus, set exposure and flash settings. On full press it places the camera in "full press" mode to take the actual photograph.
  +
Supports sync mode - see below.
  +
<br style="clear: both" />
   
 
===Quick===
 
===Quick===
  +
[[File:USB_Remote_08.png|250px|right]]
 
Causes the camera to immediatly enter shooting mode (focus, exposure, flash) and take a picture immediately on the occurance of a "half shoot". Useful for automation projects where the picture should occur as quickly as possible after some condition is detected.
 
Causes the camera to immediatly enter shooting mode (focus, exposure, flash) and take a picture immediately on the occurance of a "half shoot". Useful for automation projects where the picture should occur as quickly as possible after some condition is detected.
   
<span style="font-style: normal; ">Sync not curently available in this mode.</span>
+
<span style="font-style: normal; ">Sync not currently available in this mode.</span>
  +
<br style="clear: both" />
   
 
 
 
 
 
[[File:USB_Remote_09.png|thumb|250px]]
 
 
===Burst===
 
===Burst===
  +
[[File:USB_Remote_09.png|250px|right]]
Cause the camera to enter continuous shooting mode while a half press is active. Similiar to the built in camera continuous function except that it does not reset each time the camera power is removed.
 
  +
Cause the camera to enter continuous shooting mode while a half press is active. Similiar to the built in camera continuous function except much slower and it does not reset each time the camera power is removed.
   
<span style="font-style: normal; ">Sync not curently available in this mode.</span>
+
<span style="font-style: normal; ">Sync not currently available in this mode.</span>
  +
<br style="clear: both" />
   
   
 
 
 
[[File:USB_Remote_10.png|thumb|250px]]
 
 
===Bracket===
 
===Bracket===
[[File:USB_Remote_11.png|thumb|250px]]
+
[[File:USB_Remote_10.png|250px|right]]
 
 
Uses the CHDK ''Bracketing in Continuous Mode'' settings on each half press / full press operation, changing the bracketing setting on each shot. Times out after 5 seconds of no operations. Useful for bracketing operations as it does not require settting up camera continuous mode or timer settings, which clear after each camera power cycle.
 
Uses the CHDK ''Bracketing in Continuous Mode'' settings on each half press / full press operation, changing the bracketing setting on each shot. Times out after 5 seconds of no operations. Useful for bracketing operations as it does not require settting up camera continuous mode or timer settings, which clear after each camera power cycle.
   
Line 179: Line 206:
   
 
Sync not available in this mode.
 
Sync not available in this mode.
  +
<br style="clear: both" />
 
 
===Zoom===
 
===Zoom===
  +
[[File:USB_Remote_11.png|250px|right]]
 
 
Uses the built-in pulse counting capability of the USB remote code to control zoom operations. The following action happens for the listed pulse counts.
 
Uses the built-in pulse counting capability of the USB remote code to control zoom operations. The following action happens for the listed pulse counts.
1 pulse = zoom out one step
+
1 pulse = zoom in one step
2 pulses = zoom in one step
+
2 pulses = zoom out one step
 
3 pulses = shoot
 
3 pulses = shoot
4 pulses = zoom completely out
+
4 pulses = zoom completely in
5 pulses = zoom completely in
+
5 pulses = zoom completely out
 
Note : pulses needs to be "on" for longer than 100 mSec, "off" for longer than 50 mSec and a 500mSec gap indicates the end of the counting period.
 
Note : pulses needs to be "on" for longer than 100 mSec, "off" for longer than 50 mSec and a 500mSec gap indicates the end of the counting period.
   
 
Sync not currently available in this mode
 
Sync not currently available in this mode
  +
<br style="clear: both" />
   
 
===Video===
 
===Video===
[[File:USB_Remote_12.png|thumb|250px]]
+
[[File:USB_Remote_12.png|250px|right]]
 
 
If camera is in video shooting mode, activates filming on the first half press. Stops filming on the next half press.
 
If camera is in video shooting mode, activates filming on the first half press. Stops filming on the next half press.
   
Line 200: Line 227:
   
 
<span style="font-style: normal; ">Sync not curently available in this mode.</span>
 
<span style="font-style: normal; ">Sync not curently available in this mode.</span>
  +
  +
<br style="clear: both" />
   
 
==Multi-Camera Synchronization==
 
==Multi-Camera Synchronization==
  +
[[File:USB_Remote_13.png|thumb|250px]]
 
 
===Enable Sync===
 
===Enable Sync===
[[File:USB_Remote_14.png|thumb|250px]]
+
[[File:USB_Remote_13.png|250px|right]]
   
A useful application of CHDK is the ability to connect two or more cameras together via a common USB cable so that their operations can be synchronized. The fact that the cameras are connected in parallel ensures that things happen at approximately the same time. To achieve better synchronization when taking an actual photograph, CHDK has the ability to stop the picture taking process immediately before the image is actually captured. This allows CHDK on several cameras to focus, adjust exposure, setup the flash and then wait for a shared signal to complete the shot (i.e. sync). If the Enable Sync option is set in CHDK then each camera will wait for the final transition of the USB signal ( 5V to 0V ) before shooting.  Note : the camera will wait a maximum of 10 seconds for the sync signal.  Waiting any longer results in unpredictable bad camera behaviour.
 
   
  +
A useful application of CHDK is the ability to connect two or more cameras together via a common USB cable so that their operations can be synchronized. The fact that the cameras are connected in parallel ensures that things happen at approximately the same time. To achieve better synchronization when taking an actual photograph, CHDK has the ability to stop the picture taking process immediately before the image is actually captured. This allows CHDK on several cameras to focus, adjust exposure, setup the flash and then wait for a shared signal to complete the shot (i.e. sync). If the Enable Sync option is set in CHDK then each camera will wait for the final transition of the USB signal ( 5V to 0V ) before shooting.  Note : the camera will wait a maximum of 10 seconds for the sync signal.  Waiting any longer results in unpredictable bad camera behaviour.
  +
<br style="clear: both" />
 
===Enable Sync Delay===
 
===Enable Sync Delay===
  +
[[File:USB_Remote_14.png|250px|right]]
  +
 
To more precisely tune the synchronization between cameras, CHDK allows a precise fixed delay to be added to each camera to adjust for differences in the time each camera takes to finish shooting a picture. The sync delay value is given in units of 0.1 mSec.
 
To more precisely tune the synchronization between cameras, CHDK allows a precise fixed delay to be added to each camera to adjust for differences in the time each camera takes to finish shooting a picture. The sync delay value is given in units of 0.1 mSec.
  +
<br style="clear: both" />
  +
[[File:USB_Remote_15a.png|250px|right]]
  +
Notice in the example pictures the use of the "range multiplier" function in the upper right corner of the screenshot - used to more easily change the delay adjustment value. The range multiplier is changed in ALT mode using the zoom in / zoom out keys.
  +
<br style="clear: both" />
  +
'''Developer's note :''' the USB remote code includes optional code that can be used to calibrate the sync delay units precisely for each camera.
  +
<br style="clear: both" />
   
  +
==Other Settings==
[[File:USB_Remote_15a.png|thumb|250px]]
 
   
  +
===Enable Script Start===
  +
[[File:USB_Remote_16.png|250px|right]]
  +
Tells CHDK to activate the currently loaded script when the USB remote performs a full press. Useful for repetitive activation of a script without needing to press the shutter button.
  +
<br style="clear: both" />
   
  +
===Bracketing in Continuous Mode===
  +
[[File:USB_Remote_17.png|250px|right]]
  +
A menu link to provide convenient access to the bracketing parameters used in USB remote bracketing mode.
   
  +
<br style="clear: both" />
   
  +
==USB Remote Timing Diagrams==
  +
[[File:Usb_remote_v2_timing_diagram_medium.png]]
   
  +
==​Scripting Interface==
  +
===is_key "remote"===
  +
*state of the USB port 5V pin can be queried as any other camera key
  +
*this function works whether or not USB remote mode is enabled.
  +
while 1
  +
wait_click 1
  +
if is_key "remote" then shoot
  +
wend
   
   
  +
===get_usb_power===
Notice in the example pictures the use of the "range multiplier" function in the upper right corner of the screenshot - used to more easily change the delay adjustment value. The range multiplier is changed in ALT mode using the zoom in / zoom out keys.
 
  +
USB Remote V2 provides extensive scripting functionality using the ''get_usb_power()'' function. 
   
  +
'''Note :''' Although the function is named get_usb_power, it applies to the currently selected remote input.
(Developer's note : the USB remote code includes optional code that can be used to calibrate the sync delay units precisely for each camera.)
 
   
  +
====get_usb_power(0)====
==Other Settings==
 
   
  +
*returns the pulse width of the most recent USB power activation and clears that value. 
===Enable Script Start===
 
  +
*USB remote must be enabled for this function to work
[[File:USB_Remote_16.png|thumb|250px]]
 
  +
do
Tells CHDK to activate the currently loaded script when the USB remote performs a full press. Useful for repetitive activation of a script without needing to press the shutter button.
 
  +
p = get_usb_power 0
  +
until p>0
   
   
  +
====get_usb_power(1)====
   
  +
*returns the current state of USB power ( 0=off, 1=on)
  +
* this function works whether or not USB remote mode is enabled.
  +
do
  +
p = get_usb_power 1
  +
until p>0
   
   
  +
====get_usb_power(2)====
   
  +
*returns the buffered pulse width or pulse gap timing.  Width values are positive, gap values are negative.
  +
*USB remote must be enabled for this function to work
  +
do
  +
p = get_usb_power 2
  +
until p>0
   
   
  +
====get_usb_power(3)====
[[File:USB_Remote_17.png|thumb|250px]]
 
===Bracketing in Continuous Mode===
 
A menu link to provide convenient access to the bracketing parameters used in USB remote bracketing mode.
 
   
  +
*returns the count of pulses since that last time the function was called. Function return 0 when no pulses are receive in the previons 1 second. 
  +
*USB remote must be enabled for this function to work 
  +
do
  +
p = get_usb_power 3
  +
until p>0
   
   
  +
====set_remote_timing(uSec)====
  +
( CHDK 1.3.0 or newer only - originally called enable_remote_hp_timer() in early releases of 1.3.0)
   
  +
Standard measurement of USB pulse widths is performed by the USB remote task based on the assumption that it runs every 10 mSec.  However, variations in this interval - especially when the camera is in shooting mode - are possible and can result in poor timer accuracy.   The set_remote_timing() command enables the use of a higher precision timer for these measurements. This time does not depend on task "tic timer" accuracy,  providing a much more stable and reliable source for the measurement of pulse width and space information.
   
  +
The parameter passed to the function specifies the rate at which the <span style="font-size:14px;">USB pulse will be sampled in uSeconds.  Valid values are 1000 and larger.</span>
   
  +
===Sample Lua test script===
   
  +
----
   
  +
<syntaxhighlight lang="lua">
  +
--[[
  +
@title USB Tester
   
  +
@param m Mode
==USB Remote Timing Diagrams==
 
  +
@default m 0
[[File:Usb_remote_v2_timing_diagram_medium.png]]
 
  +
@values m State Width Pulses Count Key
   
  +
--]]
==Scripting Interface==
 
USB remote V2 provides extended functionationality when using the get_usb_power() function This new functionality is backwards compatible with the get_usb_power function in the stable version of CHDK..
 
   
  +
function printf(...)
while 1
 
  +
local tic = get_day_seconds()
wait_click 1
 
  +
print (string.format("%02d:%02d:%02d %s", tic/3600, tic%3600/60, tic%60, ...))
if is_key "remote" then shoot
 
  +
end
wend
 
   
  +
mode = m
  +
set_console_layout(1, 1, 44, 10)
   
  +
print("USB remote test started")
Calling function get_usb_power with no parameters ( or parameter = 0 ) returns the pulse width of the most recent USB power activation and clears that value.
 
  +
if(mode == 1) then mstr="pulse width"
  +
elseif (mode ==2) then mstr="pulses"
  +
elseif (mode ==3) then mstr="pulse count"
  +
elseif (mode ==4) then mstr="key"
  +
else mstr="state" end
  +
print(" test mode : "..mstr)
  +
print("Press MENU to exit")
   
  +
set_config_value(121,1) -- make sure USB remote is enabled
do p = get_usb_power 0 until p>0
 
   
  +
usb_state=-1
  +
rkey=0
   
  +
repeat
Calling function get_usb_power with parameters = 1 returns the current state of USB power ( 0=off, 1=on)
 
  +
now = get_day_seconds()
   
  +
-- check USB state ?
do p = get_usb_power 1 until p>0
 
  +
if ( mode == 0 ) then
  +
new_state = get_usb_power(1)
  +
if ( new_state ~= usb_state ) then
  +
printf("state="..new_state)
  +
usb_state=new_state
  +
end
  +
end
   
  +
-- check USB pulse width ?
  +
if ( mode == 1 ) then
  +
x=get_usb_power(0)
  +
if ( x > 0 ) then printf("width ="..(x*10).." mSec") end
  +
end
  +
  +
-- check USB pulse train?
  +
if ( mode == 2 ) then
  +
x=get_usb_power(2)
  +
if (x ~= 0 ) then
  +
if ( x > 0 ) then printf("mark ="..(x*10).." mSec")
  +
else printf("space="..(-1*x*10).." mSec") end
  +
end
  +
end
   
  +
-- check USB pulse count ?
In addition, it is also possible to return the most recent count of pulses received and a buffered list of pulse width and pulse gap information :
 
  +
if ( mode == 3 ) then
  +
x=get_usb_power(3)
  +
if ( x > 0 ) then printf("count="..x) end
  +
end
   
  +
wait_click(100)
do p = get_usb_power 2 until p>0
 
   
  +
-- read USB as a camera key ?
returns a buffered pulse width or pulse gap value (width values are positive, gap values are negative)
 
  +
if ( mode == 4 ) then
  +
if (is_key("remote")) then
  +
if (rkey==0) then
  +
printf("remote pressed")
  +
rkey=1
  +
end
  +
else
  +
if (rkey==1) then
  +
printf("remote released")
  +
rkey=0
  +
end
  +
end
  +
end
   
  +
until is_pressed("menu")
do p = get_usb_power 3 until p>0
 
   
  +
set_config_value(121,0) -- make sure USB remote is disabled
returns the most recent number of pulses in a window (terminates after 1 second of inactivity)
 
   
  +
</syntaxhighlight>
NOTE : changing the yield value used by the script ( see [[Script_commands#set_yield|set_yield]] ) will change the minimum and maximum timing for pulse counts and will change the measured pulse width value. You will need to calibrate these values for each set_yield change you make.
 
  +
  +
  +
----
  +
  +
  +
'''NOTE :''' changing the yield value used by the script ( see [[Script_commands#set_yield|set_yield]] ) will change the minimum and maximum timing for pulse counts and will change the measured pulse width value. You will need to calibrate these values for each set_yield change you make.
   
 
==Links==
 
==Links==
Line 289: Line 428:
 
*[http://chdk.setepontos.com/index.php/topic,294.0.html The perfect miniature USB remote?]
 
*[http://chdk.setepontos.com/index.php/topic,294.0.html The perfect miniature USB remote?]
 
*[http://chdk.setepontos.com/index.php?topic=7717 CHDKremote2 - a two stage remote control adapter for CHDK]
 
*[http://chdk.setepontos.com/index.php?topic=7717 CHDKremote2 - a two stage remote control adapter for CHDK]
  +
 
'''External Web Sites'''
 
'''External Web Sites'''
  +
* [http://dalybulge.blogspot.co.uk/2014/07/ghetto-remote-camera-shutter.html Wireless remote shutter by Benbojangles]
 
*[http://digitaldimensionoftechnology.com/2012/05/09/going-beyond-the-device-expanding-the-horizons-of-super-zoom/ Remote Shutter Release Project]
 
*[http://digitaldimensionoftechnology.com/2012/05/09/going-beyond-the-device-expanding-the-horizons-of-super-zoom/ Remote Shutter Release Project]
 
*[http://www.gentles.ltd.uk/gentwire/usb.htm Gentles USB Remote Switches]
 
*[http://www.gentles.ltd.uk/gentwire/usb.htm Gentles USB Remote Switches]
*[http://www.flickr.com/photos/fvdk3d/sets/72157624151791739/ fvdk's USB Remote Wwitches]
+
*[http://www.flickr.com/photos/fvdk3d/sets/72157624151791739/ fvdk's USB Remote Switches]
 
*[http://www.flickr.com/photos/fvdk3d/4823557573/# fvdk's Various SDM / CHDK Remotes with External Port]
 
*[http://www.flickr.com/photos/fvdk3d/4823557573/# fvdk's Various SDM / CHDK Remotes with External Port]
 
*[http://www.youtube.com/watch?v=k89bZ7xMF2A fvdk's USB Remote YouTube video]
 
*[http://www.youtube.com/watch?v=k89bZ7xMF2A fvdk's USB Remote YouTube video]

Latest revision as of 07:04, 15 November 2020

Using just an inexpensive push button switch, a converted USB cable, and a small battery, you can construct a remote device that will allow you to control the operation of your CHDK-enabled camera. If you want software control over USB, see PTP Extension

Background

USB Remote

Since its earliest inception, CHDK has provided a simple method of operating a Canon P&S camera from a remote switch connected to the camera's USB port. Built-in functionality allowed basic "press half" and "press full" actions - with the additional ability to synchronize the release of the shutter between multiple camera connected to a common control unit. There was also a limited remote zoom functionality, useful for coordinating the zoom position when many cameras were connected together.

With the passing of time, the code base supporting this functionality had become increasingly complicated and difficult to maintain or extend. To that end, as of August 2012, a new set of functionality has been released. This new version provides a more stable and easy to understand interface and expanded functionality.

Introduction

The current CHDK version of USB remote operation introduced a modular concept for the selection of what device is connected to the camera and how the camera reacts to that device. A logic block diagram is shown below - click to obtain a full-size view.

USB Remote Logic Diagram

In operation the state of a remote device connected to the USB port is converted to one the following states:

  • switch released
  • switch half pressed
  • switch full pressed

and action is taken based on the output module selected via the CHDK Remote menu.

In addition, values indicating number of activations (pulse count) and a duration of each activation (pulse width / pulse gap) is also maintained for use by CHDK scripts.


Supported Hardware

Homemade Switch

CHDK now supports the use of several different remote control devices to control a set of camera shooting functions.

Ricoh CA-1

For basic shooting functions, a simple switch can be used to provide 3V-5V from set of batteries to the USB connector power pin on the jack on your camera. Details about how to build such a device can be found below.

In addition to "home made" devices, a commercial product called a Ricoh CA-1 can also be used. These are widely available at camera stores or online from many sources.

For more complex operations, devices that produce multiple pulses or pulses of different time duration (width) can be used. These are popular with radio controlled airplane enthusiasts and kite aerial photographers using hardware from vendors like Gentles UK. In addition, using this ability and any of the popular Arduino-type microcontrollers gives almost total flexibility in what your CHDK enable Canon P&S camera can do. Its all up to your imagination and electronics building and programming skills ! A list of sources for USB remote switch devices is posted at the bottom of this page : Links .

Homemade USB Remote Cable

A popular method for remotely triggering CHDK-enabled cameras involves constructing a simple triggering device from a 3V CR2032 coin battery, a USB extension cable, and a push switch. The camera's USB cable is then attached to the camera at one end and to the triggering device by the other end.

Below is a circuit diagram of such a switch.

Remoterelease1rastercy6

If you are cutting up a commercially-made USB extension cable, then wires 1 and 4 are red and black, respectively, according to the USB standard. It seems that even cheaply made USB cables follow this standard.

Note that the 3V CR2032 battery might not be enough to trigger your camera; if not, you may need to use a different power source, e.g. three 1.5V AAA cells connected in series or a spare camera battery like the NB-5L (a 3.7V camera battery).

If you are building a book scanner or creating a copy board application, you can also buy one of the little USB chargers you see at the counter and switch the + side of the cable and not worry about batteries. You know you will always have the correct voltage this way.

Here's a different schematic, click for a larger view :

0001 USB Remote Shutter Wiring Diagram -3


Note: combined USB & Video Connector

Newer Powershots now have a combined USB + video connector; to use both video and USB remote feature a "splitter" cable is necessary.

The HTC splitter is actually wired correctly for the usb and video composite cable but the non standard shields do not fit the body of the camera or allow the video cable into the connector. You can alter the connector to fit the body if you are VERY CAREFUL and pry off the male connector shield and shave off the edge to fit the camera, then, open the case and pry open the non standard square looking female connector to allow the canon video cable to fit, then press the case back together. Works very well no soldering small parts. Just be careful prying it apart.


Homemade USB Remote Cable with Wireless Adapter

IMG 2336

To make a CHDK remote that will allow you to also connect a Canon wireless remote you need modifiy things a little bit. Colon247 added a 2.5mm jack with 3 connectors, so you can use Canon 2.5mm wireless remote by plugging it into the jack and bypassing the CHDK remote circuit.




Improvised USB Remote Using a USB Charger

CHDK-Improvised-Remote USB-Charger

If you own a portable USB charger with a USB A output, you can use it as an improvised USB remote for CHDK. Simply utilize your regular USB cable that you would have used to connect your camera to your computer. In many cases, this is a plain and inexpensive USB A to Mini USB B cable.

The sequence of turning the charger on and off again will create a "OnePush" event (see below). Configured this way, the CHDK camera will auto-focus when turning the switch to the “on” position, and then take the photo when turning the switch back to the "off" position.

While this is certainly kind of clumsy, as you will need to flick a switch back and forth instead of just pressing a button, with a bit of exercise this also works quite nicely for bracket shots.

This is by far sufficient for your first experiments with CHDK's USB remote functionality. You can purchase other inexpensive battery driven "USB Emergency Charger" devices :  video link here

Alternative inputs

As of CHDK 1.5, some CHDK ports support alternative hardware inputs in addition to the USB port. If available, alternate inputs will be listed under "Input Channel" in the remote menu, described below. The other settings, logic and script function generally behave the same regardless of input. These inputs may be useful when the USB port is used for other purposes, or when supplying an external +5V is inconvenient.

Support for these is currently limited to a few models, but is easy to add on cameras with the required hardware, so please request in the forum if you want this feature on a camera that doesn't currently support it.

Note : The alternate inputs have different electrical requirements from the standard USB remote. Consult the forum threads linked below for more information.



Enabling USB Remote operation

USB Remote 01

To enable USB remote operation, go to the CHDK Settings > Remote Parameters menu and select Enable Remote.

Note : When this option is selected, the USB port on the camera will no longer be available for uploading picture files or PTP operations.


Input Channel

USB Remote InputCH-01

USB

Standard USB +5v, as documented above.




USB Remote InputCH-02

HDMI HP

HDMI hotplug detect. On models with an HDMI connector, the remote can be triggered by connecting the HDMI +5v and HDMI hotplug detect pins. Forum thread



USB Remote InputCH-03

ANLG AV

Analog AV detect. On models where standard def video out is combined with the USB port (Canon adapter AVC-DC400/AVC-DC400ST) the remote can be triggered by grounding the detect pin. Forum thread



USB Remote InputCH-04

A/D CH

Battery thermistor A/D. On models with a Canon proprietary Lithium battery, the battery temperature terminal can be used to trigger the remote. The remote is triggered by a specific resistance on the terminal. Forum thread




Switch Types

USB Remote 02

None

Default setting at start-up. Indicates that no USB device is to be monitored. Useful when a script will be interacting with the USB port.



USB Remote 03

OnePush

Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch initiates a "full-press" state for 100 mSec. There is no mechanism to cancel a "half-press" once this sequence is started. Also note that the "half press" will timeout after 10 seconds even if USB power is still applied.


USB Remote 04

TwoPush

Also used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch and then immediately pressing again in less than 1/2 second initiates a "full-press" state. Full press state continues while the switch is held although the picture will be taken on entry to full press state. Failing to initiate the second press within 1/2 second will cancel the sequence.


USB Remote 05

CA-1

Used with a Ricoh CA-1 switch device. Half pressing the button causes the CA-1 to create a 30 mSec pulse that initiates a "half press" state. Releasing the switch at that point will generate 2x30 mSec pulses that cancel the shooting sequences. Full pressing the button will create a 150 mSec pulse that will initiate a "full press" state for 100 mSec.


Control Modes

CHDK control modes support the translation of input device activation sequences into specific camera operations.

None

USB Remote 06

Tells CHDK to do nothing with switch inputs. Allows the input devices to operate - useful for scripting modes.

Normal

USB Remote 07

Reacts to the state of the input device. On half press it places the camera in "half press" mode to focus, set exposure and flash settings. On full press it places the camera in "full press" mode to take the actual photograph. Supports sync mode - see below.

Quick

USB Remote 08

Causes the camera to immediatly enter shooting mode (focus, exposure, flash) and take a picture immediately on the occurance of a "half shoot". Useful for automation projects where the picture should occur as quickly as possible after some condition is detected.

Sync not currently available in this mode.

Burst

USB Remote 09

Cause the camera to enter continuous shooting mode while a half press is active. Similiar to the built in camera continuous function except much slower and it does not reset each time the camera power is removed.

Sync not currently available in this mode.


Bracket

USB Remote 10

Uses the CHDK Bracketing in Continuous Mode settings on each half press / full press operation, changing the bracketing setting on each shot. Times out after 5 seconds of no operations. Useful for bracketing operations as it does not require settting up camera continuous mode or timer settings, which clear after each camera power cycle.

Note that you may need to disable your camera's "Servo AF" mode in the Canon shooting menu for this to work.

Sync not available in this mode.

Zoom

USB Remote 11

Uses the built-in pulse counting capability of the USB remote code to control zoom operations. The following action happens for the listed pulse counts.

1 pulse   = zoom in one step
2 pulses  = zoom out one step
3 pulses  = shoot
4 pulses  = zoom completely in 
5 pulses  = zoom completely out

Note : pulses needs to be "on" for longer than 100 mSec, "off" for longer than 50 mSec and a 500mSec gap indicates the end of the counting period.

Sync not currently available in this mode

Video

USB Remote 12

If camera is in video shooting mode, activates filming on the first half press. Stops filming on the next half press.

If camera has a dedicated video button, will start and stop video using that button rather than the shutter switch.

Sync not curently available in this mode.


Multi-Camera Synchronization

Enable Sync

USB Remote 13


A useful application of CHDK is the ability to connect two or more cameras together via a common USB cable so that their operations can be synchronized. The fact that the cameras are connected in parallel ensures that things happen at approximately the same time. To achieve better synchronization when taking an actual photograph, CHDK has the ability to stop the picture taking process immediately before the image is actually captured. This allows CHDK on several cameras to focus, adjust exposure, setup the flash and then wait for a shared signal to complete the shot (i.e. sync). If the Enable Sync option is set in CHDK then each camera will wait for the final transition of the USB signal ( 5V to 0V ) before shooting.  Note : the camera will wait a maximum of 10 seconds for the sync signal.  Waiting any longer results in unpredictable bad camera behaviour.

Enable Sync Delay

USB Remote 14

To more precisely tune the synchronization between cameras, CHDK allows a precise fixed delay to be added to each camera to adjust for differences in the time each camera takes to finish shooting a picture. The sync delay value is given in units of 0.1 mSec.

USB Remote 15a

Notice in the example pictures the use of the "range multiplier" function in the upper right corner of the screenshot - used to more easily change the delay adjustment value. The range multiplier is changed in ALT mode using the zoom in / zoom out keys.
Developer's note : the USB remote code includes optional code that can be used to calibrate the sync delay units precisely for each camera.

Other Settings

Enable Script Start

USB Remote 16

Tells CHDK to activate the currently loaded script when the USB remote performs a full press. Useful for repetitive activation of a script without needing to press the shutter button.

Bracketing in Continuous Mode

USB Remote 17

A menu link to provide convenient access to the bracketing parameters used in USB remote bracketing mode.


USB Remote Timing Diagrams

Usb remote v2 timing diagram medium

​Scripting Interface

is_key "remote"

  • state of the USB port 5V pin can be queried as any other camera key
  • this function works whether or not USB remote mode is enabled.
while 1
  wait_click 1
  if is_key "remote" then shoot
wend


get_usb_power

USB Remote V2 provides extensive scripting functionality using the get_usb_power() function. 

Note : Although the function is named get_usb_power, it applies to the currently selected remote input.

get_usb_power(0)

  • returns the pulse width of the most recent USB power activation and clears that value. 
  • USB remote must be enabled for this function to work
do 
p = get_usb_power 0 
until p>0


get_usb_power(1)

  • returns the current state of USB power ( 0=off, 1=on)
  • this function works whether or not USB remote mode is enabled.
do 
p = get_usb_power 1 
until p>0


get_usb_power(2)

  • returns the buffered pulse width or pulse gap timing.  Width values are positive, gap values are negative.
  • USB remote must be enabled for this function to work
do 
p = get_usb_power 2 
until p>0


get_usb_power(3)

  • returns the count of pulses since that last time the function was called. Function return 0 when no pulses are receive in the previons 1 second. 
  • USB remote must be enabled for this function to work 
do 
p = get_usb_power 3 
until p>0


set_remote_timing(uSec)

( CHDK 1.3.0 or newer only - originally called enable_remote_hp_timer() in early releases of 1.3.0)

Standard measurement of USB pulse widths is performed by the USB remote task based on the assumption that it runs every 10 mSec.  However, variations in this interval - especially when the camera is in shooting mode - are possible and can result in poor timer accuracy.   The set_remote_timing() command enables the use of a higher precision timer for these measurements. This time does not depend on task "tic timer" accuracy,  providing a much more stable and reliable source for the measurement of pulse width and space information.

The parameter passed to the function specifies the rate at which the USB pulse will be sampled in uSeconds.  Valid values are 1000 and larger.

Sample Lua test script


--[[
@title USB Tester

@param m Mode
   @default m 0
   @values  m State Width Pulses Count Key

--]]

function printf(...)
    local tic = get_day_seconds()
    print (string.format("%02d:%02d:%02d %s", tic/3600, tic%3600/60, tic%60, ...))
end

mode = m
set_console_layout(1, 1, 44, 10)

print("USB remote test started")
if(mode == 1) then mstr="pulse width" 
elseif (mode ==2) then mstr="pulses" 
elseif (mode ==3) then mstr="pulse count" 
elseif (mode ==4) then mstr="key" 
else mstr="state" end
print("   test mode : "..mstr)
print("Press MENU to exit")

set_config_value(121,1) -- make sure USB remote is enabled

usb_state=-1
rkey=0

repeat
    now = get_day_seconds()

 -- check USB state ?
    if ( mode == 0 ) then
        new_state = get_usb_power(1)
        if ( new_state ~= usb_state ) then 
            printf("state="..new_state)
            usb_state=new_state
        end
    end

 -- check USB pulse width ?
    if ( mode == 1 ) then
        x=get_usb_power(0)
        if ( x > 0 ) then printf("width ="..(x*10).." mSec") end
    end
    
 -- check USB pulse train?
    if ( mode == 2 ) then
        x=get_usb_power(2)
        if (x ~= 0 ) then 
            if ( x > 0 ) then printf("mark ="..(x*10).." mSec")
            else printf("space="..(-1*x*10).." mSec") end
        end
    end

 -- check USB pulse count ?
    if ( mode == 3 ) then
        x=get_usb_power(3)
        if ( x > 0 ) then printf("count="..x) end
    end

    wait_click(100)

  -- read USB as a camera key ?
    if ( mode == 4 ) then
        if (is_key("remote")) then 
            if (rkey==0) then 
                printf("remote pressed")
                rkey=1
            end    
        else  
            if (rkey==1) then 
                printf("remote released")
                rkey=0
            end
        end
    end

until is_pressed("menu")

set_config_value(121,0) -- make sure USB remote is disabled




NOTE : changing the yield value used by the script ( see set_yield ) will change the minimum and maximum timing for pulse counts and will change the measured pulse width value. You will need to calibrate these values for each set_yield change you make.

Links

CHDK Forum

External Web Sites

Video Instructions