supplierdeeply

Using USB remote to control chdkptp with Raspberry Pi

  • 68 Replies
  • 5145 Views
Using USB remote to control chdkptp with Raspberry Pi
« on: 01 / March / 2017, 19:46:49 »
Advertisements
Hey there guys! I'm relatively new at using CHDK, but I have a PowerShot A4000IS HD, and was messing around with the USB remote functionality of the camera. I hooked up the USB cable to an Arduino and got the camera to be remotely controlled with an IR remote, but was wondering if there is a script already out there that allows me to remotely start the recording process, then to be able to control the zooming, and then to stop the recording.

I saw this link: http://chdk.wikia.com/wiki/UBASIC/Scripts:_Easy_Zoom_%26_MF_while_Video_Recording

and was wondering if this was what I'm looking for? If so, I'm relatively knew to the CHDK scripting languages and could definitely use some guidance or a point to the right direction!

Thanks!

*

Offline msl

  • *****
  • 1235
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Remotely start/stop recording and Zoom control question!
« Reply #1 on: 02 / March / 2017, 05:51:59 »
This is a very old uBASIC script, not usable for your project.

There are a lot of settings for the CHDK remote function in the chdk menu, also for zooming or video recording. For both at the same time you need a (Lua) script.

For a first impression you should read this wiki site: http://chdk.wikia.com/wiki/USB_Remote_V2

msl
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!

Re: Remotely start/stop recording and Zoom control question!
« Reply #2 on: 08 / March / 2017, 17:23:58 »
I've read through the USB functionality of CHDK, and made myself a USB connector that can be plugged in straight to my arduino, but I'm struggling to find on the wiki and the internet on how exactly to command the camera via Lua.

Re: Remotely start/stop recording and Zoom control question!
« Reply #3 on: 08 / March / 2017, 19:00:55 »
I've read through the USB functionality of CHDK, and made myself a USB connector that can be plugged in straight to my arduino, but I'm struggling to find on the wiki and the internet on how exactly to command the camera via Lua.
There are a couple of ways to answer your question - depending on what you are actually asking.

First of all, Lua is one of the scripting language used by CHDK. So if what you want is scripts that run on the camera, here's a link that will help get you started :CHDK Scripting

If you want to use Lua on your PC to interface with your camera, then chdkptp supports running Lua scripts with an interface over USB to your camera.

But if you want an Arduino to interface to the camera directly over USB, then you need an Arduino with a USB master interface.  This is not common, the USB interface on most Arduino (&clone) cards wants to be the slave.  Here's a link that might help : USB Master / Slave.  If you figure out how to get that sorted out, then the read_usb_msg() and write_usb_msg() Lua functions on the camera side might be of some use.
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline srsa_4c

  • ******
  • 3581
Re: Remotely start/stop recording and Zoom control question!
« Reply #4 on: 08 / March / 2017, 20:27:16 »
Alternatively, camera can also be controlled by using the 'USB remote' functionality in a script running on the camera. An example for such a script is here, or a really simple one from that script's forum thread. A collection of available script commands is here: http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page

Re: Remotely start/stop recording and Zoom control question!
« Reply #5 on: 08 / March / 2017, 20:32:50 »
Alternatively, camera can also be controlled by using the 'USB remote' functionality in a script running on the camera. An example for such a script is here, or a really simple one from that script's forum thread. A collection of available script commands is here: http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page
That last one is the same link I posted  ;) 

But if I understand the OP's question, he is looking to control the camera via USB messages.  Which will be difficult with a stock Arduino as the USB i/f is not the right one for what he wants to do.

As an alternative,  one of the digital outputs from the Arduino can function as a CHDK USB Remote device.  You can trigger the built-in USB remote functions that way - or "bit bash" to a custom script.  I've done both with some success.
« Last Edit: 08 / March / 2017, 20:34:58 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Remotely start/stop recording and Zoom control question!
« Reply #6 on: 09 / March / 2017, 14:15:13 »
Quote
But if I understand the OP's question, he is looking to control the camera via USB messages.  Which will be difficult with a stock Arduino as the USB i/f is not the right one for what he wants to do.

Yes, this is exactly what I want to do. Basically, I want to connect my Arduino to a remote (Bluetooth or Infrared perhaps, but for the sake of using CHDK, it does not matter) and then I want to be able to press on a button on the remote, which will trigger a command to send to my Canon camera. The commands that I want to be able to control remotely are: starting/stopping recording, zooming in/out by one step, and zooming in/out completely (I would like the zooming to work while the video is recording). Alternatively, I would like to be able to snap a picture while recording, but I'm not sure if my PowerShot A4000IS is able to do this.

When I originally started thinking of this project, I thought that these commands could be set by simply using the pulse functionality like this:
 https://evothings.com/diy-camera-control-on-your-smartphone-via-an-arduino-uno-ble-shield/

But if I could send actual data commands directly via USB, that would be even better. If that means getting a USB Master module for an Arduino, that's perfectly okay. Whatever would be the simplest.

*

Offline msl

  • *****
  • 1235
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Remotely start/stop recording and Zoom control question!
« Reply #7 on: 09 / March / 2017, 15:26:38 »
But if I could send actual data commands directly via USB, that would be even better.
In my opinion the Raspberry Pi is more suitable for this task. You have the full control over the camera inclusive live view.

You need a Raspberry Pi with installed PTP client chdkptp and a remote desktop server software (The recent raspberian has included a real vnc server licence.)  Set up a wlan access point on the Pi and connect the phone with the Pi. The smartphone need a real vnc client. So you have the full control over the camera via wlan.

See the pictures in this german forum thread: http://forum.chdk-treff.de/viewtopic.php?f=20&t=3553

Btw, this works also with Pi Zero or the new Pi Zero W.

msl
« Last Edit: 09 / March / 2017, 15:28:23 by msl »
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!


Re: Remotely start/stop recording and Zoom control question!
« Reply #8 on: 09 / March / 2017, 16:17:58 »
Set up a wlan access point on the Pi and connect the phone with the Pi. The smartphone need a real vnc client. So you have the full control over the camera via wlan.

I am trying to limit the amount of connections that have to be made in order for this to work. Ultimately, I am trying to make a tracking device that follows a teacher in a classroom, and that teacher is able to remotely start/stop recording and zoom in and out. I don't necessarily need access to the live camera view for this case (even though that may be super useful for future projects for me).

Is the raspberry pi still a better option in this scenario? I have more programming knowledge with Arduinos, so that would be my preferred option, but if a Raspberry Pi will make everything simpler, I can make that work!

Remotely start/stop recording and Zoom control question!
« Reply #9 on: 09 / March / 2017, 16:22:01 »
Using a Pi will be a lot simplier to program and the Pi has a lot more computing power.  It also will function as a USB master. The only real drawback is power consumption.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics