USB Remote Switch in CHDK - version 2 implementation thread - page 17 - General Discussion and Assistance - CHDK Forum

USB Remote Switch in CHDK - version 2 implementation thread

  • 220 Replies
  • 81600 Views
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #160 on: 25 / March / 2014, 19:59:55 »
Advertisements
Moving this conversation here ...

So, I would recommend getting the USB bit directly if possible, and perhaps only enabling the high speed routine on those cameras.


@srsa_4c :  so in looking (again) at all the USB remote implementations,  the ixus30_sd200,  ixus40_sd300, ixus50_sd400, and ixus700_sd500 have a unique routine called usb_power_status_override() in their kbd.c that monitors and updates the information used by the USB script functions.    The get_usb_bit() function is also implemented (maybe wrongly?) and it normally feeds the code that updates those values so I assume it returns 0 all the time?

I believe you ported the ixus30 so I thought I'd ask what that's all about?  Why are these ports different?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #161 on: 26 / March / 2014, 14:36:03 »
@srsa_4c :  so in looking (again) at all the USB remote implementations,  the ixus30_sd200,  ixus40_sd300, ixus50_sd400, and ixus700_sd500 have a unique routine called usb_power_status_override() in their kbd.c that monitors and updates the information used by the USB script functions.    The get_usb_bit() function is also implemented (maybe wrongly?) and it normally feeds the code that updates those values so I assume it returns 0 all the time?

I believe you ported the ixus30 so I thought I'd ask what that's all about?  Why are these ports different?
My port was based on the existing ixus40_sd300 port, and I did not touch the keyboard code. There are comments in source / porting thread indicating that the usual approach did not work. Note that these cameras are the first DIGIC II models, their (Canon) code base is a transition from old code to new.
get_usb_bit() can likely be fixed if it doesn't work. I have much less desire rewriting the keyboard code :)

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #162 on: 29 / March / 2014, 19:22:31 »
A draft patch file that adds high precision timer capability to USB remote processing is attached.  Should easily allow measurement of pulses as short as 2 mSec and perhaps as short as 500 uSec (see caution notes below).

Tested on G10, A1200, IXUS120_SD960 (DryOS) and A560 (VxWorks) at "s" values if 100 and 500.   I'll put together a sample high speed serial communications Lua script to go with this.

New Function Added :
  enable_highspeed_usb(s)    : Lua
  enable_highspeed_usb s     : uBASIC

Enables high precision USB pulse width timing.  The passed parameter value "s" is the sample time in uSec ( 1x10-6).

Notes :
  • Safe values of "s" are not known at this time.  However, values less than 1000 could be problematic, possibly interfering with camera motor & lens timing.  Use caution.
  • The recommended method of using this function is to wait for a 20 mSec start pulse using standard USB remote processing and then enable high speed mode only for the duration of the following communication.
  • Using normal USB remote processing,  the equivalent "s" value is 10000.
  • Values returned by the get_usb_power() function are in increments of "s"
  • The function may work more reliably in playback mode rather than shooting mode.

Function Expanded :
   get_usb_power(5)

Adds an additional returned value that give the number of high precision timer errors since the previous call to the function.  Useful for determining if the value of 's' is too small and the precision timer is failing to slip.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #163 on: 05 / April / 2014, 16:34:33 »
Added in trunk changeset 3408

Note I think srsa_4c's concerns about calling kbd stuff inside the timer callback are probably valid, but I don't think it's any worse than a lot of other stuff CHDK does. The only way to know if it's really a problem is for people to try to use it. If there is an MMIO that can be polled directly to get USB power state, that would probably be better.
Quoted here as this is probably a good place to continue the conversation. 

As noted above, us30_sd200,  ixus40_sd300, ixus50_sd400, and ixus700_sd500  read the USB bit directly, apparently necessary due to how their keyboard code is implemented in the Canon f/w.    I'll plug away at seeing if that gives us hints about how to do the same for other cameras.
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #164 on: 10 / April / 2014, 16:01:24 »
The new highspeed usb function works very well. Thanks for that.

My test environment:

-pulse width: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 ms (Arduino output)

-test script by waterwingz (PWM Tester)

-sample time: 100, 500, 1000

-reading in play mode maximum deviation: -1 ms
-reading in record mode maximum deviation: -1 ms (5 ms); -3 ms (50 ms)

-no errors (get_usb_power(5))

The results were identical for the A720 and SX220.

A gap of 5 ms is safe for different remote functions. That is great.

msl
CHDK-DE:  CHDK-DE links

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #165 on: 12 / April / 2014, 22:01:05 »
The new highspeed usb function works very well.
Which begs this question : do we leave this as a build option for advanced users, enable it for cameras where someone has tested it, or just generally enable it ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #166 on: 13 / April / 2014, 05:12:08 »
I think it's safe enough for a general activation in version 1.3. Only experienced users know and use the 'magic command' enable_highspeed_usb(s) .

More and more (cheap) µC projects are available on the market that are easy to program for a CHDK remote control. The highspeed function would be highly advantageous for such controllers.

msl
CHDK-DE:  CHDK-DE links

*

Offline srsa_4c

  • ******
  • 4451
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #167 on: 13 / April / 2014, 09:41:52 »
do we leave this as a build option for advanced users, enable it for cameras where someone has tested it, or just generally enable it ?
To confirm my suspicion, I have tried a build with CAM_REMOTE_USB_HIGHSPEED enabled on the s80. The camera crashes a few seconds later when a USB pulse (onepush, normal) is applied in rec mode. No romlog is recorded. (reminder: this is one of the cameras where the DIGIC doesn't get the USB status directly).
On the other hand, the a3200 seems to be working with this define.


Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #168 on: 13 / April / 2014, 10:06:57 »
To confirm my suspicion, I have tried a build with CAM_REMOTE_USB_HIGHSPEED enabled on the s80. The camera crashes a few seconds later when a USB pulse (onepush, normal) is applied in rec mode. No romlog is recorded. (reminder: this is one of the cameras where the DIGIC doesn't get the USB status directly).
To be clear,  are you saying you simple compiled with CAM_REMOTE_USB_HIGHSPEED enabled and the camera crashed without the enable_highspeed_usb() script function being called?   

Regardless, given the way the HP code is implemented, it seems unlikely that a single USB pulse would trigger the crash due to timing overload. Maybe there is a more fundamental bug in either the patch or the original S80 USB remote code?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #169 on: 13 / April / 2014, 10:28:23 »
To be clear,  are you saying you simple compiled with CAM_REMOTE_USB_HIGHSPEED enabled and the camera crashed without the enable_highspeed_usb() script function being called?
Ohhh.  :-[ I thought the define changed the underlying code for all remote operations.
Retried with a somewhat older CHDK version (other card), the cam will crash in rec mode when synch is enabled, regardless of CAM_REMOTE_USB_HIGHSPEED.

Quote
Maybe there is a more fundamental bug in (...) the original S80 USB remote code?
Yes, but I wouldn't call it a bug, it's "just" incompatibility. Perhaps it's time (for me) to re-work the get_usb_bit() implementation in the s80 and s3is ...? They can't sync properly anyway...

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal