get_usb_power - Script Writing - CHDK Forum

get_usb_power

  • 20 Replies
  • 11333 Views
get_usb_power
« on: 27 / November / 2007, 14:18:06 »
Advertisements
found on google:

"The "get_usb_power" uBASIC command was implemented due to some requests to find

a way to read the USB port so that 3-5vdc voltage applied to the USB cable could
be read as a data stream, allowing you to send rudimentary morse-codelike

sequences of power to that port. Thus enabling you to trigger different features

on your camera or activating defined subroutines in scripts by these "digitally"
signed events. Since script commands/code-lines cannot be executed faster than

10ms each, think slow-slow-slow serial data. Coupled to the right hardware (or a
well timed morse-code-key finger) this does allow you to perform things like
zoom your lens, or any other of the many dozens of manual camera controls, all

by USB remote control. Provided your script is designed to interpret the voltage
pulses and then execute them properly. Simple tests for duration might suffice
in most instances. Long press = zoom out 10 steps, short press = zoom in 10
steps. 2 short presses = trip shutter, etc."

this is very interesing but how make this in script???

2 seconds usb signal--->execute script 1
4 seconds usb signal--->execute script 2
6 seconds usb signal--->execute script 3
etc...

any ideas?

(moderated edit: Added "Lamp" message icon for easier finding later of useful working scripts.)
« Last Edit: 12 / December / 2007, 16:52:47 by Woodsman »

Re: get_usb_power
« Reply #1 on: 27 / November / 2007, 15:36:46 »
i found this in Fingalo homepage:

"Some testing with remote signaling to see if it is possible to make a multibutton control.

I found that the USB signal need to be at minimum 50-60ms in length in order to be detected at all.
Under this length I could not detect any signals.
Also the length varies a lot, when setting a signal 0.2sec long it will be detected between .19 to .23s.

I just used the length of the signal as a code for a simple test.
5 different signal with following timing (seconds)
0.065,   0.21,   0.33,   0.44,   0.60
In the keydecode routine just adding a counter every 10ms when the USB signal is high and set the value to the usb_power variable when usb signal goes low.
This way I just get a value (in 10ms counts) for USB signal. It is decoded with the following script:

Code: [Select]
@title Remote button

do
  do
    a = get_usb_power
  until a>0

rem remote button 1
  if a>0 and a<15 then
    release "zoom_in"
    release "zoom_out"
  endif

rem remote button 2
  if a>15 and a<25 then press "zoom_in"

rem remote button 3
  if a>25 and a<38 then press "zoom_out"

rem remote button 4
  if a>38 and a<47 then shoot

rem remote button 5
  if a>50 then exit_alt

  if a>0 then print a

rem clear my internal usb_power signal, fix for now.
  wait_click 1
  a = is_key "remote"
until is_key "set"
end


This works stable, but the timing is really not what I expected, I thought it should be a 10ms resolution for the USB signal.
I tested by a 5 V signal from the PC's printer port and a program to time the signal to the camera.
(I have not made any testbuild, it need some cleanup and adjustment to be useful!) "

good work!

Re: get_usb_power
« Reply #2 on: 28 / November / 2007, 14:03:34 »
i found this on net:

http://www.obdev.at/products/avrusb/powerswitch.html
perhaps if make a little change schema - we can control output (5V to control Canon cameras with CHDK) and switch on/off usb signal -and we can control how long signal is On/Off (secs.)

there is GUI program to control from PC http://szczuka.eu/avr/gpowerswitch.php


Re: get_usb_power
« Reply #3 on: 30 / November / 2007, 11:38:00 »
news from FINGALO

"Some testing with remote signaling to see if it is possible to make a multibutton control.

I found that the USB signal need to be at minimum 50-60ms in length in order to be detected at all.
Under this length I could not detect any signals.
Also the length varies a lot, when setting a signal 0.2sec long it will be detected between .19 to .23s.

Function get_usb_power will now give how long the USB signal is active. I leave this decoding to the script as I suspect different cameras can give different timing.
This way you can design your own method for timing, even manual 'keying' is possible, a long or short press on the button.
Note: the 'old' is_key "remote" signal still works the same as before.
Difference between get_sub_power and is_key "remote" is that is_key "remote" is activated as soon as USB power is detected but get_usb_power is set when USB power
go low (giving the lengt of the signal).

I used 5 different signal with following timing (seconds).
0.085,   0.21,   0.33,   0.44,   0.60
This way I just get a value (in 10ms counts) for USB signal. It is decoded with the following script:

Code: [Select]
@title Multi remote

do
  do
  a = get_usb_power
  until a>0
rem remote button 1
  if a>0 and a<15 then
    release "zoom_in"
    release "zoom_out"
  endif
rem remote button 2
  if a>15 and a<25 then
    press "zoom_in"
  endif
rem remote button 3
  if a>25 and a<38 then
    press "zoom_out"
  endif
rem remote button 4
  if a>38 and a<47 then
    shoot
  endif
rem remote button 5
  if a>50 then exit_alt
rem show button timecount (used for calibrating the script)
  if a>0 then print a

until is_key "set"

end

To  calibrate your own timing just use this part of the script to begin with

do
  do
   a = get_usb_power
  until a>0
  if a>0 then print a
until is_key "set"
end

This works stable, but the timing is really not what I expected, I thought it should be a 10ms resolution for the USB signal.
I tested by a 5 V signal from the PC's printer port and a program to time the signal to the camera.


- multi remote on s2is, s3is, a610,  a620,  a630,  a640, a710
(I only publish remote supported cams in this release as it is not useful for the other cams.)"

download beta firmware from Fingalo homepage http://hem.passagen.se/fsmmal/chdk2.html


Re: get_usb_power
« Reply #4 on: 30 / November / 2007, 11:56:46 »
BRAVO FINGALO
I must tested it

I have one questions to you
-how you send to printer port short signals (which one pin printer port and windows? command) ?
this is very interesing

now we make simple GUI interface and you fantastic CHDK firmware and we have program to control camera from PC (live view from analog output?) like PSRemote
but this program is not freeware and don`t recognize my 710IS
http://www.breezesys.com/PSRemote/features.htm#ps

*

Offline a710is

  • ****
  • 250
  • A710 IS
Re: get_usb_power
« Reply #5 on: 30 / November / 2007, 12:16:03 »
works great on my a710
I've done some benchmarks on myself  ;D
on my particular button, a short click is usually between 0.10s and 0.30s
if I try to get a tad longer time I seem to be getting between 0.40 and 0.99 s
it could probably work fine in morse code or with definable intervals so that every user can set his own time interval for various tasks
between x and y tens/hundreds of a sec do z
between t and v tens/hundreds of a sec do w
etc.
this is awesome and soon enough it will do stuff
that being said... I wonder what you'd want the camera to do ;D , apart from shooting pics and movies cause I don't have too many ideas.

Re: get_usb_power
« Reply #6 on: 02 / December / 2007, 11:36:11 »
i test new Fingalo firmware pre14.grand148.md.cln.zsm-a710-100a-128.zip on my 710is
i change time in script:

Code: [Select]
@title Multi remote

do
  do
  a = get_usb_power
  until a>0
rem remote button 1
  if a>0 and a<200 then
    release "zoom_in"
    release "zoom_out"
  endif
rem remote button 2
  if a>200 and a<300 then
    press "zoom_in"
  endif
rem remote button 3
  if a>300 and a<400 then
    press "zoom_out"
  endif
rem remote button 4
  if a>400 and a<500 then
    shoot
  endif
rem remote button 5
  if a>500 then exit_alt
rem show button timecount (used for calibrating the script)
  if a>0 then print a

until is_key "set"

end

and set Autobooting and Remote enable in menu-power up camera -script is ON

and testing testing testing

sometimes this script work fine sometimes not and i don`t now why

i plug in and plug out camera from PC usb for 1...2..3...4..5..6.. second and see what camera do

sometimes "zoom in" work and then nothing happend on LCD -i plug in/off camera from PC and new value "a" not show

sometimes "zoom in" work OK and i plug in camera for few seconds and plug out -on CHDK screen i see 387 (value a) BUT "zoom out" NOT WORK -but why ?

 

Re: get_usb_power
« Reply #7 on: 02 / December / 2007, 13:02:27 »
For ex. using press "zoom_in" you will have to stop zooming with release "zoom_in".
I tried to use the commands set_zoom_speed x and set_zoom x instead, but these are not working very well, the camera will shut down almost every time after giving these commands. There is a bugreport about that on the Wiki since June.


Re: get_usb_power
« Reply #8 on: 02 / December / 2007, 13:20:41 »
THX Fingalo
I have one questions
you wrote on homepage "I tested by a 5 V signal from the PC's printer port and a program to time the signal to the camera."
PLEASE tell me how you send some short signal to printer port (pin 1 and 2? http://spin.siedziba.pl/hwb/connector/serial/rs232.html)
you use program like this:
http://www.seetron.com/sersend2.zip   ?
i found this page http://www.seetron.com/ser_an1.htm with some info about RS232 but you probably make this very simple ;)
 

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: get_usb_power
« Reply #9 on: 02 / December / 2007, 13:32:43 »
Mr Cat
Printer port (LPT) is not the same as the RS-232 (COM, Serial). Printer port has 8 data pins, which has 5V on it if you send '1' and 0V in case of '0'. RS-232 operates with more voltage (+-12V) and useless in our case.

Some years ago, to access to LPT port directly from my own program from WinXP I used giveio.sys driver and wrote data directly to the LPT1 port (0x378, AFAIR).
CHDK Developer.

 

Related Topics