KAP & UAV Exposure Control Intervalometer Script - page 39 - Completed and Working Scripts - CHDK Forum
supplierdeeply

KAP & UAV Exposure Control Intervalometer Script

  • 1068 Replies
  • 343189 Views
Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #380 on: 20 / April / 2015, 14:11:03 »
Advertisements
Quote from: waterwingz
I guess the first question is how many discrete commands you want to give?  Shoot, zoom in, zoom out, shutdown ?
My use case (orthophoto for aerial surveys) only requires three instructions: "mission start", "shoot", and "mission end". Your script takes the first pulse (any length) as mission start, so I really need only two distinct commands, meaning I don't need a lot of resolution. Right now the APM configuration limits the PWM min and max values to 800 and 2200us (pixhawk hardware can probably do a lot better, but that might mean messing with the [open source!] firmware, which I am not ready to do, as I don't want to destroy my expensive hardware in a crash), so I should be able to use 800us as baseline, 1500us as "shoot", and 2200us as "mission end".

Now I am getting into unknown territory, so I need to understand this process completely:
Assuming my camera has a fast processor, if I recompile CHDK with "CAM_REMOTE_HIGHSPEED_LIMIT 250", I would be able to measure pulses with a 250us resolution. Taking into account the limitations imposed by APM, that would leave me with 750, 1000, 1250, 1500, 1750, and 2000us. I need one of those values for the "no command" state, so that nets me 5 commands. Useful for some, but a waste for me. Maybe I can use a lower resolution? That would mean I don't have to drive my camera hardware so hard, it might be more compatible with slow hardware, and it will probably consume less battery, right?
If I use a CAM_REMOTE_HIGHSPEED_LIMIT value of 700, I get a baseline of 700us, and two usable values at 1400us and 2100us. The mapping would be:

Source (Pixhawk)     -      Destination (Camera)
      800us                        700us   --> Baseline (awaiting instructions)
     1500us                       1400us   --> Shoot
     2200us                       2100us   --> Mission end

This mapping allows the benefit of sending a pulse 100us longer than needed, that might be useful if the camera clock is not very precise...
Am I correct? Did I miss something? Do you have any suggestions?

Quote
Let us know if you need a custom build to try this out.
Unfortunately I don't have the camera with me, and I will not be getting it at least for a month, so right now all I can do is write very long posts... But assuming this change has low chances of bricking my camera I will definitely ask for a custom build.

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #381 on: 20 / April / 2015, 15:20:17 »
A few extra thoughts:

If this gets implemented, the message to the camera would become very small, and it would get buried in a lot of noise... So in order for this to work there should be a way for the camera to disregard the noise (baseline 800us pulses), and only report the signal (1500us and 2200us pulses). I don't know how easy or hard this might be. Do LUA scripts get compiled and then run using native camera code or are they interpreted every time? The answer to that question might determine if the code that detects the signal vs the noise should be implemented in firmware code (fast?) or LUA code (slow if interpreted?), as this code would be executed a lot.

For how long should the pixhawk hardware send the 1500us and 2200us pulses? I believe this will depend on how long it takes the camera to run one loop of the script... If the pixhawk sends the pulse for a very short time and the timing is such that the camera misses reading it, the signal might get lost... On the other hand, if the signal is sent for too long, the camera might take the same action twice...
Has anybody timed the shortest & longest time to run a complete loop? The longest time will probably vary if for example the camera has to write the log to disk, or perform other actions...

Finally, the signal will probably be repeated a few times, I wonder how the camera reads that. If for example it constantly reads for a signal and buffers, and then sends whatever it buffered when the LUA script asks, this whole thing might be difficult to implement... I don't know if I can get the pixhawk hardware send only one 1500us pulse and then revert to 800us.

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #382 on: 20 / April / 2015, 16:00:15 »
If this gets implemented, the message to the camera would become very small, and it would get buried in a lot of noise... So in order for this to work there should be a way for the camera to disregard the noise (baseline 800us pulses), and only report the signal (1500us and 2200us pulses). I don't know how easy or hard this might be. Do LUA scripts get compiled and then run using native camera code or are they interpreted every time? The answer to that question might determine if the code that detects the signal vs the noise should be implemented in firmware code (fast?) or LUA code (slow if interpreted?), as this code would be executed a lot.
The high precision pulse counting / measurement code runs in a interrupt service routing written in C.  There is a Lua call to allow it to read buffered data from that routine.

Quote
For how long should the pixhawk hardware send the 1500us and 2200us pulses? I believe this will depend on how long it takes the camera to run one loop of the script... If the pixhawk sends the pulse for a very short time and the timing is such that the camera misses reading it, the signal might get lost... On the other hand, if the signal is sent for too long, the camera might take the same action twice...

This can be fairly easily handled in the Lua code.   But rather than continue worrying about the various "armchair theories" it would be better to just hook up the camera to a RC receiver and try it.
 

Quote
Has anybody timed the shortest & longest time to run a complete loop? The longest time will probably vary if for example the camera has to write the log to disk, or perform other actions...
I don't think this will be much of an issue.

Quote
Finally, the signal will probably be repeated a few times, I wonder how the camera reads that. If for example it constantly reads for a signal and buffers, and then sends whatever it buffered when the LUA script asks, this whole thing might be difficult to implement... I don't know if I can get the pixhawk hardware send only one 1500us pulse and then revert to 800us.
This can be fairly easily handled in the Lua code.
« Last Edit: 20 / April / 2015, 16:01:58 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #383 on: 20 / April / 2015, 16:07:20 »
This can be fairly easily handled in the Lua code.   But rather than continue worrying about the various "armchair theories" it would be better to just hook up the camera to a RC receiver and try it.
 be fairly easily handled in the Lua code.
I'm itching to try this out, unfortunately I won't be able to for at least a month  :'(


Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #384 on: 20 / April / 2015, 18:22:30 »
I'm itching to try this out, unfortunately I won't be able to for at least a month  :'(
Like I said, this is pushing the envelope a bit but if you only need three states, there should be enough resolution to pull that off reliably.   

I have a bunch of RC parts laying around that I could probably hook up.  Although now that I think about it, my Arduino clone on a bread board that I used for a bunch of other USB remote CHDK testing seems like a better option.  Once I verify operation of that on my ancient analog scope then trying it out on the camera will be trivial.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4445
Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #385 on: 20 / April / 2015, 18:28:22 »
The high precision pulse counting / measurement code runs in a interrupt service routing written in C.  There is a Lua call to allow it to read buffered data from that routine.
Did someone actually test the code with sub-millisecond repetition rate? As far as I remember, timers are not very accurate when called that often.
Also, Naccio mentioned an SD1100, which is a DIGIC III model. The ARM core in DIGIC II and III runs at 36 MHz (DIGIC 4 and 5 is clocked higher, at least 72 MHz).

edit:
not to mention that CPU load is much higher in shooting mode.
« Last Edit: 20 / April / 2015, 18:30:33 by srsa_4c »

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #386 on: 20 / April / 2015, 18:36:25 »
The high precision pulse counting / measurement code runs in a interrupt service routing written in C.  There is a Lua call to allow it to read buffered data from that routine.
Did someone actually test the code with sub-millisecond repetition rate?
Yes, there was some work done and reported in the thread where all this was documented.  The OP was running a bit banging UART at 1 kbps  and getting responable results.   I couldn't find the post but I believe from memory that thing got really shakey down below 500 uSec timer rate. Which is partly why I set the lower limit that can be set from a script at 1 mSec.

Quote
As far as I remember, timers are not very accurate when called that often.  Also, Naccio mentioned an SD1100, which is a DIGIC III model. The ARM core in DIGIC II and III runs at 36 MHz (DIGIC 4 and 5 is clocked higher, at least 72 MHz). edit: not to mention that CPU load is much higher in shooting mode.
All true.  The question is whether we can differentiate a 1 mSec pulse, a 1.5 mSec pulse, and a 2 mSec pulse to get the three states required.   As I've said a few times now, this is pushing the envelope and not guaranteed, but it seems worth trying?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #387 on: 20 / April / 2015, 19:17:22 »
I couldn't find the post but I believe from memory that thing got really shakey down below 500 uSec timer rate.
Found it :  http://chdk.setepontos.com/index.php?topic=11342.msg111415#msg111415
Ported :   A1200    SD940   G10    Powershot N    G16


Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #388 on: 29 / April / 2015, 07:45:33 »
I already have CHDK installed on my Canon S110, how do I go about adding this script into it and is there a link anywhere on how to do it????

Re: KAP & UAV Exposure Control Intervalometer Script
« Reply #389 on: 29 / April / 2015, 08:19:34 »
I already have CHDK installed on my Canon S110, how do I go about adding this script into it and is there a link anywhere on how to do it????
Well, you could always RTFM.  The particular section you are looking for is here.

This might help as well, although it's a bit old.

Finally, there is some documentation on the actual script.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics