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.
Replies
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
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
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.