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

USB Remote Switch in CHDK - version 2 implementation thread

  • 220 Replies
  • 83655 Views
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #150 on: 29 / January / 2014, 02:24:11 »
Advertisements

I'm open to other avenues to explore.  His code works on my cameras but jittter increases when I remove the sleep command in the loop.  It does not work on his S110. 

Small correction - it does work on S110 , it always did, the jitter was just too big, especially after first picture.
It seems to be fully usable after I increased difference between "commands",  adding 50ms sleep , and narrowed down the range that is accepted as a valid measurement.

So I have a working workaround, even tho some bizarre phenomenon remain :)
-thank you all for looking into this.

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #151 on: 29 / January / 2014, 08:11:12 »
Which leads us to the possible option of running the kbd task more frequently to increase precision.
It's not clear how you'd do this, since SleepTask() operates in 10ms increments. Also, kdb_task calls a bunch of the original canon keyboard code, so calling it more often might have unexpected side effects.
I think you would have to remove the call to SleepTask() and then use the timer / call back functions that srsa_4c recently posted to rerun the task on a more frequent interval.  The calls to stuff in the original Canon code only get called every few times through the task so that they maintain a 10 mSec update rate.

However,  it would probably be easier to just create a new task and run that from a timer callback.  Do the USB power polling from there and thus maintain more precise pulse width / pulse count values.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #152 on: 29 / January / 2014, 17:43:34 »
However,  it would probably be easier to just create a new task and run that from a timer callback.
You certainly can't run a task from a timer callback...
You can run certain parts of the code in the interrupt callback(s), but they have to be lightweight. You can use them for example to 'sample' the USB input with 1/2/5/... msec resolution, and determine pulse lengths. You can manage the timers and get their results from the task code.

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #153 on: 29 / January / 2014, 19:00:35 »
You can run certain parts of the code in the interrupt callback(s), but they have to be lightweight. You can use them for example to 'sample' the USB input with 1/2/5/... msec resolution, and determine pulse lengths. You can manage the timers and get their results from the task code.
That's essentially what I was thinking.

In hind sight,  we have been fighting recently to get precision sync with the USB remote code in newer camera and seeing sync variations of 50 mSec at times. 

So it only stands to reason that whatever is causing that (like long interrupts?) could also be interfering with the kbd task running at exactly 10 mSec intervals.   This will in turn mess up the accuracy of the measurement of USB pulse widths. Adding a small task that uses timer callbacks (or perhaps simply the elapsed timer value) for more precise measurement of USB on & off state times may very well have some value.
« Last Edit: 29 / January / 2014, 19:07:27 by waterwingz »
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 #154 on: 19 / March / 2014, 12:54:09 »
script command get_usb_power(), count mode:

Is there a limit of the pulse length? I have tested with 80, 160, 240ms a.s.o.  The count begins only from a pulse length of 240 ms. I have used the test script from the wiki page: http://chdk.wikia.com/wiki/USB_Remote_Cable

And how long must be the time between the pulses? Must be the break between pulses shorter than the pulse? I need the shortest possible pulse sequence. The goal is a wait loop between 'press' & 'release', e.g.
Code: [Select]
function zoomOut()
    press "zoom_out"
    repeat
        sleep(50)
    until get_usb_power(3) == 0
    release "zoom_out"
end

msl
CHDK-DE:  CHDK-DE links

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #155 on: 19 / March / 2014, 13:07:00 »
Is there a limit of the pulse length? I have tested with 80, 160, 240ms a.s.o.  The count begins only from a pulse length of 240 ms.
What is supposed to happen is the code ( in usb_remote_key() ) will count any pulse longer than 100 mSec.  You probably need at least 20 mSec between pulses.  It transfers the current count when it sees at least 500 mSec with no activity on the USB 5V line.

I've been recently looking at the USB remote 2 code to clean up a few small things and add the battery terminal trigger code.  Using srsa_4c's timer interrupt code,  I also think I can increase the precision of pulse width measurement and thus pulse counting too.  If you think you have a different method of counting pulses (and maybe detecting when counting is complete) this would be a good time to discuss it.
« Last Edit: 19 / March / 2014, 13:09:04 by waterwingz »
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 #156 on: 19 / March / 2014, 16:02:02 »
Thanks.

Now I have tested with steps of 50 ms. A pulse length < 150 ms was not counted. Pulse lengths of 150 and 200 ms are counted but not always safe. With a pulse length of  200 ms and more is all ok.

I have read the news of srsa_4c about the timer interrupt code. This sounds very good. Smaller pulse length with a improve the precision of reading the pulse length would be a great step for a remote control with µC support.

ms
CHDK-DE:  CHDK-DE links

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #157 on: 19 / March / 2014, 16:32:50 »
Hi,

since I want also to use a micro controller to send some pulses to USB port and trigger some action on CHDK side I would also appreciate any improvement in getting short pulses which can be detected by CHDK safely.
200ms for detecting one pulse safely is much too long.
E.g. if you want to send a byte in you need 8 pulses which will lead into around 2000 ms (with pauses between pulses, not considered any start / stop bit) to transmit an 8 Bit information. This is much too long.

What about the 1 ms patch discussed here:

http://chdk.setepontos.com/index.php?topic=10114.msg109695#msg109695

There waterwingz mentioned:

Quote
The attached patch changes that to 1 mSec resolution.

Is it already considered here?

So if I could help somehow, may testing on S110 or anything else please let me know.
2 x IXUS 860IS 100c
2 x Powershot S110 103a

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #158 on: 19 / March / 2014, 17:16:19 »
Now I have tested with steps of 50 ms. A pulse length < 150 ms was not counted. Pulse lengths of 150 and 200 ms are counted but not always safe. With a pulse length of  200 ms and more is all ok.
If you read through this thread,  there have been several people who have had problems with pulse width (and probably pulse count) accuracy.  But every time I've tested with my scope and small stable of cameras, its always been bang on. 

Which leads me to two theories.   

The first theory is that the keyboard task in some cameras is not actually running every 10 mSec.  With the data msl posted above, it would seem his keyboard task runs on a 20 mSec?  Should be easy to test that.   

The other theory is tied to the problems we have with recent cameras getting good "remote sync".  It appears sync is affected by interrupts that take considerably longer in recent cameras than in older ones.  If so, then USB pulse detection accuracy must suffer too.

@msl :  what camera are you testing with ?

Quote
I have read the news of srsa_4c about the timer interrupt code. This sounds very good. Smaller pulse length with a improve the precision of reading the pulse length would be a great step for a remote control with µC support.
There waterwingz mentioned:
Quote
The attached patch changes that to 1 mSec resolution.
Is it already considered here?
Working on it.  If I could just get the MF stuff put to bed that is. 

Current plan is to provide a new function that enables "precision measurement".  If it's not called, you get the 10 mSec default count rate so existig scripts will not be affected.

 I'll try to get a testing release out this weekend.
« Last Edit: 19 / March / 2014, 17:17:59 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: USB Remote Switch in CHDK - version 2 implementation thread
« Reply #159 on: 19 / March / 2014, 17:24:31 »
Hi waterwingz,

thanks for reply this sounds great.
Then I will wait until this "precision measurement" is available at least for testing.
I think it makes no sense to learn / deal with the 'old' code if I want to connect a microcontroller to USB port using pulses.

So please let me know if I can support testing!
2 x IXUS 860IS 100c
2 x Powershot S110 103a

 

Related Topics


SimplePortal © 2008-2014, SimplePortal