USB pulse receiving script - Script Writing - CHDK Forum supplierdeeply

USB pulse receiving script

  • 6 Replies
  • 2358 Views
USB pulse receiving script
« on: 07 / April / 2010, 18:17:47 »
Advertisements
I've been working on a script for about a month now that takes in 5 pulses from a microcontroller, each about 1.25s apart.  After the camera receives each pulse, it sets predetermined camera settings and takes a picture.

The problem is that the script is Very unreliable.  It takes anywhere from 1-5 pictures, usually around 2 or 3.  I put the camera in Program and Continuous mode.

Any help at all would be appreciated.  I'm thinking about converting the script to LUA to see if it'll improve reliability and speed.  I'm using a Powershot A2000 IS.  I'm not sure if it's my camera settings (turned flash off) or the script itself.

If you notice any red flags in my code (settings that may be taking a long time to process) or settings that I should make sure my camera is in (so that it doesn't auto-focus or anything), this is what I'm particularly interested in.

Thanks.
Code: [Select]
@title Penta-Camera Capture

print "@@ Started Script"
n=0
gosub "Setting0"
n=0

while 1
  wait_click 1
  if is_key "remote" then gosub "SelectOption"
wend
end
:SelectOption
  print "Option Select"
  if n = 4 then gosub "Capture4"
  if n = 3 then gosub "Capture3"
  if n = 2 then gosub "Capture2"
  if n = 1 then gosub "Capture1"
  if n = 0 then gosub "Capture0"
  if n = 5 then n = 0
  return
:Capture
  press "shoot_full"
  sleep 20
  release "shoot_full"
  sleep 150
  return
:Capture0
  press "shoot_half"
  sleep 150
  gosub "Capture"
  print "Capture 0"
  gosub "Setting1"
  return
:Capture1
  gosub "Capture"
  print "Capture 1"
  gosub "Setting2"
  return
:Capture2
  gosub "Capture"
  print "Capture 2"
  gosub "Setting3"
  return
:Capture3
  gosub "Capture"
  print "Capture 3"
  gosub "Setting4"
  return
:Capture4
  gosub "Capture"
  release "shoot_half"
  print "Capture 4"
  gosub "Setting0"
  return
:Setting0
  
  set_zoom 0
  set_iso 3
  rem set_focus 200
  set_av 10
  rem set_tv 35
  n=5
  print "Setting 0 Ready"
  
  return
:Setting1
  set_zoom 0
  set_iso 4
  rem set_focus 300
  set_av 17
  rem set_tv 35
  n=1
  print "Setting 1 Ready"
  return
:Setting2
  set_zoom 0
  set_iso 50
  rem set_focus 100
  set_av 14
  rem set_tv 35
  print "Setting 2 Ready"
  n=2
  return
:Setting3
  set_zoom 0
  set_iso 400
  rem set_focus 50
  set_av 18
  rem set_tv 35
  print "Setting 3 Ready"
  n=3
  return
:Setting4
  set_zoom 0
  set_iso 200
  rem set_focus 500
  set_av 9
  rem set_tv 35
  print "Setting 4 Ready"
  n=4
  return
« Last Edit: 07 / April / 2010, 20:03:04 by calyn »

Re: USB pulse receiving script
« Reply #1 on: 08 / April / 2010, 14:03:16 »
New note:

After doing much reading on these forums, it seems that it's fairly easy to turn on the different LEDs on the camera and attach a photodiode to detect the LED.  Well, I believe instead of using a microcontroller to send pulses, I could use the camera's LED and a photodiode to send pulses to an external set of LEDs that the microcontroller was controlling (so different light intensities could be controlled).

If anyone has experience with anything like this, or any suggestions, I'd really appreciate it.  Links to other threads are always helpful as well.

Thanks.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: USB pulse receiving script
« Reply #2 on: 08 / April / 2010, 14:21:55 »
I've been working on a script for about a month now that takes in 5 pulses from a microcontroller, each about 1.25s apart.  After the camera receives each pulse, it sets predetermined camera settings and takes a picture.

You're working quite close to the highest continuous mode shooting rate possible, there probably isn't enough time for the cam to do all your script stuff in between pulses. Try with uC pulses further apart and squeeze it down until it works reliably (make sure you try with maximum quality JPEGs in maximum and minimum resolutions with ISO 400 if you need everything to work reliably -- noise reduction takes a while as does scaling and writing to an SD card...also writing to a large SD card full of photos may slow down continuous mode rate).

Since it almost works, converting to Lua might help because each line of ubasic wastes 10 ms and with Lua you could get rid of some of all of that delay.

Re: USB pulse receiving script
« Reply #3 on: 08 / April / 2010, 16:33:21 »
After devouring these forums for something close to what I'm attempting to do, I've noticed that my approach may be flawed.  The only reason I use a microcontroller is so that I can simultaneously send pulses to both the Camera and the LED fixture.  The LED fixture simply takes in a pulse and alternates which LEDs are lit.

It seems that if I use a photodiode attached to the camera to send a pulse, I may not even have to mess with a microcontroller.

Thoughts?  If I should make a new thread for this discussion, just let me know.


Re: USB pulse receiving script
« Reply #4 on: 08 / April / 2010, 17:32:14 »
it seems that it's fairly easy to turn on the different LEDs on the camera and attach a photodiode to detect the LED.
If anyone has experience with anything like this, or any suggestions, I'd really appreciate it. 

Yes, no problem, see the 'send_data' command here http://stereo.jpn.org/eng/sdm/ubasic.htm

Here is a commercial device that uses that command to send messages to a microcontroller that controls a pan-and-tilt rig on a kite :-

http://www.zenoshrdlu.com/clickpansdm/
http://www.gentles.ltd.uk/clickpan/

The device can have a digital output (instead of servo control pulses) and you can specify the polarity.



David

Re: USB pulse receiving script
« Reply #5 on: 08 / April / 2010, 18:05:31 »
Sure, i used this setup:
1. Hardware: The "serial port download solution" from the wiki. http://chdk.wikia.com/wiki/File:UART_receiver.jpeg#
    This is the simple build with only a 10 kOhm resistor and a SFH 300-3/4 photodiode.
    I placed the photodiode direct in front of the G11 AF-Light (ca. 2 cm distance or so..).
    Then i tested if the photodiode works as it should be, in the readme of the COM-Port software (Blinker_Java_Version_by_Syrius\by_grand_blink_g7) is described how to do that.
    (Measure the voltage between comport GND(Pin 5) and RX(Pin 2)).

I couldn't find any hardware diagrams on that commercial device you posted, David, so I dug around and found this little circuit diagram.  I've only worked with photodiodes once before with an IR remote, but I think I should be able to figure out how to wire one up just to look at the UF lamp and send those 2-3 pulses with the send_data command.

Re: USB pulse receiving script
« Reply #6 on: 08 / April / 2010, 18:23:01 »
If you want any more practical information or advice, just contact me directly.

The clickPAN-SDM device uses a phototransistor connected directly to the input of a six-pin microcontroller.

David

 

Related Topics