Interesting power findings - page 2 - General Discussion and Assistance - CHDK Forum

Interesting power findings

  • 21 Replies
  • 6207 Views
Re: Interesting power findings
« Reply #10 on: 26 / May / 2017, 16:16:14 »
Advertisements
Another thing, which is not so nice, is that running a script where I just shoot and then sleep, with the power saving option on 10 seconds, uses 230 mA! So a whole 100 mA used by the script alone, even though it's just sleeping. Any ideas?
That's very interesting.  A scripted shoot( ) just simulates pressing the shutter button and then releasing it by setting bits in the memory mapped I/O.  There should be no way for the Canon code to know it's being tricked.

Obvious question, but does just doing a sleep( 1000 ) change the power draw?

Also, what happens if you run the camera (with or without CHDK loaded) and press the shutter button to take a shot while watching the current readings?


Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline RaduP

  • *****
  • 908
Re: Interesting power findings
« Reply #11 on: 26 / May / 2017, 16:33:38 »
I think the problem is with sleep(), it probably doesn't work properly.
When pressing the power button, it draws a bit over 500 mA. This camera is much hungrier than the SX210.

Re: Interesting power findings
« Reply #12 on: 26 / May / 2017, 16:35:19 »
I think the problem is with sleep(), it probably doesn't work properly.
When pressing the power button, it draws a bit over 500 mA. This camera is much hungrier than the SX210.
So, just to be clear,  physically pressing the shutter button has the same power draw profile as calling the script shoot( ) function?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online reyalp

  • ******
  • 13454
Re: Interesting power findings
« Reply #13 on: 26 / May / 2017, 16:46:30 »
I think the problem is with sleep(), it probably doesn't work properly.
How specifically do you propose that sleep() "doesn't work properly"?

From a CPU usage perspective, there should be no meaningful difference between a script that's in sleep() and no script running at all, kbd_task runs at the same rate, it just takes a very slightly different path.

There might be differences due to secondary factors, like if being in alt mode is causing the display to update constantly. Another possibility might be that the conf.alt_prevent_shutdown / "disable LCD off in ..." code (which is enabled by default for alt and script) affects power consumption in some way.
Don't forget what the H stands for.


*

Offline RaduP

  • *****
  • 908
Re: Interesting power findings
« Reply #14 on: 26 / May / 2017, 16:52:21 »
Quote
How specifically do you propose that sleep() "doesn't work properly"?
So sleep() is like a yield? I didn't know that.

Quote
There might be differences due to secondary factors, like if being in alt mode is causing the display to update constantly. Another possibility might be that the conf.alt_prevent_shutdown / "disable LCD off in ..." code (which is enabled by default for alt and script) affects power consumption in some way.

I already disabled that, or else the screen won't shut down. Is there any special code called if it is set to "Never"?

*

Offline RaduP

  • *****
  • 908
Re: Interesting power findings
« Reply #15 on: 26 / May / 2017, 16:53:20 »
So, just to be clear,  physically pressing the shutter button has the same power draw profile as calling the script shoot( ) function?

Yes, I tested it again. Not sure if it is the SAME but pretty similar. It peaks at around 600 mA, both when physically pressing the button and when calling it from a script. No significant differences.

Re: Interesting power findings
« Reply #16 on: 26 / May / 2017, 17:08:59 »
So, just to be clear,  physically pressing the shutter button has the same power draw profile as calling the script shoot( ) function?

Yes, I tested it again. Not sure if it is the SAME but pretty similar. It peaks at around 600 mA, both when physically pressing the button and when calling it from a script. No significant differences.
Does the power stay high afterwards in both cases?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online reyalp

  • ******
  • 13454
Re: Interesting power findings
« Reply #17 on: 26 / May / 2017, 17:12:57 »
Quote
How specifically do you propose that sleep() "doesn't work properly"?
So sleep() is like a yield? I didn't know that.
Right, for historical reasons CHDK script runs in kbd_task (aka PhySw), which runs in a loop with a 10-ish* ms OS level SleepTask in it. Normal script execution happens in small slices every kbd_task iteration (see set_yield). Script sleep() just tells CHDK not to run the script engine until the specified time has passed.

* The sleep time for PhySw may vary on some ports, but it's under control of the Canon OS.

Quote
I already disabled that, or else the screen won't shut down. Is there any special code called if it is set to "Never"?
No.
Don't forget what the H stands for.


*

Offline RaduP

  • *****
  • 908
Re: Interesting power findings
« Reply #18 on: 26 / May / 2017, 17:34:22 »
Does the power stay high afterwards in both cases?

I checked again and the script version stays at ~500mA while the button shoot will go to around 320 mA soon after the shot is taken. Very strange indeed, it seems like something is not shutting down properly.

*

Offline RaduP

  • *****
  • 908
Re: Interesting power findings
« Reply #19 on: 26 / May / 2017, 17:49:49 »
Ok, so I found it :)

Here is the script:
Code: [Select]
--[[
@title Delayed Single Shot
@chdk_version 1.3

@param a = interval (min)
@default a 9
--]]

b=a
set_aflock(1)
set_mf(1)

focus_distance=get_focus()

repeat
s = get_tick_count()

if b>=a then
--set_focus(focus_distance)
shoot()
end

set_led(9,1)
sleep(100)
set_led(9,0)


sleep(60*1000-(get_tick_count()-s))

b=b+1   
until (false)   

It was the set_focus() who was causing that draw. After commenting it out, it works nicely.
Although now my camera uses 160 mA instead of 130, but it does that without CHDK also. My camera settings were lost, so perhaps something I had disabled or enabled before helped?

 

Related Topics