Four Channels In/Out on ArduPilot Board

Hey all, I was hoping for some tips.


I'm trying to get 4 channels (ail/ele/thr/rud) of input and output working on my ArduPilot Board.


I'm starting with the recent 2.6 version of the code.


I've managed to get all 4 channels inputting correctly to the board (Verified by adding adding ch4 to the print_radio() function.)


Now I'm working on getting PPM coming out for all 4 channels.


Any tips on the best way to add the fourth channel of output to the Ardupilot?

Which pin is best suited to be used for the fourth PPM out?


I don't mind sniffing through manuals or existing code, but I've been hacking around the datasheets for a couple hours this evening and am still scratching my head.






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

Join diydrones

Email me when people reply –


  • I think I've found it.

    From iom328p.h which is in the Arduino IDE.

    /* Interrupt Vectors */
    /* Interrupt Vector 0 is the reset vector. */
    #define INT0_vect _VECTOR(1) /* External Interrupt Request 0 */
    #define INT1_vect _VECTOR(2) /* External Interrupt Request 1 */
    #define PCINT0_vect _VECTOR(3) /* Pin Change Interrupt Request 0 */
    #define PCINT1_vect _VECTOR(4) /* Pin Change Interrupt Request 0 */
    #define PCINT2_vect _VECTOR(5) /* Pin Change Interrupt Request 1 */
    #define WDT_vect _VECTOR(6) /* Watchdog Time-out Interrupt */
    #define TIMER2_COMPA_vect _VECTOR(7) /* Timer/Counter2 Compare Match A */
    #define TIMER2_COMPB_vect _VECTOR(8) /* Timer/Counter2 Compare Match A */
    #define TIMER2_OVF_vect _VECTOR(9) /* Timer/Counter2 Overflow */
    #define TIMER1_CAPT_vect _VECTOR(10) /* Timer/Counter1 Capture Event */
    #define TIMER1_COMPA_vect _VECTOR(11) /* Timer/Counter1 Compare Match A */
    #define TIMER1_COMPB_vect _VECTOR(12) /* Timer/Counter1 Compare Match B */
    #define TIMER1_OVF_vect _VECTOR(13) /* Timer/Counter1 Overflow */
    #define TIMER0_COMPA_vect _VECTOR(14) /* TimerCounter0 Compare Match A */
    #define TIMER0_COMPB_vect _VECTOR(15) /* TimerCounter0 Compare Match B */
    #define TIMER0_OVF_vect _VECTOR(16) /* Timer/Couner0 Overflow */
    #define SPI_STC_vect _VECTOR(17) /* SPI Serial Transfer Complete */
    #define USART_RX_vect _VECTOR(18) /* USART Rx Complete */
    #define USART_UDRE_vect _VECTOR(19) /* USART, Data Register Empty */
    #define USART_TX_vect _VECTOR(20) /* USART Tx Complete */
    #define ADC_vect _VECTOR(21) /* ADC Conversion Complete */
    #define EE_READY_vect _VECTOR(22) /* EEPROM Ready */
    #define ANALOG_COMP_vect _VECTOR(23) /* Analog Comparator */
    #define TWI_vect _VECTOR(24) /* Two-wire Serial Interface */
    #define SPM_READY_vect _VECTOR(25) /* Store Program Memory Read */

    #define _VECTORS_SIZE (26 * 4)

    As well as the attached PDF excerpt.

    Pages from 8271.pdf
  • Hey Doug,

    Whether or not it works well I think I'd still like to give it a go... see with my own eyes how jittery it is. It also can't hurt to learn how this stuff works.

    I also got the fourth channel of input working fairly easily by adding an if(PINB & B00010000) case.

    While figuring out how the servo write is working, I found this website that explained it better than any other I found:

    One thing I haven't really been able to find is a decent description of what the different available interrupt vectors are. For instance, TIMER1_CAPT_vect, TIMER2_COMPA_vect, etc. Don't seem to be in the ATMEL data sheet, and finding reference to them on Arduino Playground is hit or miss. Where could I go to find their definitions and see what else might be available?


  • Developer
    There is a sixteen bit timer running ch 1 and 2. I thinks it's running fast pwm. Basically it counts up to 40000 and loops There are two compare values that are triggered with an interrupt. I already use the timers to hijack the radio input code using pin interrupts and the timer as offset values. I feel like this was a stretch but it works great. I can't see a way to trick the timer into doing a tire task, but I'm always surprised how much functionality you can squeeze out of these systems.
  • Developer
    Hi Tom,

    We haven't really pursued 4 channels on the current board because of the limited timer resources. If you look at the interrupt vectors in the servos.pde file and see the difference in the way that ch3 is formed versus ch1 and ch2 you will understand. The resolution avaialble for ch3 (and ch4) is poor. With ch3 going to an esc it is not so bad, but for driving an actual servo the output will be very coarse and prone to jitter.
This reply was deleted.