USB Remote + PTP - How to add PTP functions on multicam.lua - Script Writing - CHDK Forum

USB Remote + PTP - How to add PTP functions on multicam.lua

  • 19 Replies
  • 15952 Views
USB Remote + PTP - How to add PTP functions on multicam.lua
« on: 04 / January / 2017, 16:19:26 »
Advertisements
Hi everyone, i've been learning a lot from this forum for a long time. Always trying to solve my problems on my own, looking for the answers on the infinite pages, and in most cases it took me a long time to understand, but I always found the way. And even though I did not know anything about programming, I managed to make it work, just reading the forum.
I'm very grateful for this.  :D

So, I'll briefly tell you what I did and how I came to this point with no way out for me but to ask for help.

My project consists of controlling 42 cameras at the same time. First I was able to make it work using chdkptp and the multicam.lua codes. Which worked perfectly. I was able to shoot, download and delete all 42 cameras without any problems. With one exception, of course, now the big problem to be solved was the synchronism between the cameras.

Back to the forum, I discovered that I could achieve better synchronization using USB Remote and could keep the ptp connection. Why not try?

I cut one of the usb cables, just the red wire, and I plugged it into a simple switch that turns on and off. Cable hacked perfectly.

At this point, it is very important to say that I'm using CHDK 1.4.1 on SDcards and CHDKPTP-r723 on a PC.

With that in mind, I plugged the camera into the hacked cable and plugged it into the pc.
I opened the chdkptp, connected the camera and used this codes sequence:

Code: [Select]
=usb_force_active(1)
=switch_mode_usb(1)
=usb_sync_wait(1)
=shoot()
 

In this last command, the camera set the focus and waited, I pressed the switch of the hacked cable and the camera took the photo.
After that I put the download and delete codes and it worked perfectly.

I was so happy to make it work. And promptly I made another hacked usb cable, to do the test with two cameras.
And that's when I got stuck. :'(

I connected the two cables to the same switch, tried to use the same codes, but only one of the cameras executes the commands.

How do I get the command to go to all the connected cameras?
I understand that I could add this to the multicam.lua script, but how?
Seems simple, but I do not have the knowledge to do it.
The answer seems to be in my face, but I can not see.
http://chdk.wikia.com/wiki/Lua/PTP_Scripting#usb_force_active
How to add this PTP Functions to work on a script like multicam.lua?

Well, I hope someone can give me some light or a little big help with this.

And sorry for my bad english from google translator.

Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #1 on: 04 / January / 2017, 19:13:06 »
...My project consists of controlling 42 cameras at the same time....
...With one exception, of course, now the big problem to be solved was the synchronism between the cameras....
...I discovered that I could achieve better synchronization using USB Remote and could keep the ptp connection....

...I cut one of the usb cables, just the red wire, and I plugged it into a simple switch that turns on and off.
Cable hacked perfectly....

...The answer seems to be in my face, but I can not see...

Well, I hope someone can give me some light or a little big help with this.

There are both some simple and complex answers to the above.

BUT first I have a question for you, in regard to the
"Welcome to the CHDK forum! (and RULES)" at https://chdk.setepontos.com/index.php?topic=2.0
"... Commercial projects based on CHDK cannot be discussed in this board...."
So,
Is this post about any "Commercial projects..."

And if not, your "42 cameras" what Canon model are they. ??

H-H

« Last Edit: 04 / January / 2017, 19:16:39 by Hardware_Hacker »

Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #2 on: 04 / January / 2017, 21:18:29 »
BUT first I have a question for you, in regard to the "Welcome to the CHDK forum! (and RULES)" at https://chdk.setepontos.com/index.php?topic=2.0 "... Commercial projects based on CHDK cannot be discussed in this board...."
I think it's safe to say that rule has been regularly ignored over the years without anyone objecting. Especially in cases like this where the discussion is about CHDK technical issues with nothing that could be construed as advertising, promoting, or any commercial aspects of a product.
« Last Edit: 04 / January / 2017, 21:22:34 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #3 on: 04 / January / 2017, 21:47:55 »
BUT first I have a question for you, in regard to the "Welcome to the CHDK forum! (and RULES)" at https://chdk.setepontos.com/index.php?topic=2.0 "... Commercial projects based on CHDK cannot be discussed in this board...."
I think it's safe to say that rule has been regularly ignored over the years without anyone objecting. Especially in cases like this where the discussion is about CHDK technical issues with nothing that could be construed as advertising, promoting, or any commercial aspects of a product.
Just being curious about the above post and the old post below.

"..8 camera array for 360 degree panorama possible?   25 / April / 2009..."
This https://chdk.setepontos.com/index.php?topic=3528.msg32957#msg32957
It was originally a ".. Kind of google streetview-like.." a non-commercial site for about a year then it disappeared..

For some time now its a commercial site (the latest version) is here.
http://www.applied-streetview.com/contact/

H-H


Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #4 on: 04 / January / 2017, 22:20:26 »
Just being curious about the above post and the old post below.
I can think of several other threads (more recently) that have been about multi-camera setups, for a variety of purposes. Some of them are linked here :  CHDK Forum Treads - Multicamera Rigs.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #5 on: 04 / January / 2017, 22:39:17 »
So, I'll briefly tell you what I did and how I came to this point with no way out for me but to ask for help.
Well, you've come to the right place!

Quote
Back to the forum, I discovered that I could achieve better synchronization using USB Remote and could keep the ptp connection. Why not try?
That's one of two methods. Unfortunately, I do not believe the necessary code is in the multicam.lua script to support this (at least looking at the somewhat older copy I have of the script).  IIRC,  reyalp went down a different route of calibrating the delays between cameras to achieve reasonable (but perhaps not optimal) sync quality.  There is info about that in a few threads.  Start with this one ?
Re: Noob question, how to run multicam.lua on chdkptp


Quote
How to add this PTP Functions to work on a script like multicam.lua?
I'd suggest waiting for reyalp's response. I expect it would not be too hard to modify his script to use the command sequence you've requested but I should not attempt to speak for him.

Quote
And sorry for my bad english from google translator.
Language never seems to be a problem for anyone using this forum. We manage.
« Last Edit: 04 / January / 2017, 22:42:19 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #6 on: 05 / January / 2017, 00:41:11 »

...I was able to shoot, download and delete all 42 cameras without any problems.
With one exception, of course, now the big problem to be solved was the synchronism between the cameras.

...Back to the forum, I discovered that I could achieve better synchronization using USB Remote and could keep the ptp connection. Why not try?

...I cut one of the usb cables, just the red wire, and I plugged it into a simple switch that turns on and off. Cable hacked perfectly.

...I made another hacked usb cable, to do the test with two cameras.
...And that's when I got stuck. :'(

...I connected the two cables to the same switch, tried to use the same codes, but only one of the cameras executes the commands.
Just getting your 42 cameras to work (at ALL) is a very big first step, but a little more details on your rig (+ photo's) also would help.
And is your multi-camera built, by you, from scratch or partly bought second-hand. ??

My guess is the devil is in the details regarding the "red wire SYNC USB-2 HACK".

What happens to the voltage between the USB-2 Black and Red wires a you progressively add more cameras.

When multicam.lua is used the shoot command is via USB-2 commands.

When the "red wire SYNC USB-2 HACK"  Sync method is used it depends on a UN-documented USB-2
hardware switch that is subject to "Changes without Notice" by Canon due to Camera Model hardware changes. ( ??? )

Also UN-documented USB-2 HUB hardware variations that are also subject to "Changes without Notice" by the USB-vendors.

What I think is happening is that the "red wire SYNC USB-2 HACK" is dropping below the switching threshold.
(A simple fix for this problem is possible.)

There is some Windows USB software that may also help to find the USB-Hub Device I.C. Vendors :-

Nirsoft's UsbDeviceView (Also shows what's happening in the windows registry) , UsbLogView, etc.

Uwe Sieber's  UsbTreeView (The Old version's was Buggy ??)

H-H

Edit #1   Also refer to the Multi-Camera post's regarding Rig Construction, USB-2 Wiring, Camera Power Supply etc.

Edit #2  Windows will only connect to ONE Camera at a time so the camera selection is via a software switch (multicam.lua)
              OR via switching the "red wire". Example see the post's on  USB-2 HUB Hacking. (An experimental up-dated method is now available)

Edit #3  Windows is un-relable in regard to (the Rig's) Multiple USB Devices such as Multiple-HUB's and Multiple-Cameras.
              It's continually attempting to re-install the Rig's USB-2 Devices attempting to re-access the Windows Registry etc.
              So some times the "Trusted Windows Installer" will place a "Restricted Access" Flag on the Rig's USB-2 Devices.
« Last Edit: 05 / January / 2017, 01:41:21 by Hardware_Hacker »

*

Offline reyalp

  • ******
  • 14082
Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #7 on: 05 / January / 2017, 01:00:01 »
How do I get the command to go to all the connected cameras?
I understand that I could add this to the multicam.lua script, but how?
Seems simple, but I do not have the knowledge to do it.
In multicam, you can execute any Lua on all the cameras using the "call" or "pcall" commands

So for usb_force_active you should be able to just do something like
!mc:cmdwait('call usb_force_active(1)')

For usb_sync_wait, you probably can't use the normal multicam shoot command , but something like
!mc:cmd('call usb_sync_wait(1);shoot()')
and then triggering your hardware switch might work. If you want to get all the cameras ready to shoot first, you could do something like
!mc:cmdwait('preshoot')
!mc:cmd('call usb_sync_wait(1); click("shoot_full")')

I think you don't want to use cmdwait for the command that actually triggers the shot, because you could get USB errors when multicam is trying to check status.
« Last Edit: 05 / January / 2017, 01:22:23 by reyalp »
Don't forget what the H stands for.


Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #8 on: 05 / January / 2017, 08:44:21 »
I understand that I could add this to the multicam.lua script, but how?

I added that to multicam.lua and completed a quick test, on a single camera, here https://chdk.setepontos.com/index.php?topic=12827.msg128700#msg128700

From that test, it appeared to work as expected. My concern with that simple code approach, stated here https://chdk.setepontos.com/index.php?topic=12827.msg128714#msg128714, is that no status is returned.

*

Offline reyalp

  • ******
  • 14082
Re: USB Remote + PTP - How to add PTP functions on multicam.lua
« Reply #9 on: 05 / January / 2017, 16:31:15 »
is that no status is returned.
FWIW, you should be able to return status in the normal way in the camera side code. What you probably don't want to do is used cmdwait while messing with the physical USB connection, since it tries to repeatedly poll the camera. All communication in the CHDK PTP protocol is actually initiated by the PC side, sending or returning from lua just queues a message.

You could use wait_status_msg (see the end of mc:cmd in multcam.lua) to get status after you know are done with the hardware USB trigger.
Don't forget what the H stands for.

 

Related Topics