Does get_usb_power() ever return a value other than 0? - Script Writing - CHDK Forum  

Does get_usb_power() ever return a value other than 0?

  • 5 Replies
  • 5267 Views
Does get_usb_power() ever return a value other than 0?
« on: 09 / January / 2009, 19:28:59 »
Advertisements
Does get_usb_power() ever return a value other than 0?  I've been trying to use this function in a Lua script but never see anything but 0.  Of course, it could be that this is the 2nd Lua script I've written and I don't know what I'm doing... :haha

Here's my code:

function print_usb_time()
   
repeat

   a = get_usb_power() 
   print(a)
   sleep(500)
until is_key "set"

end

Searching throught the forum, I found some postings that suggest the function does not actually work.  Can anyone shed some light on this for me?  Thanks!!
Was: SD1100 IS, Autobuild, V1.01a, dunked in ocean
Next: SD990 IS, Autobuild, used to build sand castles with
Waiting to die: SX230

*

Offline zeno

  • *****
  • 891
Re: Does get_usb_power() ever return a value other than 0?
« Reply #1 on: 10 / January / 2009, 05:48:15 »
You have to do two things to get a non-zero value:

1. turn on Enable Remote in Remote Parameters in Scripting Parameters
2. apply 3-5 volts to the USB port for some time (for some cameras - such as the A570 - 3 volts is not enough).
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Does get_usb_power() ever return a value other than 0?
« Reply #2 on: 10 / January / 2009, 06:13:35 »
the easiest voltage source to connect and test is ... your PC...

i.e., connecting the camera to the Pc and disconnecting makes a pulse.

Also, pay attention that get_usb_power measures PULSES, i.e. you have to apply voltage AND remove it.

If you just apply voltage, it will keep returning 0 until you remove voltage, and in this case it will return a value proportional to the duration of the pulse (i.e. how long you kept the voltage on)


*

Offline Jucifer

  • *****
  • 251
  • [A710IS]
Re: Does get_usb_power() ever return a value other than 0?
« Reply #3 on: 10 / January / 2009, 07:21:46 »
get_usb_power(1) should return 1 if usb voltage is detected (i.e. doesn't wait for the remote to be released before returning >0)


*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: Does get_usb_power() ever return a value other than 0?
« Reply #4 on: 10 / January / 2009, 08:25:40 »
oooohhh....
one never ends learning!

Re: Does get_usb_power() ever return a value other than 0?
« Reply #5 on: 10 / January / 2009, 12:35:59 »
Great!!!  Success!  Now, some notes...

zeno:  It was the "Enable remote" that made it work.  Thanks!

fbonomi: You seem to describe correctly what my camera does.

Jucifer: You also are correct.  I missed the subtle difference of what you wrote at first.  The difference being
get_usb_power(1)
-versus-
get_usb_power()

With get_usb_power(1), the function reports ONLY 0 or 1; with get_usb_power(), the function reports ONLY 0 or the amount of time.  And with get_usb_power(1), it updates when the level of the usb power changes whereas with get_usb_power(), it updates only when usb power goes low after having gone high.

I'm trying to clarify what I see here for other newbys like myself who may get here by searching the forum.  So for a user who wants to know when usb power is applied, they should use get_usb_power(1).   For someone who wants to know what the pulsewidth is, they should use get_usb_power().

On my SD1100, the command sequence to enable the remote is:

1. turn on camera

2. get in alt mode

3. press "Menu"

4. select "Miscellaneous stuff"

5. select "Remote parameters"

6. choose "Enable Remote"

7. Power off/back on: this item still selected. (I'm never sure which things get remembered and which don't after a power cycle.)

Having only the SD1100, I don't know what works on other models.

Although I searched most of the day yesterday for this information, I never found it.  Does anyone know where these details are explained? 

Thanks again to everyone for your help!!



Was: SD1100 IS, Autobuild, V1.01a, dunked in ocean
Next: SD990 IS, Autobuild, used to build sand castles with
Waiting to die: SX230

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal