Mostly for the sake of better understanding the insides of APM2, Arduplane and Arducopter, I'm attempting to write what I'm calling ArduGimbal (very clever I know).

Immediately I'm just trying to use an APM2 to stabilize a triple axis gimbal.  I'm a partial noob, I can write in Java, Processing, & Arduino, and can muscle through to make a C++ library for Arduino.  Write now I am able to grab Accel, Gyro, and Mag data from the APM2 and push it through to a Processing program to animate the sensor input.  But for the life of me I can't figure out how to read and write input/output PWM pins.  I've been looking through Arducopter/plane libraries, code and examples and can't figure it out.  I think many of the examples are broken as well and it's difficult for a partial noob like myself to figure out what I need to make it work.

Any help as especially general advice for where/how to look for documentation for APM libraries would be much appreciated. (Like the equivalent of JavaDocs, and the Processing/Arduino reference page)

Thanks in advanced,


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

Join diydrones

Email me when people reply –


  • From looking at examples, it seems that this is the class that deals with writing PWMs to the output channels but I can't get it to work.  Is there a description of what each method is meant to do somewhere?

    class Arduino_Mega_ISR_Registry;

    class APM_RC_Class



    virtual void Init( Arduino_Mega_ISR_Registry * isr_reg ) = 0;
    virtual void OutputCh(uint8_t ch, uint16_t pwm) = 0;
    virtual uint16_t InputCh(uint8_t ch) = 0;
    virtual uint8_t GetState() = 0;
    virtual void clearOverride(void) = 0;
    virtual void Force_Out() = 0;
    virtual void SetFastOutputChannels( uint32_t channelmask, uint16_t speed_hz = 400 ) = 0;
    virtual void enable_out(uint8_t) = 0;
    virtual void disable_out(uint8_t) = 0;

    virtual void Force_Out0_Out1(void) = 0;
    virtual void Force_Out2_Out3(void) = 0;
    virtual void Force_Out6_Out7(void) = 0;

    uint16_t _map_speed(uint16_t speed_hz) { return 2000000UL / speed_hz; }


    #include "APM_RC_APM1.h"
    #include "APM_RC_APM2.h"


This reply was deleted.