Triggering a Camera: APM or Arduino

Hi Guys,

A quick question. Has anyone programmed APM for a camera trigger?

Basically, I need to send out +5V when camera must trigger for 250ms and send 0V otherwise.

The problem I have is:

digitalWrite does not seem to work on APM output pins.

APM.OutputCh(PWM_Pulse) does not seem to do the job.

APM_Camera library in APM also does not help me here.

Am I going wrong somewhere? Any clue is appreciated.

Thanks.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi Shyam

    Sorry to bother you again but i have been trying to get the camera way point trigger working. I understand what you replied with in a thread you had about this topic, but I'm getting some irritating errors.

    i have added this to the APM_Config.h file:
    #define CAMERA_TRIGGER camera_trigger();
    #define CAMERA_PIN 8;
    #define pinMode(CAMERA_PIN, OUTPUT);

    but then when I go to use the "digitalWrite(CAMERA_PIN, HIGH)" in UserCode i get "digitalWrite is not declared in this scope" error.

    is there any way you would be able to show me your UserCode, UserVariables and APM_config.h files? Once i have seen how it has been done i should be able to get my version working.

    Thanks for you time
    Adam
    http://error.is/
  • Hey Shyam

    sorry to keep asking questions about this but I'm getting errors.

    I have this in the userVariables.h file

    const int camPin = 8;
    pinMode(camPin,OUTPUT);
    unsigned long alphaMillis = millis();

    then in the UserCode file i have

    void takePhoto(){
    digitalWrite(camPin, HIGH);
    digitalWrite(camPin, LOW);
    }

    I know that there will need to be a delay in between the HIGH and the LOW but im building it incrementally to see how it works.

    The errors that I'm getting are

    UserVariables.h:20:8: error: expected constructor, destructor, or type conversion before '(' token

    UserCode.ino: In function 'void takePhoto()':
    UserCode.ino:47:28: error: 'digitalWrite' was not declared in this scope

    any help would be wicked.

    Cheers
    Adam
  • that looks great thanks!
  • Hi Shyam

    The code that you wrote to trigger the camera, was it written in the ArduCopter arduino code ? if so where did you write it?

    Im trying to set a Quadcoper up so that it takes a photo at every waypoint by default. My logic is that i can put a call to a "take photo" method in the code that checks if the quad is at a way point, but im not to sure where to start with modifying the code.

    any help would rock.
    Adam
    • Hi Adam,

      To your question:

      Yes, it was in the Arducopter Arduino code.

      Hardware

      I used a simple thyristor circuit in between APM and DLSR camera. I attached that to the DLSR camera to trigger the photo. I send a simple high digital pulse (5V when high, 0V when low) to trigger the camera (Camera should be on before you fly).. The pulse is about 220ms wide and helps to take a snapshot. I think you can use one of the output pins of APM/ Pixhawk. Google it, enough information on using camera trigger should be online.

      Software

      Regarding the code, I will make it easy for you.

      1. Define a function 'CameraTrigger(..)' in Usercode.pde (This is usually where users can edit their code, without messing up the rest of the code in Arducopter. If you don't understand the code very well, this is the place to write your own functions).

      2. Call this function you defined in this file, from 'commands_logic.pde'

      3. In 'commands_logic.pde', find the function 'verify_nav_wp()'. This function is triggered whenever a waypoint is hit. It is basically a verification check that is hit when the quadcopter reaches the 'waypoint radius zone'.  Call your camera trigger code CameraTrigger(..) from here - basically, make a function call.

      Does that sound simple enough ;)?

      Regards,

      Shyam

  • +3

  • +2

  • Does the camera triggering work in Arduplane 2.7?

    We can't seem to get it to function.

  • Shyam, did you get your camera trigger working yet?

    I posted a description on Jan 1 of how I control and trigger my camera in this thread:
    http://diydrones.com/forum/topics/camera-trigger-again?xg_source=ms...

    In summary, I use the extra pins A7 and A8 (pins 61, 62) on the APM2.5 defined as digital outs. Then use the digitalWrite() command to set them high or low using timer loops similar to your test code and flight distance. I use transistors to drive the camera but as Luke mentioned, optoisolators would be an even more elegant solution.

    If you have an APM1 you can use the commands relay.off(); and relay.on(); to switch the built in mechanical relay.

  • In some cases it is desirable to retract the lens during takeoff and landing. I just solved this using CHDK. See the blog post here:

    http://fpvlab.com/forums/showthread.php?11357-Scripting-Canon-SX230...

    Note that this is a stock SX230 with no modifications.

This reply was deleted.

Activity

DIY Robocars via Twitter
Sunday
DIY Robocars via Twitter
Saturday
DIY Robocars via Twitter
May 13
DIY Robocars via Twitter
RT @f1tenth: Say hi to our newest #F1TENTH creation for @ieee_ras_icra next week in Philly. It’s going to be huge! 😎 🔥 @AutowareFdn @PennEn…
May 13
DIY Robocars via Twitter
May 11
DIY Robocars via Twitter
May 8
DIY Robocars via Twitter
RT @SmallpixelCar: Noticed my car zigzagged in last run. It turned out to be the grass stuck in the wheel and made the odometry less accura…
May 8
DIY Robocars via Twitter
RT @SmallpixelCar: Test my car. RTK GPS worked great. Thanks @emlid for their support. https://t.co/EkQ6qmjmWR
May 8
DIY Drones via Twitter
RT @chr1sa: @kane That's @diydrones circa 2009. Still have a box of those Canon cameras that we used to strap into planes, just like this.…
May 3
DIY Robocars via Twitter
RT @chr1sa: Our next @diyrobocars race is going to be outside at a real RC racetrack in Fremont on May 28. Fully autonomous racing, head-to…
Apr 30
DIY Robocars via Twitter
RT @f1tenth: Our Spring 2022 F1TENTH course @PennEngineers is coming to an end with a head-to-head race as a big finale. So proud of our st…
Apr 26
DIY Robocars via Twitter
RT @DanielChiaJH: I wrote a thing! Throughout the development of my @diyrobocars car I've been using @foxglovedev Studio to visualize and d…
Apr 23
DIY Robocars via Twitter
RT @SmallpixelCar: My new car for high speed. Low body, everything ( @NVIDIAEmbedded Jetson Xavier NX, @emlid RTK GPS, IMC) under the deck…
Apr 23
DIY Robocars via Twitter
Apr 21
DIY Robocars via Twitter
RT @f1tenth: F1TENTH Race training setup @PennEngineers for our upcoming ICRA2022 @ieee_ras_icra competition. @OpenRoboticsOrg @IndyAChalle…
Apr 21
DIY Robocars via Twitter
RT @fatcatFABLAB: Proud to be hosting a restarted DIY Robocars NYC Meetup April 26. Come by if you want to talk about and race self-driving…
Apr 17
More…