PPM with CC3D flight controller

Hi,

I dont want to use PWM channels anymore from CC3D to received data from arduino, I decided to move on and use PPM which will require only one signal pin to be connected.

So I uploaded the code below from a really good guy who created it but LibrePilot never recognizes the PPM signal.

/*
 * PPM generator originally written by David Hasko
 * on https://code.google.com/p/generate-ppm-signal/ 
 */

//////////////////////CONFIGURATION///////////////////////////////
#define CHANNEL_NUMBER 12  //set the number of chanels
#define CHANNEL_DEFAULT_VALUE 1500  //set the default servo value
#define FRAME_LENGTH 22500  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PULSE_LENGTH 300  //set the pulse length
#define onState 1  //set polarity of the pulses: 1 is positive, 0 is negative
#define sigPin 4  //set PPM signal output pin on the arduino
//////////////////////////////////////////////////////////////////

#define SWITCH_PIN 16
#define CHANNEL_TO_MODIFY 11
#define SWITCH_STEP 100

byte previousSwitchValue;

/*this array holds the servo values for the ppm signal
 change theese values in your code (usually servo values move between 1000 and 2000)*/
int ppm[CHANNEL_NUMBER];

int currentChannelStep;

void setup(){  

  previousSwitchValue = HIGH;
  
  //initiallize default ppm values
  for(int i=0; i<CHANNEL_NUMBER; i++){
    if (i == 2 || i == CHANNEL_TO_MODIFY) {
      ppm[i] = 1000;
    } else {
      ppm[i]= CHANNEL_DEFAULT_VALUE;
    }
  }

  pinMode(sigPin, OUTPUT);
  pinMode(SWITCH_PIN, INPUT_PULLUP);
  digitalWrite(sigPin, !onState);  //set the PPM signal pin to the default state (off)
  
  cli();
  TCCR1A = 0; // set entire TCCR1 register to 0
  TCCR1B = 0;
  
  OCR1A = 100;  // compare match register, change this
  TCCR1B |= (1 << WGM12);  // turn on CTC mode
  TCCR1B |= (1 << CS11);  // 8 prescaler: 0,5 microseconds at 16mhz
  TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
  sei();

  currentChannelStep = SWITCH_STEP;
}



void loop(){

  int switchState;

  switchState = digitalRead(SWITCH_PIN);

  if (switchState == LOW && previousSwitchValue == HIGH) {

    static int val = SWITCH_STEP;

    ppm[CHANNEL_TO_MODIFY] = ppm[CHANNEL_TO_MODIFY] + currentChannelStep;
    
    if (ppm[CHANNEL_TO_MODIFY] > 2000 || ppm[CHANNEL_TO_MODIFY] < 1000) {
      currentChannelStep = currentChannelStep * -1;
      ppm[CHANNEL_TO_MODIFY] = ppm[CHANNEL_TO_MODIFY] + currentChannelStep;
    }
    
  }

  previousSwitchValue = switchState;
  
}

ISR(TIMER1_COMPA_vect){  //leave this alone
  static boolean state = true;
  
  TCNT1 = 0;
  
  if (state) {  //start pulse
    digitalWrite(sigPin, onState);
    OCR1A = PULSE_LENGTH * 2;
    state = false;
  } else{  //end pulse and calculate when to start the next pulse
    static byte cur_chan_numb;
    static unsigned int calc_rest;
  
    digitalWrite(sigPin, !onState);
    state = true;

    if(cur_chan_numb >= CHANNEL_NUMBER){
      cur_chan_numb = 0;
      calc_rest = calc_rest + PULSE_LENGTH;// 
      OCR1A = (FRAME_LENGTH - calc_rest) * 2;
      calc_rest = 0;
    }
    else{
      OCR1A = (ppm[cur_chan_numb] - PULSE_LENGTH) * 2;
      calc_rest = calc_rest + ppm[cur_chan_numb];
      cur_chan_numb++;
    }     
  }
}

Has anyone tried to make PPM work from arduino to CC3D?

A nice guy from LibrePilot named @f5soh looks like got some progress. But he is using flexiport, I am waiting him to tell me if he can do the same with the pin 3 of the receiver. You can follow up the thread here: https://forum.librepilot.org/index.php?topic=2420.0

This guy @f5soh is really nice and it looks like he may help with this poblem, so if you are having the same problem please follow the link above cause in that thread maybe the solution will arise.