Script to retract lens into the body, UAV mapping

  • 23 Replies
  • 4129 Views
Re: Script to retract lens into the body, UAV mapping
« Reply #10 on: 15 / November / 2014, 12:20:30 »
Advertisements
uBASIC debugging is very painful as the error messages are very close to meaningless.  Lua is a much better way to do scripting in CHDK.  However, in your case, the line that says  :

Code: [Select]
print "Ch1Up-Shoot; k
is missing a second quotation mark

Code: [Select]
print "Ch1Up-Shoot"; k
That might be the problem.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #11 on: 15 / November / 2014, 12:27:28 »
heres another idea, if a photo hasnt been taken in a certain amount of time then retract lens
That's a good idea. However, as I mentioned earlier, pressing the DISP button is not going to cause the lens to retract.  Please see my previous post for a better way to do that.


are there any tutorials for writing scripts? it would be handy to know how to properly write the various statements as they are nothing like the c i am used to
Quite a bit of work went into this wiki page : CHDK Scripting Cross Reference Page.  You might find it helpful. 

And if you have experience programmnig in C, then I would strongly recommend taking an hour or two and reading up about Lua.  It's a far more powerful scripting language with much better error detection and error messages.  Programming in uBASIC for anything non-trivial is a painful exercise.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #12 on: 15 / November / 2014, 12:41:23 »
thanks for the comments, ill give lua a look.

ive been looking through the reference page. its given me some ideas but i need to know how to apply it.

Re: Script to retract lens into the body, UAV mapping
« Reply #13 on: 15 / November / 2014, 12:43:53 »
but i need to know how to apply it.
Read some of the published scripts and then practice.   Did my earlier post fix the issue with your first script?
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Script to retract lens into the body, UAV mapping
« Reply #14 on: 15 / November / 2014, 13:30:38 »
yes it did, turned out i had carried the error to all my other versions. doing some testing and hope to find one that retracts the lens.

Re: Script to retract lens into the body, UAV mapping
« Reply #15 on: 15 / November / 2014, 13:35:13 »
doing some testing and hope to find one that retracts the lens.
Is there some part of this hint that is not clear ? >>>

The secret to managing the lens extension & retraction is to have the script switch the camera between shooting & playback modes with the  Canon Lens Retract setting set to 0 sec.
Perhaps a further hint will help? set_record
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #16 on: 15 / November / 2014, 14:00:50 »
i set the lens to retract immediately, as suggested. missed the other part of the hint but ive heard the latest loud and clear  :D

Re: Script to retract lens into the body, UAV mapping
« Reply #17 on: 15 / November / 2014, 14:34:29 »
@title  APM shooterV6
rem by Ben Harvey Benny_H88, modified version of 3dr_shoot.bas



while 1
   do
      k = get_usb_power
   until k>0
   if k < 5 then gosub "ch1down"   
   if k > 4 and k < 8 then gosub "ch1mid"
   if k > 7 and k < 11 then gosub "ch1up"
   if k > 10 then print "error"
wend
end

:ch1up
   print "Shoot"
   set_record(true)
   while not get_mode() do
      sleep(10)
   shoot
   return

:ch1mid
   print "Wait"
   sleep 500
   return

:ch1down
   print "Stowed"
   set_record(false)
   while get_mode() do
     sleep(10)
   sleep 1000
   return


ok what am i doing wrong this time?
it wont take a photo, wont even do my prints, my guess is that i'm getting hung up in the while loops


Re: Script to retract lens into the body, UAV mapping
« Reply #18 on: 15 / November / 2014, 14:58:00 »
ok what am i doing wrong this time?
Well, to start with,  you have an interesting mix of Lua and uBASIC syntax there.  The link zeno posted for you ( http://www.zenoshrdlu.com/kapstuff/zubdb.html ) will likely save you a lot of time if you use the debugger first.

Meanwhile,  try this :

Code: [Select]
while 1
   do
      k = get_usb_power
   until k>0
   if k < 5 then gosub "ch1down"   
   if k > 4 and k < 8 then gosub "ch1mid"
   if k > 7 and k < 11 then gosub "ch1up"
   if k > 10 then print "error"
wend
end

:ch1up
    print "Shoot"
    set_record 1
    while get_mode = 1 do
      sleep 50
    wend
    shoot
    return

:ch1mid
   print "Wait"
   sleep 2000
   return

:ch1down
   print "Stowed"
   set_record 0
   while get_mode = 0 do
     sleep 50
   wend
   sleep 1000
   return
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script to retract lens into the body, UAV mapping
« Reply #19 on: 15 / November / 2014, 15:10:08 »
@title  APM shooterV8
rem by Ben Harvey Benny_H88, modified version of 3dr_shoot.bas



while 1
   do
      k = get_usb_power
   until k>0
   if k < 5 then gosub "ch1down"   
   if k > 4 and k < 8 then gosub "ch1mid"
   if k > 7 and k < 11 then gosub "ch1up"
   if k > 10 then print "error"
wend
end

:ch1up
   print "Shoot"
   set_record(1)
   sleep(20)
   shoot
   return

:ch1mid
   print "Wait"
   sleep 500
   return

:ch1down
   print "Stowed"
   set_record(0)
   sleep(20)
   sleep (1000)
   return


This one has cracked it. Turns out the lead i butchered for my trigger has a bad connection somewhere.

 

Related Topics