Author Topic: get_usb_power always returns '1'  (Read 1767 times)

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
get_usb_power always returns '1'
« on: 21 / May / 2008, 07:59:38 »
Hi,

I'm having a problem with the get_usb_power function.  When power is applied to USB, it returns 1, regardless of the pulse duration.  Is this a regression or did I miss something?

I'm running an 11 April 2008 build of Allbest #50.  Here's the script I'm running:

Code: [Select]
@title RemoteTest2

do
  do
  a = get_usb_power
  until a>0
  if a>0 and a<200 then
    print "0 - 200"
  endif
  if a>200 and a<300 then
   print "200 - 300"
  endif
  if a>300 and a<400 then
   print "300 - 400"
  endif
  if a>400 and a<500 then
   print "400-500"
  endif
  if a>500 then
   print "500+"
  endif
  if a>0 then print a
until is_key "set"
end

Thanks,

Chris

NW5W High Altitude Balloon Project
http://nw5w.com/journal/

Offline zeno

  • Hero Member
  • *****
  • Posts: 503
Re: get_usb_power always returns '1'
« Reply #1 on: 21 / May / 2008, 13:21:37 »
Which camera are you runing the test on? Not all support get_usb_power.

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
Re: get_usb_power always returns '1'
« Reply #2 on: 21 / May / 2008, 19:39:52 »
Which camera are you runing the test on? Not all support get_usb_power.

I'm running on an A720 IS.  It does seem to detect the presence of voltage on the line--get_usb_power returns 0 if there's no voltage--but not the duration.
NW5W High Altitude Balloon Project
http://nw5w.com/journal/

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: get_usb_power always returns '1'
« Reply #3 on: 21 / May / 2008, 20:14:50 »
this is common behaviour. it can only detect the presence, not the duration. you have to implement that functionality via the use of a script. there are scripts somewhere on the forum that have this functionality, please use the search, i dont know where they are at the moment.

Offline Jucifer

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 251
  • [A710IS]
Re: get_usb_power always returns '1'
« Reply #4 on: 21 / May / 2008, 20:58:07 »
fingalo has this on his CHDK page:

Quote
Remote control 4 functions with one button

I made a small script for using my remote button.
With autostart on and the following script I get 4 functions (on the s3is)
I can use it with my cable remote or with my radio remote, just by timing the press of the button.

1. Short press turn camera on, extend the lens.
2. Short press will take a picture
3. A bit longer press will take a picture with flash (if flash is lifted)
4. Looong press (>4 seconds) will turn camera off.

Very simple but useful!

(Next step is to add a small microcomputer (or a timer circuit) in the remote to detect several buttons and generate the timing, then you would not have to use 'camera Morse' code.)

Code: [Select]
@title Remote button
if get_autostart then
  sleep 2000
  set_autostart 0
  press "shoot_half"
  sleep 500
  release "shoot_half"
endif
do
  do
    a = get_usb_power
  until a>0
  if a<50 then
    shoot
  else   
    if a>400 then
      shut_down
    else
      set_prop 16 2
      shoot
      set_prop 16 0
    endif
  endif
until is_key "set"
end

I don't know if different cameras have different get_usb_power functionality. (Can't test my A710, don't have an USB remote.)

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: get_usb_power always returns '1'
« Reply #5 on: 21 / May / 2008, 21:35:12 »
good question. hm.

Offline zeno

  • Hero Member
  • *****
  • Posts: 503
Re: get_usb_power always returns '1'
« Reply #6 on: 21 / May / 2008, 21:39:10 »
Here's a simpler test. When you run this script, the LCD should indicate how long power has been applied. It will keep on doing this until you press Set (or the shutter to interrupt the script).
Code: [Select]
@title test remote
do
  do
    a = get_usb_power
  until a>0
  print a
until is_key "set"
end

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
Re: get_usb_power always returns '1'
« Reply #7 on: 22 / May / 2008, 10:31:36 »
This test isn't going to work because get_usb_power is always returning 1, regardless of duration.

The only way I've come up with is to do something like I've described in this graphic.
« Last Edit: 22 / May / 2008, 10:33:25 by chrissnell »
NW5W High Altitude Balloon Project
http://nw5w.com/journal/

Offline zeno

  • Hero Member
  • *****
  • Posts: 503
Re: get_usb_power always returns '1'
« Reply #8 on: 22 / May / 2008, 12:37:08 »
Chris - I've just looked at the source for the routine get_usb_power for the A720 and it's no wonder it always returns 1 - the normal code is commented out and replace with "return remote_key").

I've no idea why the code is commented out like this - presumably someone tested the A720 and found that there's a problem. If you like I can produce a build that has the normal code and you can give it a try.

CHDK Forum

Re: get_usb_power always returns '1'
« Reply #8 on: 22 / May / 2008, 12:37:08 »

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
Re: get_usb_power always returns '1'
« Reply #9 on: 22 / May / 2008, 18:20:24 »
Zeno, that would be great!
NW5W High Altitude Balloon Project
http://nw5w.com/journal/

Offline zeno

  • Hero Member
  • *****
  • Posts: 503
Re: get_usb_power always returns '1'
« Reply #10 on: 22 / May / 2008, 21:50:23 »
Chris - I'm not promising anything, but try the DISKBOOT.BIN here
http://www.zenonic.demon.co.uk/zips/DISKBOOT.BIN

Dave

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: get_usb_power always returns '1'
« Reply #11 on: 23 / May / 2008, 00:14:06 »
hah funny, all the time i was under the impression it only returns 1 if voltage present. i thought the scripts that emulate different functions through the duration of usb voltage present used the tickcount (which is also possible). sorry for maybe giving misleading information.

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
Re: get_usb_power always returns '1'
« Reply #12 on: 01 / June / 2008, 09:35:47 »
Disregard my post to the other thread, Zeno.  It's working now!

get_usb_power appears to be returning in multiples of 1/100th of a second.  So, raising power high for 3 seconds will return a 300, +/- a few.

This is awesome!  Hope you can get this code merged in allbest.

thanks again,

Chris
NW5W High Altitude Balloon Project
http://nw5w.com/journal/

Offline chrissnell

  • Rookie
  • *
  • Posts: 18
    • NW5W High Altitude Balloon Project
Re: get_usb_power always returns '1'
« Reply #13 on: 01 / June / 2008, 10:45:48 »
Hmm, get_usb_power is working but another strange issue has cropped up:

For some reason, the shutter button is not being released, even if I do a release "shoot_full".  Same thing happens when I use the basic "shoot" command.

Because the shutter button isn't being released, my camera will take a picture and then the LCD will display the picture just taken and never return to take another picture.  You can simulate this on your camera by pressing the shutter and just holding it down. 

If we could get this little problem solved, I think that my script would be golden and I'll have a camera that's ready to launch on my balloon.

Chris
NW5W High Altitude Balloon Project
http://nw5w.com/journal/

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal