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

Synchronising two S110's via the AF lamp

  • 54 Replies
  • 6698 Views
Synchronising two S110's via the AF lamp
« on: 28 / March / 2014, 04:07:41 »
Advertisements
 Now that I have two S110's, the SX40 rig project will be put on the backburner for a few weeks. But fortunantly, as I'm pretty much doing the exact same thing, all that will be changing is the camera I'm testing the code with.

Firstly, as I would like to play with the S110 rig this weekend (high hopes there  ;) ), I won't be transfering any data just yet, I just want to sync the shutter for today. Which I don't have any questions about yet.

But I have run into another problem though. When using the modified _wait_until_remote_button_is_released code, which works fine on the SX40, I run into an E26 error on both of my S110's. A quick search revealed that this is WbCaptureTimeOut, which would make sense, but how should I get around this error?


Code: [Select]
void _wait_until_remote_button_is_released(void)
{
int tick;

if ( ( 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

//    #ifdef USB_REMOTE_PRECISION_SYNC
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
//        do { }  while( get_usb_bit() &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT)); //Old
    if ( conf.remote_input == 0 )
{
do { }  while( get_usb_bit() &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT));
}
if ( conf.remote_input == 1 )
{
  prevent_kbd_read = 1; // to make sure only my_kbd_read_keys_alt runs
  msleep(10);
// *((volatile int *) 0xc022c200) = 0x93d800;
// do { }  while( (*(short*)0xc090004a < 300) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT));

        do
{
  msleep(5);
}  while( (kbd_is_key_pressed_alt(KEY_SHOOT_FULL)) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT));
// *((volatile int *) 0xc022c200) = 0x83dc00;
prevent_kbd_read = 0;
}

        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
        *(volatile int*)(GPIO_VSYNC_MAX) = std_period; // back to standard timing on next period
        *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;
        msleep(40);

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


}

edit: I just realised I don't have the address for the AF LED. I know the power LED is 0xC022C30C from the 110 porting thread, and that it's the same for the S100, so if anyone knows either the S110 or S100 AF LED address either will do.
Thanks
« Last Edit: 28 / March / 2014, 06:12:04 by Recyclojunk64 »

Re: Synchronising two S110's via the AF lamp
« Reply #1 on: 28 / March / 2014, 08:58:55 »
But I have run into another problem though. When using the modified _wait_until_remote_button_is_released code, which works fine on the SX40, I run into an E26 error on both of my S110's. A quick search revealed that this is WbCaptureTimeOut, which would make sense, but how should I get around this error?
How long does it take for that error to occur after you release the USB remote 5V signal?

I guess that it's possible the GPIO values for the S110 are different than the SX40.   

There was some discussion about that here :  http://chdk.setepontos.com/index.php?topic=8312.60
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Synchronising two S110's via the AF lamp
« Reply #2 on: 28 / March / 2014, 10:01:39 »
Quote
How long does it take for that error to occur after you release the USB remote 5V signal?

Sometimes two seconds, sometimes almost immediately. It basically hangs, a faint shutter click of some sort can be heard, then it gives the error. BTW I'm not using the usb remote, but that shouldn't make a difference.

*

Offline srsa_4c

  • ******
  • 3935
Re: Synchronising two S110's via the AF lamp
« Reply #3 on: 28 / March / 2014, 15:32:45 »
I just realised I don't have the address for the AF LED. I know the power LED is 0xC022C30C from the 110 porting thread, and that it's the same for the S100, so if anyone knows either the S110 or S100 AF LED address either will do.
Try this one. Use 0x93d800 and 0x83dc00 to turn it on/off.


Re: Synchronising two S110's via the AF lamp
« Reply #4 on: 29 / March / 2014, 12:47:18 »
Try this one. Use 0x93d800 and 0x83dc00 to turn it on/off.
Yep, it works the AF lamp, thanks.

I guess that it's possible the GPIO values for the S110 are different than the SX40.   

There was some discussion about that here :  http://chdk.setepontos.com/index.php?topic=8312.60
Not exactly sure what to do here, I've downloaded the firmware for the SX40 (100f) and S110 (101b), and done a quick search of the strings file for any of the addresses, but they're not there. So I'm guessing I will actually have to decompile the firmware dump, but would this likely get me anywhere given that all I'm capable of is just looking for an appearance of one of the addresses in the SX40 firmware and comparing it to something similar in the S110 to see which address might be different?

Here are the addresses I'm using anyway. I tried both GPIO_VSYNC_CURRENT addresses and both have the same results.
Code: [Select]
#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

Re: Synchronising two S110's via the AF lamp
« Reply #5 on: 30 / March / 2014, 11:25:23 »
Well I took a look at the values at those addresses:

0xC0F06000 - normally 0, goes to 1 while shooting (between shutter clicks)
0xC0F06014 - same as above
0xC0F070C8 - a 5 digit (hex digits) number that's constantly changing, some of the digits change slower with a lower v-sync rate (in low lighting). If more info is needed I could log the output or something.
0xC0F07008 - Always zero

And it seems to be the same on the SX40, so I don't think the addresses would be the problem.

I have also tried removing the lines of code that make it wait till the button is released, but it still shuts down just after taking the photo. And it seems to corrupt the CHDK folder or something as the camera won't start up again until I replace it.
Code: [Select]
#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;

if ( ( 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

       
        //code to wait untill button is released removed.
       
       
        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
        *(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


}

}

Any idea of how I could fix this, or does this sound like a large problem that may take some effort to work out? In which case should I bring this problem to that precision sync thread?

Re: Synchronising two S110's via the AF lamp
« Reply #6 on: 30 / March / 2014, 11:50:00 »
I have also tried removing the lines of code that make it wait till the button is released, but it still shuts down just after taking the photo.
Try commenting out the code that plays with the sync registers?

Quote
Any idea of how I could fix this, or does this sound like a large problem that may take some effort to work out? In which case should I bring this problem to that precision sync thread?
In case you haven't noticed, it's the same two or three people responding to all your posts.  No need to move the conversation to another thread.
« Last Edit: 30 / March / 2014, 11:53:13 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Synchronising two S110's via the AF lamp
« Reply #7 on: 30 / March / 2014, 12:23:31 »
Quote
Try commenting out the code that plays with the sync registers?

Yep it works with them commented out, so that's where the problem is then.

Quote
In case you haven't noticed, it's the same two or three people responding to all your posts.  No need to move the conversation to another thread.
Just though it might have been better for organisational purposes in the other thread, but I guess it'll just make it more fragmented though.


Any ideas of how I could go about trying to prevent it shutting down when those values are changed?


Re: Synchronising two S110's via the AF lamp
« Reply #8 on: 30 / March / 2014, 12:29:20 »
Any ideas of how I could go about trying to prevent it shutting down when those values are changed?
Unfortunately, I don't.  You can try commenting out the parts of the code that actually try to write to the sync registers to narrow down which address might be wrong.

Code: [Select]
     //  *(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
    //    *(volatile int*)(GPIO_VSYNC_MAX) = std_period; // back to standard timing on next period
    //    *(volatile int*)(GPIO_VSYNC_UPDATE) = 1;

But given all the other issues you face getting this project running,  maybe you can stick with standard "sync'" for now.  Have you actually tested how close that is on an S110?
« Last Edit: 30 / March / 2014, 12:31:56 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Synchronising two S110's via the AF lamp
« Reply #9 on: 30 / March / 2014, 13:05:11 »
thanks for the fast reply. I'll have to test which address is causing the problem tomorrow. I haven't actually done a sync test yet, so I'll probably do one tomorrow aswell.

It is unfortunate that it doesn't work on the s110, is it possible that canon changed something that only affects the s110, or is it more likely that other cameras released around the same time may have the same problem? Are there any cameras verified to work with the precision code that were released after the s110?

 

Related Topics