testing sync among more cameras - page 12 - General Discussion and Assistance - CHDK Forum

# testing sync among more cameras

• 121 Replies
• 54609 Views

#### Hardware_Hacker

• 322
##### Re: testing sync among more cameras
« Reply #110 on: 15 / July / 2014, 22:13:26 »

As a matter of interest what method would you use to divide the frequency by a four-digit number (that is not a multiple of 2 or 10) ?

A microcontroller ?

Make Decimal Frequencies in 0.00001 Hz Resolution!   15th Sept 2012

http://www.romanblack.com/onesec/High_Acc_Timing.htm#decfreq

This PIC16F or PIC18F source code uses any handy xtal, and generates a very exact frequency that is adjustable in real Hz steps
(actually in 0.00001 Hz steps).

The lowest freq possible is one unit, or 0.00001 Hz. (Please be warned, at this freq it will take 30 hours to make a single pulse!)

The highest freq possible is;
TMR2 freq / 200
For example; with a 4MHz xtal HS mode TMR2 is 1Mhz so the max freq is 1Mhz / 200 = 5000.00000 Hz.
With a 10MHz xtal in HSPLL mode (40MHz) TMR2 is 10Mhz so the max freq would be 50000.00000 Hz.

(Source Code also supplied for 0.0001 Hz to 50000.0000 Hz)

Theory;...............

Here   http://www.romanblack.com/onesec/DecimalFreqLF.zip

Here   http://www.romanblack.com/onesec/DecimalFreqHF.zip

H-H

#### andrew.stephens.754365

• 461
##### Re: testing sync among more cameras
« Reply #111 on: 29 / November / 2014, 07:20:43 »
Query based on this earlier post http://chdk.setepontos.com/index.php?topic=8312.msg108744#msg108744

For cams (if the A1200 were representative and the hook were missing, which it isn't) missing the synch hook in capt_seq.c it seems the total variation, for a large number of cams, between the first cam shutter to open and last cam shutter to open may not be so different to those with synch / precision synch functionality, see: http://chdk.setepontos.com/index.php?topic=8312.msg107601#msg107601 (has the precision "outlier" issue changed?)

A1200 looks (or, at least looked) like first->last shutter open with sync =22ms, no sync = 28ms, precision synch = 34ms

For cams with “M” mode:

So, for those cams missing the sync hook and outside of a script (and with the appropriate kbd.c hack to enable concurrent usb remote / ptp operation) “acceptable” spread (for blackroom flash capture) of time to shutter open could be provided by usb remote “One Push” menu selection. Detection of transistion to 5V initiates shooting without waiting for transistion to 0v and perhaps something approaching a 28ms spread for all shutters to be opened.

For a fast sequential two stage flash capture to occur (see description here http://chdk.setepontos.com/index.php?topic=11667.msg118685#msg118685) it would be required to fire the flash very soon after the last shutter opened and then force all shutters to close asap thereafter in readiness for the second group of cams to open their shutters.

Should it (for a guru) be possible to provide a chdk menu item (no script) with purpose to mechanically force the shutter to close (if the cam has a mechanical shutter and it is open) when the usb goes back to 0V (or at a menu setable time from when the 5V is first detected).

Any multicam.lua or bcam.lua related camera scripts would have been stopped prior to usb (or 3rd battery terminal) transistion to 5v.

#### waterwingz

• 12138
##### Re: testing sync among more cameras
« Reply #112 on: 29 / November / 2014, 11:51:02 »
(has the precision "outlier" issue changed?)
No.

Quote
For a fast sequential two stage flash capture to occur (see description here http://chdk.setepontos.com/index.php?topic=11667.msg118685#msg118685) it would be required to fire the flash very soon after the last shutter opened and then force all shutters to close asap thereafter in readiness for the second group of cams to open their shutters.
I assume you actually mean this post : http://chdk.setepontos.com/index.php?topic=8810.msg118515#msg118515 ?

Quote
Should it (for a guru) be possible to provide a chdk menu item (no script) with purpose to mechanically force the shutter to close (if the cam has a mechanical shutter and it is open) when the usb goes back to 0V (or at a menu setable time from when the 5V is first detected).
It's possible.  But it seems unlikely to be something that would get added to the autobuild for general distribution so a custom build would be needed (with all the issues that entails for support long term).

However, if you remove the (no script) qualifier,  from what I understand in your post you may very well be able to do it with a variant of either of the ptp scripts you mentioned.   Using call_event_proc("CloseMechaShutter") as discussed here (meteor.lua) it should be fairly simple to force the shutter closed (but this would have to be tested) a fixed time after the script sees the USB go to 0V.  I would expect Lua to be able to do this with enough precision & speed for the application you describe.

Obviously, this would need to be tested.  But testing a simple script modification is not hard.  Certainly a whole lot less work than building and supported a custom CHDK build.
Ported :   A1200    SD940   G10    Powershot N    G16

#### andrew.stephens.754365

• 461
##### Re: testing sync among more cameras
« Reply #113 on: 29 / November / 2014, 15:58:24 »
I assume you actually mean this post : http://chdk.setepontos.com/index.php?topic=8810.msg118515#msg118515 ?

not really, the link I used included this hint:
"...The alternative is noise projection but this introduces other problems of being able to capture a color pass quickly straight after..."
of course, the link you suggest is a much fuller description.

Quote from: waterwingz
It's possible.  But it seems unlikely to be something that would get added to the autobuild for general distribution so a custom build would be needed (with all the issues that entails for support long term).

However, if you remove the (no script) qualifier,  from what I understand in your post you may very well be able to do it with a variant of either of the ptp scripts you mentioned.   Using call_event_proc("CloseMechaShutter") as discussed here (meteor.lua) it should be fairly simple to force the shutter closed (but this would have to be tested) a fixed time after the script sees the USB go to 0V.  I would expect Lua to be able to do this with enough precision & speed for the application you describe.

Obviously, this would need to be tested.  But testing a simple script modification is not hard.  Certainly a whole lot less work than building and supported a custom CHDK build.

Understood.

Thanks.

I'm wondering, a little, about the interaction of the "scripting engine" (if that's a fair description) and other chdk "stuff" e.g. if a script were trying to close the shutter at effectively the same instant the usb remote "process" was trying to open it is conflict likely? is there a simple(ish) thread or explanation that may give a little insight into how this all hangs togther, it may talk about, say, "threads" & "processes" and other such intangibles for the uninitiated?

#### waterwingz

• 12138
##### Re: testing sync among more cameras
« Reply #114 on: 29 / November / 2014, 17:48:43 »
I'm wondering, a little, about the interaction of the "scripting engine" (if that's a fair description) and other chdk "stuff" e.g. if a script were trying to close the shutter at effectively the same instant the usb remote "process" was trying to open it is conflict likely?
Quite possible but not very likely to happen often.  We know only a little about the internal workings of the Canon code and many things are literally a hack that mostly works most of the time.

Quote
is there a simple(ish) thread or explanation that may give a little insight into how this all hangs togther, it may talk about, say, "threads" & "processes" and other such intangibles for the uninitiated?
If you understand the term "preemptive multi-tasking" then you are covered here.  Otherwise,  a quick read of http://en.wikipedia.org/wiki/Computer_multitasking will help.  The operating system in the camera coordinates multiple tasks. Tasks start and stop based on things happening in the camera ( button presses,  shooting, battery status,  temperature status, etc). A task runs until it sleeps, stops, waits for something, or is interrupted (usually by hardware). Interrupted tasks are restarted at some point by the operating system based on their priority relative to other waiting tasks.  All of this implies that things can change "in the background" between each instruction in any give task.  Appropriate steps & precautions need to be taken when coding such tasks.
Ported :   A1200    SD940   G10    Powershot N    G16

#### reyalp

• 14000
##### Re: testing sync among more cameras
« Reply #115 on: 29 / November / 2014, 18:33:18 »
I'm wondering, a little, about the interaction of the "scripting engine" (if that's a fair description) and other chdk "stuff" e.g. if a script were trying to close the shutter at effectively the same instant the usb remote "process" was trying to open it is conflict likely?
To expand somewhat on waterwingz answer:
CHDK does not directly control the shooting sequence. It just hooks the normal firmware at various points.

If you shoot using CHDK (script, usb remote), it makes the  firmware think the shutter buttons was pressed, which starts off a long complicated sequence involving a bunch of different canon firmware tasks. If you use remote sync, then the remote code causes this process to be blocked at a certain point. Similarly, CHDK overrides just change some values at particular points in the code.

Under normal operation, CHDK doesn't control the mechanical shutter at all, it just tells the canon firmware to shoot. So any concern isn't between the scripting engine and remote code, it's between CHDK and the canon firmware.

The mecha shutter functions waterwingz referred to are "eventprocs" exposed by the Canon firmware. You can call them from CHDK Lua, but how this interacts with the canon firmware shooting sequence is not specified.

My observation is that the camera doesn't care if the shutter is already closed, so if you called the close function before the canon firmware would normally close, it just stays closed. I suspect it would be the same if you called it after the Canon firmware had closed it.

As far as I know, on cameras like this the mechanical shutter is really only used to at the end of the exposure, to prevent the sensor from accumulating additional exposure during readout. The exposure is started electronically, and "open" is the default state of the shutter, since it's required for live view.

If you called the close function after the the canon firmware was completely done with the exposure and had already re-opened it for live view, then it would close again and your live view would be black, and your next shot might start with the shutter closed.
Don't forget what the H stands for.

#### andrew.stephens.754365

• 461
##### Re: testing sync among more cameras
« Reply #116 on: 30 / November / 2014, 06:40:37 »
Just the level I was looking for waterwingz and reyalp  - appreciate the comments.

fmi & a start to further investigation http://chdk.setepontos.com/index.php?topic=4454.msg42630#msg42630

Aside:
in case anyone could find it useful sometime, attached is a wip list of sx150is levent / related info.

#### reyalp

• 14000
##### Re: testing sync among more cameras
« Reply #117 on: 30 / November / 2014, 16:23:37 »
in case anyone could find it useful sometime, attached is a wip list of sx150is levent / related info.
Note levents (http://chdk.wikia.com/wiki/LogicalEvent) and eventprocs (http://chdk.wikia.com/wiki/Event_Procedure) are different things.

A list of levents can be generated using the lua: http://chdk.wikia.com/wiki/Lua/Lua_Reference/Levent

Many eventprocs are listed in the platform/sub/.../funcs_by_*.csv files in the CHDK source.
Don't forget what the H stands for.

#### andrew.stephens.754365

• 461
##### Re: testing sync among more cameras
« Reply #118 on: 30 / November / 2014, 17:02:47 »
Note levents (http://chdk.wikia.com/wiki/LogicalEvent) and eventprocs (http://chdk.wikia.com/wiki/Event_Procedure) are different things.

Many eventprocs are listed in the platform/sub/.../funcs_by_*.csv files in the CHDK source.

Ta...I suspected (chanced my arm  ) that was the case...but your reply confirms more study needed. I'll (hopefully) remember to look at the csv's.

Hope the levent file may be useful to someone anyway.
« Last Edit: 30 / November / 2014, 17:19:00 by andrew.stephens.754365 »

#### andrew.stephens.754365

• 461
##### Re: testing sync among more cameras
« Reply #119 on: 05 / January / 2015, 16:21:00 »
A list of levents can be generated using the lua: http://chdk.wikia.com/wiki/Lua/Lua_Reference/Levent

In M mode on my SX150IS:

after setting zoom (another story) i'd like to investigate setting aperture using (http://chdk.setepontos.com/index.php?topic=8613.msg91529#msg91529)

post_levent_to_ui("RotateJogDialLeft",1)
post_levent_to_ui("RotateJogDialRight",1)

These work the jog dial fine.

In manual operation the "focus" of the jog dial toggles between shutter period & aperture when the "+/-" button is pressed.

Using chdkptp lua & the spreadsheet at reply #116 on this thread i've gone through the descriptions that seemed "worth a go" with no success (green arrows continue to surround shutter period) - so any prior story of success / comment would be welcome.
« Last Edit: 05 / January / 2015, 16:26:27 by andrew.stephens.754365 »