Backlight disable: Lua/UBASIC commands + power input measurement results - General Discussion and Assistance - CHDK Forum

Backlight disable: Lua/UBASIC commands + power input measurement results

  • 18 Replies
  • 21097 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Advertisements
Dataghost already experimented with LCD things a while back with some cameras and his code is available in his branch in svn. I think we should put TurnOffBackLight / TurnOnBackLight to Lua and uBASIC. I experimented with it a bit and it seems like a good way to cut power consumption of timelapse and motion detect scripts.

There are no backlight brightness settings in the A570IS (except in Dataghost experimental branch), and adding these simple calls will not bring that PWM control to us.

The effect of TurnOffBackLight wears off quite easily (for example after each mode change and after each shot or release of shoot_half), but this is sort of a good thing as it will not cause permanently difficult situations of dark displays after interrupting scripts. To keep a script dark, this just needs to be called after each shot and whatever commands are found to reset the backlight. The backlight stays off during half shoot, exposures and during dark frame reduction, important in night time timelapses and motion detectors. The LCD getting ready to show live view again is probably what re-enableds backlight.

Note that even if the effect doesn't wear off on your camera no matter what you do other than powering off (remember you may need to exit ALT mode to be able to do things), you can still see what's on the LCD if you point a bright light at it and look carefully.


Aside from increasing battery life, this control should be good for
  - eliminating stray light from LCD (which ruins long exposures when shooting out of a window at night... LEDs must still be taped shut, though, but that's less troublesome than covering the LCD and uncovering it each time you need to tweak).
  - making the camera draw less attention during script runs by making it spend significantly less time with a shiningly bright LCD
  - slightly lowering heat dissipation of the camera, which theoretically could very very slightly reduce sensor noise in long script runs even though the reduced heat is nowhere near the CCD.

So, what sort of effect on battery life are we talking about? I measured it on my a570is (simple 4-lead lab PSU measurement supplied to the DC jack).

LCD backlight of A570IS requires 200 mW of power, give or take a 5 % or so. On empty batteries the camera's PSU is a bit less efficient, I measured at nominal DC input (3.15 VDC) and at nominal NiMH input (2.4 VDC), the difference in efficiency is about 2 units of %.

During idle REC mode (e.g. slow mode MD or timelapse script wait) this is 15 % of total power consumption of this idle time.
During half shoot REC mode (e.g. fast mode MD) this is 13 % of total power consumtion of this half shoot "idle" time.
During PLAY mode with lens out (after REC mode for a while) this is 30 % of total power consumption.
During PLAY mode with lens in (hidden) this is 37 % of total power consumption.

This is significantly better than using the already proven but a bit disappointing AV plug method, whose power savings are about 7 % in REC mode during half shoot, 10 % in idle REC mode and 25 % in PLAY mode (don't remember if the lens was in or out), probably because the video output circuitry requires some power.


To add the function to CHDK, these additions are required:
==========================================================
platform/a570/sub/100e/stubs_entry_2.S:
NHSTUB(TurnOnBackLight, 0xFFC34D40)
NHSTUB(TurnOffBackLight, 0xFFC34D70)

Entry points for some other cameras, including the reference firmwares. For vxworks cameras the signature finder should probably find the functions well. For dryos not so much I guess. All I looked for were simple, but is IDA able to do this automatically? Going thru all dissassemblies manually is pretty tiring.

TurnOnBackLight
a450 100d 0xffc4e3b8
a570 100e 0xFFC34D40
a570 101a 0xffc34d40
a610 100e 0xffd93428
s3is 100a 0xff9e6afc
ixus70_sd1000 100c 0xff8462a4
a650 100d 0xffc69378
a710 100a 0xffdbd720
a720 100c 0xffc676dc
s5is 101a 0xff888450
s5is 101b 0xff888388

TurnOffBackLight
a450 100d 0xffc4e3e8
a570 100e 0xFFC34D70
a570 101a 0xffc34d70
a610 100e 0xffd93454
s3is 100a 0xff9e6b2c
ixus70_sd1000 100c 0xff8462d4
a650 100d 0xffc69390
a710 100a 0xffdbd750
a720 100c 0xffc676f4
s5is 101a 0xff888468
s5is 101b 0xff8883a0

include/lolevel.h:
extern void _TurnOnBackLight(void);
extern void _TurnOffBackLight(void);

include/platform.h:
void TurnOnBackLight(void);
void TurnOffBackLight(void);

platform/generic/wrappers.c:
void TurnOnBackLight(void)
{
  _TurnOnBackLight();
}

void TurnOffBackLight(void)
{
  _TurnOffBackLight();
}


To add a new command set_backlight to Lua:
==========================================
core/luascript.c:
// Enable/disable LCD back light (input argument 1/0)
static int luaCB_set_backlight( lua_State* L )
{
  int val = (luaL_checknumber(L,1));

  if (val > 0) TurnOnBackLight();
  else TurnOffBackLight();
  return 0;
}

and to the end of core/luascript.c function register_lua_funcs, add the line:
  FUNC(set_backlight);


To add the same command to uBASIC:
==================================
lib/ubasic/ubasic.c (somewhere before the function static void statement(void)):
static void set_backlight_statement(void)
{
  int val;
  accept(TOKENIZER_SET_BACKLIGHT);
  val = expr();
  if (val > 0) TurnOnBackLight();
  else TurnOffBackLight();
  accept_cr();
}

add to the switch/case statement near the end of ubasic.c:
  case TOKENIZER_SET_BACKLIGHT:
    set_backlight_statement();
    break;


add to struct keyword_token keywords[] in lib/ubasic/tokenizer.c:
  {"set_backlight",            TOKENIZER_SET_BACKLIGHT},

add to enum ubasic_token in lib/ubasic/tokenizer.h:
  TOKENIZER_SET_BACKLIGHT,


That should be it.

set_backlight(0) turns off the backlight
set_backlight(1) turns on the backlight (as do some operations such as shoot() and release(("shoot_half"))

In ubasic no paranthesis in syntax, obviously. I didn't actually test the ubasic command, just the Lua ones but it compiles fine and follows my old example from http://chdk.wikia.com/wiki/Adding_Firmware_Features.

(and as a side note, from the above you can see one more reason I now prefer Lua...it's way easier to add funky new experimental functions to Lua  :D).


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #1 on: 08 / December / 2008, 18:08:58 »
no responses yet ???
nice stuff, as always, fudgey.

*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #2 on: 09 / December / 2008, 19:26:49 »
nice stuff, as always, fudgey.

Yeah - absolutely, as always !

This is one of the points of my fast growing ToDo/Check/PlayWith@CHDK list; i plan to do some tests with the sig finder, e.g. an additional DryOS reference dump, would be helpful for new members / pre-members in the CHDK family...

In all dumps we have also DispSwCon_TurnOnBackLight & DispSwCon_TurnOffBackLight, also some other interessting strings starting with DispSwCon_:

 DispSwCon_TurnOnBackLight
 DispSwCon_TurnOffBackLight
 DispSwCon_MuteOnPhysicalScreen
 DispSwCon_MuteOffPhysicalScreen
 DispSwCon_DisableMute
 DispSwCon_TurnOnDisplayDevice
 DispSwCon_TurnOffDisplayDevice


what is DispSwCon standing for ? Display Switch Control maybe ?

TurnOnDisplayDevice & TurnOffDisplayDevice sounds good for me as a users of a camera without an optical viewfinder (SD870) since there you can't switch off the display with the DISP key. Maybe this is the key to switch off the complete thing (sensor & display) ?

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #3 on: 09 / December / 2008, 19:48:13 »
what is DispSwCon standing for ? Display Switch Control maybe ?
IMHO, Display Software Control.

Quote
TurnOnDisplayDevice & TurnOffDisplayDevice sounds good for me as a users of a camera without an optical viewfinder (SD870) since there you can't switch off the display with the DISP key. Maybe this is the key to switch off the complete thing (sensor & display) ?
In some cameras without optical viewfinder (SX100, IXUS860 for example) "diplay off" function can be assigned to "print" button from camera menu.

edit: I tested current consumption on SX100 in record mode:
display is on - 500 ma
display is off - 150 ma
« Last Edit: 09 / December / 2008, 19:59:14 by ewavr »


*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #4 on: 09 / December / 2008, 20:01:56 »
..In some cameras without optical viewfinder (SX100, IXUS860 for example) "diplay off" function can be assigned to "print" button from camera menu.
Yes, this is great for time lapse (5.5-6h and ~ 1100 images with a batt. charge on the SD870), but the problem is: you can only attach one function, e.g. Disp.Off OR Rec Movie, furthermore it's not available in Playback mode...

*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #5 on: 09 / December / 2008, 20:06:39 »
...edit: I tested current consumption on SX100 in record mode:
display is on - 500 ma
display is off - 150 ma

Switched off by which method - with the attached Canon function or with TurnOffBackLight ?
I guess the first one, so the sensor is also switched off, the powr consumption is the same as in Playback mode ?
MD would not work in this case, correct ?

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #6 on: 09 / December / 2008, 20:16:39 »
Switched off by which method - with the attached Canon function or with TurnOffBackLight ?
I guess the first one, so the sensor is also switched off, the powr consumption is the same as in Playback mode ?
MD would not work in this case, correct ?
Of course, I use Canon function. In this case sensor is off and MD would not work.
But display without sensor can be turned off using video-out cable.
I think that DispSwCon_XYZ() function can turn on/off display only, without sensor/shutter.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #7 on: 10 / December / 2008, 02:21:34 »
In all dumps we have also DispSwCon_TurnOnBackLight & DispSwCon_TurnOffBackLight, also some other interessting strings starting with DispSwCon_:

Using those pwm thingies isn't quite as simple as that simple backlight disable, but see Dataghost branch /branches/dataghost/core - chdk - Trac (dgmod.*) and s5is stubs files in the same branch for some more info.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #8 on: 14 / January / 2009, 17:24:05 »
attached is a patch for LCD backlight switch for following cameras:

a450/sub/100d
a570/sub/100e
a570/sub/101a
a610/sub/100e
a620/sub/100f
a650/sub/100d
a710/sub/100a
a720/sub/100c
ixus70_sd1000/sub/100c
s3is/sub/100a
s5is/sub/101a
s5is/sub/101b

what does it do? it allows switching of lcd backlight on and off via ubasic and lua (like in fudgeys original post). also the sigfiles are updated.

Please, someone with a devkit AND all the binaries and a fast box - run gmake batchzip once, so we can get all stubs from all cameras.

i can then check it into svn, so all cameras will have this wonderful feature :)

oh, attached also is a slightly modified metronome lua script, which when you start the metronome via set, starts the metronome (sound + blue light) and disables backlight - and when you press menu, it stops the metronome and enables backlight again. this is an example application.
i guess when you use the command in actual scripts, i advise you to use some kind of means to tell you that your camera is not powered down, ie. with the blue led or something like that (i guess the blue led doesnt consume much power).

anyhows, thanks for your work fudgey, and also for the wonderful manual on the sigfinder ( http://chdk.wikia.com/wiki/Signature_finder ).

p.s.: all i need are the stubs from the missing cameras ;)

edit: just tested shooting with this: after a shot, display is turned on again. so either you disable it again via script after a shot or all the time? Or shall we make that a function in chdk? like for example the dummy keys, but the other way around: if you dont press a button for a given time, the display goes to sleep. huh?
« Last Edit: 14 / January / 2009, 17:43:43 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Backlight disable: Lua/UBASIC commands + power input measurement results
« Reply #9 on: 14 / January / 2009, 19:07:49 »
thx to fudgey, i was able to get adresses for almost all cams.

4 oddities:

- according to fudgey, it is not neccessary adding sigs to all 5 reference firmwares. i dont know which to remove though, trial and error? any hints?
- ixus80 101a dump still missing
- fudgeys batch-zip seems to have heavily messed around in the g9 stub files.
- ixus40_sd300 100j there one adress changed as well

all the other stubfiles were updated correctly (tested on s3is and a620) (besides the eg "ALT: NSTUB(TurnOffBackLight, 0xff848a6c) // 22/0" issue which is adressed in oddity 1)

in the meantime i downloaded all firmwares (well, almost :D) and doing a batch-zip myself (during the night).

attached is a diff. it is almost ready for trunk (when the oddities have been solved)

edit: attached is a diff i made after compilation for several hours, it is different from what i got from fudgey, but i havent analysed it yet
edit2: added patch4, which contains the adresses for ixus80 101a
edit3: all oddities fixed :)
« Last Edit: 15 / January / 2009, 19:40:07 by PhyrePhoX »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal