Script to 'co-operate' with external controller - page 4 - Script Writing - CHDK Forum

Script to 'co-operate' with external controller

  • 37 Replies
  • 14142 Views
*

Offline jules

  • **
  • 73
Re: Script to 'co-operate' with external controller
« Reply #30 on: 26 / September / 2016, 06:24:56 »
Advertisements
Yes that has been plan-all-along and sorry, it's me that's missing understanding.  Long time trying to get plan working, I continually ascribed erratic results to poor mechanical hold-down. Beginning to suspect other complexities exist.

Above we discussed whether or not 'constant-restart' occurs, when power is continuously available to the camera. Possibly different for different cameras. But when I tested further with D10 and A620 it seemed both did restart, but it was IN-constant behaviour. Both had a few restarts, seemingly irregular timing, and both had unscripted stops.

Might seem this should be irrelevant when plan-all-along turns power off between script runs. But until now it was assumed okay to turn power off any time after script completed. Now I'm suspecting that some delay in turning power off might account (partly?) for previous erratic results.

I'd like to test and report more accurately. Would it be possible to have time recorded as HH:MM:SS (include seconds) for logging in your very helpful onshot3.lua ?

Many thanks for patience with this!
« Last Edit: 27 / September / 2016, 02:33:42 by jules »

Re: Script to 'co-operate' with external controller
« Reply #31 on: 28 / September / 2016, 11:23:42 »
Might seem this should be irrelevant when plan-all-along turns power off between script runs. But until now it was assumed okay to turn power off any time after script completed. Now I'm suspecting that some delay in turning power off might account (partly?) for previous erratic results.
That's the nice part about having the script issue a shutdown before you actually cut the power off.  The camera will go through whatever it normally does to turn off in a safe and organized fashion.  Simply killing the power can cause problems depending on what the camera is doing.  After all,  the camera designers assumed battery operation, so the only way to screw that up would be to pop open the battery door while the camera was running.  Not something likely to occur too often for the normal user.

Quote
I'd like to test and report more accurately. Would it be possible to have time recorded as HH:MM:SS (include seconds) for logging in your very helpful onshot3.lua ?

Updated script attached.  Changes are :
  • Timing reworked.
  • Added fixed necessary delays for stable operation (at start and just before power off)
  • Added user variable controlled delay after each shot to allow pressing the MENU button to halt without autostart
  • Modified user variable to control speed of script execution.  I've now tested this with values down to 0 delay.
  • Time stamp format now hh:mm:ss (rather than just hh:mm)
  • Elapsed milliseconds from script start is also logged.
« Last Edit: 28 / September / 2016, 11:33:42 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline jules

  • **
  • 73
Re: Script to 'co-operate' with external controller
« Reply #32 on: 01 / October / 2016, 20:53:05 »
That's the nice part about having the script issue a shutdown before you actually cut the power off.  The camera will go through whatever it normally does to turn off in a safe and organized fashion.  Simply killing the power can cause problems ...

Indeed safe shutdown is nice and is necessary. In the button-held-down scenario, the part that puzzles/worries me is this:

For shut down, script sends 'press power button' event. Camera 'obeys' (we can watch it shut down). But, to 'obey' the software press button event, the camera must ignore the physical 'down' status of the held-down-power-button.
 
Thereafter, for the next autostart to occur, we assume camera must respect the physical 'down' status of the power button. This seems contradictory or potentially unreliable to me... but perhaps due to my lack of understanding what chdk and scripts actually do behind the scenes? Or perhaps there is a real issue, and could account for erratic results in trials so far??

I will test again with the new oneshot script and report back. Thank you very much,  waterwingz, for the enhanced version of your script. 

Re: Script to 'co-operate' with external controller
« Reply #33 on: 01 / October / 2016, 21:07:33 »
Indeed safe shutdown is nice and is necessary. In the button-held-down scenario, the part that puzzles/worries me is this:

