Original ArduPilot controls 2 servos (throttle/yaw) by autopilot code or from RC receiver. Other 2 servos are controlled by FMA copilot (or again manually by RC). Although there're servo IN3/4 and servo OUT 3/4 connectors on ArduPilot board, they're at present unused (actually only pass-through control from IN3/4 to OUT3/4 is connected).Yet there's simple way to control all 4 servos from ArduPilot code, and use other two servos for interesting tasks, such as moving plane's camera tilt. Or even better - provide full stabilization in basic ArduPilot, which is at present only planned in ArduPilot Pro.While I don't know yet if stabilization code would fit into 16KB memory of AT168 (together with navigation code), I'll just post how to control all 4 servos from code. We'll see what comes out of this.On hardware side, there's simple wire soldered between digital 6 pin and MUX IN 3 pin. Also connector is added at servo OUT 3 at top right for connecting the servo:

This is for controlling servo 3, for adding control of servo 4, add another wire from D7 to MUX4 and another connector to Servo OUT 4.Now programming part... For controlling servo, we need to output PPM signals at pins 6/7. And do it at 50Hz frequency. Luckily we can set interrupt function that will be called 50 times/second, and generate PPM pulses there. This functionality will use up to 10% of CPU (for delays while generating PPM signals). All the code is here.In your code, call Servo_3_4_Init once, then Servo_3_set or Servo_4_set whenever you need to set angle for particular servo.That's it! We can control now 4 servos from inside code. And possibly add stabilization part to the code...? Let's hope so.
E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Hi ! I need this important part in my project, very urgent, less than 10days to finish. I tried your code but it didn't work. I notice in your code, it say that it generate PPM signal to drive the servo. But I thought only PWM Signal then can drive the servo ?? 

    Help please . thanks :)

  • For those wanting to explore the use of more than 3 servos in their ArduPilot or other Arduino based boards, I tried out the MegaServo library to be found in the Arduino Playground. It works great with four servos, and its possible to expand to 12 servos on a ATmeag168 and ATmega328, and as much as 48 servos (!) on the ArduinoMega board.
    So you may refurbish your "old" green ArduPilots as pan&tilt or aerial photo trigger platforms, as I have done in my project. It works fine!
  • mmmmmmmmm nice...
    that will allow to fly the plane in UAV mode without the problem of thinking that maybe some radio could get control of the 2 channels that ardupilot is not controlling, and it could crash easly.

    the problem now is... if the plane joins in the RF of another radio and ardupilot become disabled...
    maybe adding some "tricky code" to atiny to enable / disable the autopilot will be nince, (like the reset on/off/on/off/on code)
  • 3D Robotics
    Very nice!

    Just a note that we are also working on implementing integrated thermopile stabilization in the basic ArduPilot board, but just with 3-channel aircraft (just controlling rudder/elevator or elevons in a flying wing), like an EasyStar or Funjet. This is a nice idea, which will allow us to include throttle for speed control.
This reply was deleted.