Pages: [1]   Go Down
  Print  
Author Topic: get_usb_power always returns '1'  (Read 813 times)
0 Members and 1 Guest are viewing this topic.
chrissnell
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 18


« on: 21 / May / 2008, 03: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:
@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

Logged

NW5W High Altitude Balloon Project
http://nw5w.com/journal/
zeno
Full Member
***

Karma: +13/-1
Offline Offline

Posts: 107


« Reply #1 on: 21 / May / 2008, 09:21:37 »

Which camera are you runing the test on? Not all support get_usb_power.
Logged
chrissnell
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 18


« Reply #2 on: 21 / May / 2008, 15: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.
Logged

NW5W High Altitude Balloon Project
http://nw5w.com/journal/
PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +121/-27
Offline Offline

Posts: 1624


Coders Humiliate DSLR Kiddies


« Reply #3 on: 21 / May / 2008, 16: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.
Logged

Jucifer
Global Moderator
Full Member
*****

Karma: +41/-0
Offline Offline

Posts: 221


[A710IS]


« Reply #4 on: 21 / May / 2008, 16: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:
@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.)
Logged

PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +121/-27
Offline Offline

Posts: 1624


Coders Humiliate DSLR Kiddies


« Reply #5 on: 21 / May / 2008, 17:35:12 »

good question. hm.
Logged

zeno
Full Member
***

Karma: +13/-1
Offline Offline

Posts: 107


« Reply #6 on: 21 / May / 2008, 17: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:
@title test remote
do
  do
    a = get_usb_power
  until a>0
  print a
until is_key "set"
end
Logged
chrissnell
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 18


« Reply #7 on: 22 / May / 2008, 06: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, 06:33:25 by chrissnell » Logged

NW5W High Altitude Balloon Project
http://nw5w.com/journal/
zeno
Full Member
***

Karma: +13/-1
Offline Offline

Posts: 107


« Reply #8 on: 22 / May / 2008, 08: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.
Logged
chrissnell
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 18


« Reply #9 on: 22 / May / 2008, 14:20:24 »

Zeno, that would be great!
Logged

NW5W High Altitude Balloon Project
http://nw5w.com/journal/
zeno
Full Member
***

Karma: +13/-1
Offline Offline

Posts: 107


« Reply #10 on: 22 / May / 2008, 17:50:23 »

Chris - I'm not promising anything, but try the DISKBOOT.BIN here
http://www.zenonic.demon.co.uk/zips/DISKBOOT.BIN

Dave
Logged
PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +121/-27
Offline Offline

Posts: 1624


Coders Humiliate DSLR Kiddies


« Reply #11 on: 22 / May / 2008, 20: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.
Logged

chrissnell
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 18


« Reply #12 on: 01 / June / 2008, 05: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
Logged

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

Karma: +0/-0
Offline Offline

Posts: 18


« Reply #13 on: 01 / June / 2008, 06: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
Logged

NW5W High Altitude Balloon Project
http://nw5w.com/journal/
Pages: [1]   Go Up
  Print  
 
Jump to: