Synchronising two S110's via the AF lamp - page 3 - General Discussion and Assistance - CHDK Forum

Synchronising two S110's via the AF lamp

  • 54 Replies
  • 13486 Views
Re: Synchronising two S110's via the AF lamp
« Reply #20 on: 01 / April / 2014, 10:15:13 »
Advertisements
thanks for reply, which release should I take?
From stable one or development trunk?
Precision sync in CHDK is only available in the 1.3.0 development branch as a compile time option.  Which currently means a custom build if you want to implement it on a specific camera.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Synchronising two S110's via the AF lamp
« Reply #21 on: 02 / April / 2014, 12:44:23 »
thanks for reply, which release should I take?

From stable one or development trunk?
(A link would be great)
I just used SVN to get it svn co https://tools.assembla.com/svn/chdk/trunk chdk .

Quote
Should I test with and without precision sync?
If you want to make sure that the sync is working properly and want to know how bad it is without precision sync, then yes. But the results aren't that important, I just wanted to know if anyone else had had the same problem as me, which is the case.

Quote
It would be interesting to know the value from this line ;
Code: [Select]
int std_period = _EngDrvRead(GPIO_VSYNC_MAX);
I was going to test it today but I forgot, I'll post the results tomorrow. And try out the HDMI output aswell





Well after a lot of trial-and-error, I have put together some quick-and-dirty code to synchronise the shutter between the two cameras. Basically, whenever the AF LED is on, the slave camera will half-press. If the LED turns off for less than 50ms (the off-time is 30ms), it will full-press, then take the photo when the LED turns off again (when full-press is released on the master). As half-press is still pressed of course, the LED will go back on almost immediately, and the slave won't have to refocus (until half-press on the master is released again).

in usb_remote.c . Note that the code for the master is commented out at the moment
Code: [Select]
#include "keyboard.h"

#define GPIO_VSYNC_UPDATE  0xC0F06000
#define GPIO_VSYNC_MAX     0xC0F06014
#define GPIO_VSYNC_CURRENT 0xC0F070C8    // microfunguy's value
//#define GPIO_VSYNC_CURRENT 0xC0F07008    // vnd's original value

void _wait_until_remote_button_is_released(void)
{
int tick;

//NOTE set to 1 because, well, you're not going to be turning it off anyway
if ( 1 /*( conf.remote_enable ) // menu : USB remote enabled - bracket everything in this function
&& ( conf.synch_enable  ) // menu : Sync enabled - tells us to wait for USB to disconnect
&& ( usb_sync_wait      )*/ ) // only sync when USB remote is active - don't trap normal shooting
{
usb_remote_status_led(1); // indicate to user we are waiting for remote button to release - this happens every time the camera takes a picture
tick = get_tick_count(); // timestamp so we don't hang here forever if something goes wrong


int std_period = _EngDrvRead(GPIO_VSYNC_MAX);
        int sync_time = std_period * 3;         // schedule the end of extended period at t = t(synch pulse) + sync_time

//NOTE For the master camera
/*  
  *((volatile int *) 0xc022c028) = 0x83dc00; //Turn AF LED off for 30 ms to signal slave
  msleep(30); //LED is turned off anyway by the firmware about 20ms after _wait_until_remote_button_is_released starts
  *((volatile int *) 0xc022c028) = 0x93d800; //Set AF LED on //address is for the S110

do
{
  msleep(20);
}  while( (kbd_is_key_pressed(KEY_SHOOT_FULL)) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT));

//
*((volatile int *) 0xc022c028) = 0x83dc00; //Set AF LED off //Address is for the S110
*/


//NOTE For the slave camera, Value of 100 works well, anything above about 300 will trigger if the battery temp terminal is not modified.
do
{ }  while( (*(short*)0xc090004a < 100) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT));



        int cur_cnt = *(volatile int*)(GPIO_VSYNC_CURRENT) & 0xffff; // get the counter state at the time of sync
        int sync_period = sync_time - (std_period - cur_cnt);
        if (std_period - cur_cnt < 10)
        {
            // too close to overflow, wait for the next period
            sync_period -= std_period;
            while ((*(volatile int*)(GPIO_VSYNC_CURRENT) & 0xffff) >= cur_cnt) {};
        }
        *(volatile int*)(GPIO_VSYNC_MAX) = sync_period; // write the length of the extended period to the register
        *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;
        while (*(volatile int*)(GPIO_VSYNC_UPDATE)) {}; // wait until the new value is applied
        //now we are at the beginning of extended period
        //NOTE commented out because it caused problems with the S110
//        *(volatile int*)(GPIO_VSYNC_MAX) = std_period; // back to standard timing on next period
        *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;
        msleep(40);

        sync_counter++ ;
        usb_sync_wait = 0 ;
        usb_remote_status_led(0);       // alert the user that we are all done


}

}
in kbd_process.c, master code commented out again.
Code: [Select]
int wait_until_master_confirms = 0;


long kbd_process()
{
    ...
       
    // auto iso shift
    if (camera_info.state.is_shutter_half_press && kbd_is_key_pressed(conf.alt_mode_button))
        return 0;

    if (kbd_is_key_pressed(conf.alt_mode_button))
{
        key_pressed = 1;
        kbd_key_release_all();         
        return 1;
        }



//NOTE for slave
if (*(short*)0xc090004a < 100)
{
    if ((wait_until_master_confirms > 1) && (wait_until_master_confirms < 5))
    {
kbd_key_press(KEY_SHOOT_FULL);
kbd_blocked = 1;
    }
    else
    {
    kbd_key_release(KEY_SHOOT_FULL);
    kbd_key_press(KEY_SHOOT_HALF);
    *((volatile int *) 0xc022c028) = 0x93d800; //Set AF LED on, address is for S110
    wait_until_master_confirms = 0;
    kbd_blocked = 1;
    }
}
else
{
    wait_until_master_confirms++;
    if (wait_until_master_confirms > 5) //wait 50 ms to ensure this isn't a 30ms off pulse
    {
*((volatile int *) 0xc022c028) = 0x83dc00;
if (wait_until_master_confirms == 6)
{
    kbd_blocked = 0; //Only do this once or else it will interfere with alt mode keyboard masking
}
    }
}


       //NOTE for master
/*if (kbd_is_key_pressed(KEY_SHOOT_HALF))
{
    *((volatile int *) 0xc022c028) = 0x93d800; //turns on the AF LED on the S110
}
else
{
    *((volatile int *) 0xc022c028) = 0x83dc00;
}*/



#ifdef CAM_TOUCHSCREEN_UI
    extern int ts_process_touch();
    if (ts_process_touch())
    {
        gui_set_need_restore();
    }
#endif

    // deals with the rest

    if ( !kbd_blocked || usb_remote_active )
{
// kbd_blocked = handle_usb_remote(); //Yes, this has been disabled, as it was causing problems I will have to find later
}


   


    if (gui_kbd_process())
        return 1;

    action_stack_process_all();
   

    return kbd_blocked;
}


It seems to work alright, and sync is very good, most shots were about 0.1ms apart. Sometimes the sync was out enough to be heard but only on occasion, not sure why just yet. The above code for the master may have problems reading the state of the full-press during sync, I had to do a complex rearrangement in kbd.c, but it would be easier to replace it with a 50ms or so delay. Not that I expect anyone will try the above modification just yet anyhow.

The next step will be to send settings over to the slave, such as ISO and aperture, and probably shutter-speed.

Re: Synchronising two S110's via the AF lamp
« Reply #22 on: 03 / April / 2014, 03:58:39 »
Hi Recyclojunk64,

Quote
... Basically, whenever the AF LED is on, the slave camera will half-press.  If the LED turns off for less than 50ms (the off-time is 30ms), it will full-press, ...

does that mean you trigger the shutter of the slave cam by the AF LED of the master?



2 x IXUS 860IS 100c
2 x Powershot S110 103a

Re: Synchronising two S110's via the AF lamp
« Reply #23 on: 03 / April / 2014, 05:43:45 »
Quote
does that mean you trigger the shutter of the slave cam by the AF LED of the master?
Yep. It's a lot more versatile than using an external remote. It's just like using the master on it's own, except that the photo is taken (with both cameras) when full-press is released.

The photodiode cathode is connected to the battery-temp terminal on the slave's battery (I just taped thin wires onto the connections), and the anode to gnd.

If you're interested in trying it out I could upload the binaries for the slave and the master. Note that it's not 100% reliable yet though.


Re: Synchronising two S110's via the AF lamp
« Reply #24 on: 04 / April / 2014, 06:50:49 »
Hi Recyclojunk64,

thanks for reply. Sounds interesting.
But for me it is not really clear what is the benefit compared to the USB switch solution.
Can you make it a littlebit more clear to me?

Thanks a lot!
2 x IXUS 860IS 100c
2 x Powershot S110 103a

Re: Synchronising two S110's via the AF lamp
« Reply #25 on: 04 / April / 2014, 10:31:55 »
Hi Recyclojunk64,

thanks for reply. Sounds interesting.
But for me it is not really clear what is the benefit compared to the USB switch solution.
Can you make it a littlebit more clear to me?

Thanks a lot!

Well, there are several benefits. This is looking at a perspective of when this project is complete, which may take a few weeks or months depending on how many problems I run into.

1. It's easier to put together: All that's needed to be done (hardware wise) to put a stereo-rig together is to wire a photodiode to the slave battery and stick it to the master's AF (or otherwise) LED. And of course an S-shaped piece of metal to hold the cameras together (or whatever). Whereas with a USB remote, a remote needs to be constructed, attached to the rig, and needs power to run (unless it's a battery-temp version).

2. It's more versatile: with this setup, when you change a value on the master camera, such as exposure and ISO ect. , it will be synced with slave (either immediately or just before shooting, not sure yet). Whereas to do that with a remote, either a complex resistor array and lots of buttons or a micro-controller and also lots of buttons. An intervalometer script or motion-detection script could also run on the master and sync with the slave.

3. It's easier to use: I will admit, using a loudish trigger-style switch to fire the cameras was fun, but it was somewhat impractical though. Canon put a lot of R&D into the camera button layouts, and to recreate a layout of easy-to-access buttons and spin-dials might take a bit of work (but still a great idea if you have the time of course). I found shooting with the camera's own shutter button was much easier and practical in most situations. Also easier to carry, it fits into a pocket (well a largish one).







Could anyone advise on what would be better between manipulating settings and stuff on the slave as soon as it's changed on the master, or to just send a one-off packet just before shooting? I'm thinking the latter might be easier, of course zoom would be done immediately though.

Also, would I be correct in assuming white-balance is chosen by the firmware after the images is taken? If both cameras take the photo with the same settings, auto white balance isn't likely to differ between the cameras too much would it?

Re: Synchronising two S110's via the AF lamp
« Reply #26 on: 04 / April / 2014, 16:37:10 »
Also, would I be correct in assuming white-balance is chosen by the firmware after the images is taken? If both cameras take the photo with the same settings, auto white balance isn't likely to differ between the cameras too much would it?
AFAIK,  you can't set change the WB setting from CHDK.  If you want them to be exactly the same, I'd suggest using one of the fixed settings.  That way you can always adjust both image in post processing by applying the same changes to both.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Synchronising two S110's via the AF lamp
« Reply #27 on: 04 / April / 2014, 19:00:50 »

AFAIK,  you can't set change the WB setting from CHDK.

It is there, buried deep in the vastness of CHDK archives.
I think it was a thread about flash, possibly posted by the notorious phyrephox.
Who initially devised manual flash control ?


Re: Synchronising two S110's via the AF lamp
« Reply #28 on: 04 / April / 2014, 19:06:38 »
Whereas to do that with a remote, either a complex resistor array and lots of buttons or a micro-controller and also lots of buttons.

Well, some years ago someone in New Zealand sent me an ATTiny84 programmed to talk to one camera via a photosensor and pass parameters to the other camera via USB.
It was a very high speed connection based on the assumption that relatively few messages would be corrupted.
If they were, they were sent again.
The author tested it outdoors on a number of occasions.

One day he just disappeared, as seems customary on the Internet.
I still have the ATTiny84.

Re: Synchronising two S110's via the AF lamp
« Reply #29 on: 05 / April / 2014, 12:08:07 »
Hi,

since this thread is also related to synching S110 I want to tell you that I have finished 1st part of my sync test using CRT.

See this post:

http://chdk.setepontos.com/index.php?topic=11256.0

2 x IXUS 860IS 100c
2 x Powershot S110 103a

 

Related Topics