Trigger an Arduino board via USB - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

Trigger an Arduino board via USB

  • 42 Replies
  • 13168 Views
Re: Trigger an Arduino board via USB
« Reply #10 on: 12 / September / 2013, 10:22:18 »
Advertisements
Quote
The standard USB remote code is capable of very precise shutter release timing if you use the right sequence.  With the switch mode set to "One Press" and "Sync" enabled, have your Arduino assert the 5V line prior to when you need to release the shutter and hold it high.  When you want to shoot,  set the 5V line to 0V.  You should get a shot less than a few milliseconds later and that delay will be very consistent from shot to shot.
I made many test with different interval between shots (2,3,4,5 sec) and different transition timing between 5 and 0V (100ms - 1 sec) but the range of the delays is always 100-300ms.

I'll admit to not being able to follow what has been described in this thread and the other one.

You seem to be running lapser's script that shoots in continuous mode while also trying to use  a USB remote signal to somehow trying to shoot as well.

I'd suggest disabling the script and simply using your Arduino to trigger shots via CHDK's USB remote functionality.  You should get rock solid intervals.

But I might be totally missing what you are trying to do here.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Trigger an Arduino board via USB
« Reply #11 on: 12 / September / 2013, 12:47:31 »
Sorry,

  I didn't start from the beginning...

The goal is to trigger the camera from the Arduino board and to know the exactly delay between the triggering and the shot. This because I need to log position, attitude, etc on the istant of the shot.

My first attempt was with the standard remote functionality but after many test (all in manual mode, manual focus, no preview, etc) the delay is random in a range of 100-300 ms, too much for me.

So I tried to use the usblapse of lapser. He modified it to be triggered from the USB but it seems not working so well (watch the video). Without the external triggering works very well.

 

Re: Trigger an Arduino board via USB
« Reply #12 on: 12 / September / 2013, 16:47:07 »
The goal is to trigger the camera from the Arduino board and to know the exactly delay between the triggering and the shot. This because I need to log position, attitude, etc on the istant of the shot.
My first attempt was with the standard remote functionality but after many test (all in manual mode, manual focus, no preview, etc) the delay is random in a range of 100-300 ms, too much for me.
So unless there is something wrong with the CHDK port for your camera,  the following sequence should work :

1) Enable USB remote,  one press switch mode,  normal output mode, sync enabled
2) Set the 5V signal high for at least 2 seconds (to allow focus & exposure setting)
3) Release the 5V signal when you want to shoot.

The between when you release the 5V signal in step 3 and the actual picture is taken should be very accurate and consistent- less than 10 mSec for sure and usually less than 1 mSec.

Note that the camera will time-out if step two is held for too long -  I think its about 1 minute.  Will look that up later to confirm.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Trigger an Arduino board via USB
« Reply #13 on: 12 / September / 2013, 17:05:41 »
I'll try again and I'll tell you.

Thanks


*

Offline lapser

  • *****
  • 1093
Re: Trigger an Arduino board via USB
« Reply #14 on: 12 / September / 2013, 17:29:19 »
My goal is to shot a picture exactly every 2 sec because i've to log on the Arduino parameters in synch with the pictures.

I send to the USB, for example, this square wave: t0=5V t1=0V t2=0V with t0=0ms, t1=100ms and t2=3000ms but the camera shots every 3200ms, 2500ms, 3300ms...
@waterwingz,

Thanks for your input. I'm sorry for the confusion. The initial message above was sent privately.

I think the t0 parameter may be wrong, but I'm not sure what the parameters mean on the Arduino. It looks like he's not holding 5 volts at all (0 ms) and he's holding 0 volts for 3.1 seconds. This would explain the problem.

@lukeiron, will you try these parameters with both scripts?

t0=5 volts, 1900 msec
t1=0 volts, 100 msec
t2=0 volts, 0 msec

To change the interval, I think you would adjust  t0 = interval-100

Someone familiar with the Arduino, please correct me if this is wrong. Thanks.

This should work with my original script. Also, the script will log the actual measured interval between the shots so you can see how accurate it is. After running the script, you can see the results with "Display last console" in the Miscellaneous/Console sub-menu.

Also, see if this works without my script with the CHDK remote trigger in sync mode. The CHDK geniuses have spent a lot of time on sync mode trying to get multiple cameras to take pictures at the same time. The camera tick counter changes every 10 msec, but somehow they've achieved time sync in the 1 msec range. waterwingz says that the delay from the Arduino sending the triggering pulse to the camera taking the shot is constant. Once you know that delay, you can add it to the time of the pulse and know the exact time of each picture.

If CHDK sync works, then hopefully we can get it to do the synch while a script is running. That is, the script presses the shutter to start the shot, and the CHDK sync holds it, right before shutter open, until the remote triggers it. This would work with my full time lapse script and allow you to adjust exposure between shots at over 1 shot per second, like I do for sunsets.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: Trigger an Arduino board via USB
« Reply #15 on: 12 / September / 2013, 17:50:01 »
1) Enable USB remote,  one press switch mode,  normal output mode, sync enabled
2) Set the 5V signal high for at least 2 seconds (to allow focus & exposure setting)
3) Release the 5V signal when you want to shoot.
Thanks! In continuous drive mode, shouldn't step #1 be "Burst" control mode, not "Normal"?

Also, I noticed an "Enable Script Start" check box. Maybe that would work with a time lapse script? After you get the Arduino working to trigger the camera reliably, try this:

check: Enable Remote
select: one-push
control mode: disable
check: Enable sync

Then run this script:

Code: [Select]
--[[
@title USBTest 130912
--]]
--MUST BE IN CONTINUOUS MODE
nshot=1
print("Holding shoot_full")
print("Press <menu> to exit")
press("shoot_full") -- continuous mode
repeat
  wait_click(10)
  if(get_shot_ready())then
    print(nshot,get_shot_data(4)) -- shot #, interval from last shot
    nshot=nshot+1
  end
until is_key("menu")
I really need to wire up a remote USB switch to check this out.I haven't burned my fingers on a soldering gun in awhile, so it should be fun.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Trigger an Arduino board via USB
« Reply #16 on: 12 / September / 2013, 19:37:41 »
Quote
think the t0 parameter may be wrong, but I'm not sure what the parameters mean on the Arduino. It looks like he's not holding 5 volts at all (0 ms) and he's holding 0 volts for 3.1 seconds. This would explain the problem.

@lapser
At t1 there's the transition from 5V to 0V... so i had the 5V for 100ms and 0V for 2.900ms.
I attached a diagram of a similar example some post ago.
With Arduino is very easy to write code to control I/O ports, if you want to start some project I'll be happy to help you.

Tomorrow I'll try the new script.

@waterwingz
I tried to enable the synch and it works well! Now the shooting is costant.
Unluckily I can't take more pictures than 1 every 2.5sec. Under this interval the camera don't recognize the transition of the USB and so it had to wait the next one (one shot mode and continous mode).







*

Offline lapser

  • *****
  • 1093
Re: Trigger an Arduino board via USB
« Reply #17 on: 12 / September / 2013, 20:36:21 »
At t1 there's the transition from 5V to 0V... so i had the 5V for 100ms and 0V for 2.900ms.
OK, that's backwards. You need to hold 5 volts most of the time (interval-100msec), and 0 volts for 100 msec. Then my original script should work.
Quote
I tried to enable the synch and it works well! Now the shooting is costant.
Unluckily I can't take more pictures than 1 every 2.5sec. Under this interval the camera don't recognize the transition of the USB and so it had to wait the next one (one shot mode and continous mode).
Make sure the camera is in continuous drive mode, and try the CHDK remote parameter/ control mode "burst"
I think that will give you up to 2 shots per second. My original script should do the same thing.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


Re: Trigger an Arduino board via USB
« Reply #18 on: 13 / September / 2013, 01:19:28 »
@waterwingz
I tried to enable the synch and it works well! Now the shooting is costant.
Unluckily I can't take more pictures than 1 every 2.5sec. Under this interval the camera don't recognize the transition of the USB and so it had to wait the next one (one shot mode and continous mode).
That's about normal if you are not in continuous shooting mode. You can tweak the intervals to try and get the next USB pulse to come right after the previous shot finishes - I'm thinking you can get to just under 2 seconds per shot that way.

I'm not going to try to follow all of lapser's various posts on this subject - you are on your own there.  :)
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Trigger an Arduino board via USB
« Reply #19 on: 13 / September / 2013, 01:28:43 »
I'm not going to try to follow all of lapser's various posts on this subject - you are on your own there.  :)
I can't even follow them myself sometimes! Let me rephrase it as 2 questions:

Can you do remote sync in continuous mode at over 1 shot per second?

Can you do remote sync in continuous mode with a script holding the shutter down and processing the photos?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics