In case it is useful to anyone, here is my code for controlling the 4th channel through the Ardupilot board.
The main thing that stumped me for a while is you need to change timer2 from CTC mode to Normal mode. The default Ardupilot code has Timer 2 in CTC mode which resets the counter every time the throttle compare interrupt is captured. To drive two channels you need to be in Normal mode allowing the timer to go all the way to 255 before resetting.
Channels 3 and 4 to have noticable more granularity than the first two channels (as expected), but within this granularity, the movement is nice and reliable. In the linked video, you can see that when being controlled by the ardupilot the rudder motion is slightly more jerky.
I also added an extra flight mode to my code called SERVO_TEST. When in servo_test, the main loop skips any sort of navigation or stabilization, and simply passes the radio inputs through to the servos. I did this so I could get a feel for how well my servo code was working.
I hadn't seen any code on the site for channel 4 actually integrating into an Ardupilot software load, so I thought I would post mine..
My pin assignments are as follows:
pinMode(2,INPUT); //- Aileron in
pinMode(3,INPUT); //- Elevator in
pinMode(8,OUTPUT); //- Throttle out
pinMode(9,OUTPUT); //- Elevator out
pinMode(10,OUTPUT); //- Aileron out
pinMode(11,OUTPUT); //- Rudder out
pinMode(12,INPUT); //- Rudder in
pinMode(13,INPUT); //- throttle in
(Note that I'm using RADIO_TYPE 0, so I have no code in the RADIO_TYPE 1 sections).
Below is a video from my shop of the rudder motion, both in MANUAL mode (straight from the radio) and in SERVO_TEST mode (radio read by the ArduPilot and Passed through untouched).
Comment by Cronselaar on April 15, 2010 at 7:18am 
Comment by Tom Hastie on April 15, 2010 at 7:39pm
Comment by Tom Hastie on April 26, 2010 at 6:26am
Comment by Geert Folkertsma on June 2, 2010 at 1:00am
Comment by Geert Folkertsma on June 2, 2010 at 1:01am 
Comment
Season Two of the Trust Time Trial (T3) Contest has now begun. The third round was a reliablilty/aerial photography round for both planes and copters, which is now closed. Stay tuned for the next round, beginning soon.61 members
57 members
95 members
108 members
617 members
© 2012 Created by Chris Anderson.

You need to be a member of DIY Drones to add comments!
Join DIY Drones