For shut down, script sends 'press power button' event. Camera 'obeys' (we can watch it shut down). But, to 'obey' the software press button event, the camera must ignore the physical 'down' status of the held-down-power-button.
 
Thereafter, for the next autostart to occur, we assume camera must respect the physical 'down' status of the power button. This seems contradictory or potentially unreliable to me... but perhaps due to my lack of understanding what chdk and scripts actually do behind the scenes? Or perhaps there is a real issue, and could account for erratic results in trials so far??
Actually,  this has almost nothing to do with CHDK or its scripts.   

It's more a case of making intelligent guesses about what the Canon software does when it sees the power button pressed to turn off the camera.  All the CHDK script does is invoke the same actions via post_levent_to_ui('PressPowerButton').  The power button does not actually cut off the power - it is monitored by the Digic processor in software and when the Canon code see the button pressed,  it executes the 'PressPowerButton' code.  So CHDK is virtually doing the same thing in code as someone physically pressing the button.

If you observe what happens when you press the button,  the camera retracts the lens and then turns itself off.   It will not turn on again if you continues to hold the button - it only starts up again when it sees the button pressed again.  And the magic behind that is likely a tiny bit of electronics that essentially does the restart in hardware.

I think you are worried about nothing here.
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline jules

  • **
  • 73
Re: Script to 'co-operate' with external controller
« Reply #34 on: 01 / October / 2016, 22:04:05 »
If you observe what happens when you press the button,  the camera retracts the lens and then turns itself off.   It will not turn on again if you continues to hold the button - it only starts up again when it sees the button pressed again.  And the magic behind that is likely a tiny bit of electronics that essentially does the restart in hardware.

Strange but truthfully what I am seeing is different. I have just tested with A620 and no script. It did turn on again with button held down, as follows.

[begin manual test] Quick press power to turn on normally. Camera starts up, extends lens, CHDK autostarts.

Press and *hold* power button. Lens retracts, camera shuts down. Button still held down continuously.

After several seconds, camera starts up, extends lens, CHDK autostarts. Stayed on for a few minutes until I removed pressure on button. [end manual test]

Had same result for three repeats of the test above.

Will do script test next.

*

Offline jules

  • **
  • 73
Re: Script to 'co-operate' with external controller
« Reply #35 on: 01 / October / 2016, 23:45:13 »
Test A620 button-down and power available produced similar behaviour with oneshot4 script, to the behaviour without script (my previous post). That is, camera did restart (unwanted/unscripted).

After restarting a few times with script running, it then stopped (unwanted, unscripted, unsafe) and continued to start and stop at irregular short intervals.

Annotated log file attached to show details.

To me it looks like problematic erratic behaviour. Or am I missing something?

*

Offline reyalp

  • ******
  • 14080
Re: Script to 'co-operate' with external controller
« Reply #36 on: 02 / October / 2016, 00:34:07 »
Quote
[begin manual test] Quick press power to turn on normally. Camera starts up, extends lens, CHDK autostarts.

Press and *hold* power button. Lens retracts, camera shuts down. Button still held down continuously.

After several seconds, camera starts up, extends lens, CHDK autostarts. Stayed on for a few minutes until I removed pressure on button. [end manual test]
FWIW, I was not able to reproduce this with A540, SX160, elph130, D10 or G7X. If I power the camera on by clicking power, and then shut down by holding down the power button, they all shutdown and stay stay powered off. I held for at least 30 sec.

edit:
and also FWIW, I known a number of people have used the permanently pressed power button approach successfully.
« Last Edit: 02 / October / 2016, 00:35:41 by reyalp »
Don't forget what the H stands for.

Re: Script to 'co-operate' with external controller
« Reply #37 on: 02 / October / 2016, 02:11:15 »
edit: and also FWIW, I known a number of people have used the permanently pressed power button approach successfully.
Yup .. pretty much what I have observed too.
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics