I would like to add some simple functionality to my autopilot, chiefly a signal sent every 10 seconds or so to fire a small camera. After looking a bit through the older posts, I am still a bit confused on how one would go about doing this, any suggestions on where to start looking?

That looked like how to make a timer, but I'm a bit confused on the theory. Do i need to declare and initilize a new servo output, then call something like "pulse_servo_throttle(long angle)"?

As far as hardware going, it's just an on/off type toggle switch, i'm not trying to actuate a servo to press the shutter button.

Views: 321

Reply to This

Replies to This Discussion

If you just want to send a signal, why not just set one of the spare digital pins high?

[setup]
pinMode(pin,OUTPUT);

[code]

digitalWrite(pin,HIGH);
Chris, do you have any idea how to code setting a digital pin high once a specific waypoint is reached?
Yes! that sounds pretty much exactly what I am thinking. If you don't mind me asking the Servo_control file has them writing to pin 10, but I was expecting it to be "1" (for throttle) - Why is that?

Also by [setup] do you mean the setup() function in ArduPilot.pde? I'm still feeling my way around the code a bit - it looks familiar, but with some different vocabulary than my usual Flash/PHP stuff!

Thanks!
Sure, that's easy.

In ArduPilot 1.0, for instance, in first tab you'll find the following. I've noted where to insert the trigger code.

if(RTL==0)//Verify the RTl option (0=Waypoint mode, 1 = Return Home mode)
{
if((wp_distance<30)&&(jumplock_wp==0x00))//Checking if the waypoint distance is less than 30, and check if the lock is open
{
current_wp++; //Switch the waypoint
// insert trigger code here
jumplock_wp=0x01; //Lock the waypoint switcher.
if(current_wp>waypoints)//Check if we've passed all the waypoints, if yes will return home..
{
current_wp=0;
}
}
Hi Kyle,

This is how the Atmega chip works with Ardupilot. There are specific pins for digital and analog input/output. Some of the digital I/O pins can also be use for PWM (pulse width modulation)
http://en.wikipedia.org/wiki/Pulse-width_modulation

With the Ardupilot, digital pins 9 and 10 just happen to be servo 1 and 2 out respectively. These particular digital pins can also input and output PWM signals.

See the servo tab for where these are declared as OUTPUT and set LOW initially:

digitalWrite(10,LOW);//Defining servo output pins
pinMode(10,OUTPUT);
digitalWrite(9,LOW);
pinMode(9,OUTPUT);

So, when you hook your throttle up to servo out 1, you are actually connected to digital (PWM) pin 10. Here is a good simple diagram of the pins on the "through-hole" version of the Atmega 128 chip. Note the items in RED text.

http://www.arduino.cc/playground/uploads/Learning/Atmega168PinMap2.png

Torin
You can declare pin modes anywhere, but the void setup() {....} function in the first tab of the code is a special Arduino convention and a good place to do it. It runs once at startup. You'll note that we have so much setup stuff that we just have that setup routine call an Init function, which we've broken out as the fifth tab.
Just to make sure, digital pin 9 (throttle) refers to the chip's #15 pin (PB1), therefor the 3rd set of jumpers on the output side would reference digital pin 11 (atmega168's #17 pin) correct?

Thanks, it's making alot more sense now!

Reply to Discussion

RSS

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service