Problem with generating a ppm stream with one Arduino nano to another.

Hey so the problem I'm having is that i'm following a guide for building an Arduino based drone. I'm waiting for some parts to arrive from China for the radio communication. In the meantime i have been trying to cut out the radio control, and just run the Arduino flight controller with a second Arduino generating the PPM signal the flight controller needs.

The FC (Flight controller) by default takes a PPM signal as input, and controls the drone and generates PWM signals going out to the motor's of the drone.

The flight controller (Arduino) is run by a platform called Multiwii.
(the code can be found at Google Code Archive - Long-term storage for Google Code Project Hosting.)
I'm using version 2.4

The Arduino nano that i want to generate the PPM signal, for the Flight Controller. Is currently connected to a PS2 joystick breakout board from which i'm hoping to control the Throttle and roll values for the drone.

I tried to piece together part of code from the tutorial i follow for the drone and some sample code from the Arduino Adeept starter kit. Now also with a bit of my own code.

Here is the code i used for the second Arduino (PPM generator or wired controller)

////////////////////// Joystick configruation /////////////////////////  
int JoyStick_X = 0; //PS2 joystick X-axis is defined, ANALOG IN of Pin0
int JoyStick_Y = 1; //PS2 joystick Y axis is defined, ANALOG IN of Pin1
int JoyStick_Z = 3; //Defined PS2 joystick Z axis,
int Joystick_aux = 4; //Aux Channel to fill multiwii requirements
///////////////////////////////////////////////////////////////////////


////////////////////////// PPM Configruation //////////////////////////
#define channel_number 4 //Set the number of channels
#define sigPin 2 // Set PPM signal output pin on arduino
#define PPM_FrLen 27000 //set the PPM frame lenght in microseconds (1ms == 1000 microS)
#define PPM_PulseLen 400 // Set the pulse length
///////////////////////////////////////////////////////////////////////

int ppm[channel_number];



struct MyData {
  byte throttle;
  byte roll;
  byte pitch;
  byte yaw;
};

MyData data;

  
void resetData() 
{
  // 'safe' values to use when no radio input is detected
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  
  
  setPPMValuesFromData();
}

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.roll,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.yaw,     0, 255, 1000, 2000);
  
  }

  void setupPPM() {
    pinMode(sigPin, OUTPUT);
    digitalWrite(sigPin, 0);

    
    cli();
  TCCR1A = 0; // set entire TCCR1 register to 0
  TCCR1B = 0;

  OCR1A = 100;  // compare match register (not very important, sets the timeout for the first interrupt)
  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();
  }

  void reciveData() 
  {
    
     
  }

  
  void setup(void)
  {
     resetData();
     //setupPPM();
     Serial.begin(9600);
     pinMode(JoyStick_Z, INPUT_PULLUP); //Z axis is defined as an input PS2
  }
   
  void loop(void)
  {
    
   data.throttle = map(analogRead(A1), 0, 1023, 0, 255);
   data.roll = map(analogRead(A0), 0, 1023, 0, 255);
   data.pitch = map(digitalRead (JoyStick_Z), 1, 0, 127, 255);
   data.yaw = map(digitalRead (Joystick_aux), 0, 1, 0, 255);
   
    //int x,y,z;
    //x=analogRead(JoyStick_X);
    //y=analogRead(JoyStick_Y);
    //z=digitalRead(JoyStick_Z);
    
    Serial.print("Throttle   "); Serial.print(data.throttle); Serial.print("   ");
    Serial.print("Roll   "); Serial.print(data.roll);     Serial.print("   ");
    Serial.print("Pitch   "); Serial.print(data.pitch);    Serial.print("   ");
    Serial.print("Yaw   "); Serial.print(data.yaw);    Serial.print("\n");
    setPPMValuesFromData();
    
    
    //delay(1);
  }

And my Wiring diagram is attached below.

What problems are you having ?

Why would you want to send a PPM stream from one Arduino to another? Your system would be both simpler and more reliable if the first Arduino sends numbers and the receiving Arduino generates the appropriate PPM stream.

OR, if the second Arduino is treating the incoming PPM stream as data from which to control the movements of your drone then, again, the system will be a lot simpler if it receives numbers rather than a PPM stream.

What sort of wireless modules are you planning to use? If you are using nRF24L01+ modules the notion of sending a PPM stream makes no sense as the nRF24 can send 32 bytes of data with every message. That could be interpreted as up to 32 different control channels.

...R
Simple nRF24L01+ Tutorial

Robin2:
Why would you want to send a PPM stream from one Arduino to another? Your system would be both simpler and more reliable if the first Arduino sends numbers and the receiving Arduino generates the appropriate PPM stream.

OR, if the second Arduino is treating the incoming PPM stream as data from which to control the movements of your drone then, again, the system will be a lot simpler if it receives numbers rather than a PPM stream.

What sort of wireless modules are you planning to use? If you are using nRF24L01+ modules the notion of sending a PPM stream makes no sense as the nRF24 can send 32 bytes of data with every message. That could be interpreted as up to 32 different control channels.

...R
Simple nRF24L01+ Tutorial

I'm not too familiar with coding yet and because of that i figured the easiest way to test and use the multiwii code without changing the code and without the parts for the receiver. Would be to just generate the PPM signal the Flight Controller takes as an input.

The final version was planed to be a:

Remote with an Arduino and some joysticks + a few buttons and the NRF24L01+PA+LNA to send the data.

A receiver with and nRF24 to receive the data and then stream the data from the receiver to the flight controller Arduino locally.

Lastly the Flight controller which by default is coded to accept a PPM signal and then generate a PWM to each ESC (Electric Speed Controller) for each motor on the drone.

if you think i't better to just edit the code on the flight controller i could try that as well. or what do you think would be the preferred way to achieve local/wired control for the flight controller.
So that i can tinker a little with it before i get the Remote and Receiver?

UKHeliBob:
What problems are you having ?

I updated the Original post, but the problem is that I don't want to mess with the Multiwii platform to get my controls to work from within the same Arduino. So since the Code on the Arduino that is my "Flight Controller" expects a PPM signal input for the controls i want to send some input values from a secondary Arduino "Controller" to the "FC" via PPM.

I tried generating that signal with the included code, but can't seem to get any output from the Pin i set to output the PPM signal.

Ekliuz:
I updated the Original post,

Please don't do that - it makes the Thread almost impossible to follow. Just put new information in a new Reply.

Ekliuz:
A receiver with and nRF24 to receive the data and then stream the data from the receiver to the flight controller Arduino locally.

Is the flight controller an off-the-shelf component? - if so please post a link to its datasheet.

OR, is the flight controller an Arduino and is it the Arduino that will be connected to the nRF24?

...R

Robin2:
Please don't do that - it makes the Thread almost impossible to follow. Just put new information in a new Reply.
Is the flight controller an off-the-shelf component? - if so please post a link to its datasheet.

OR, is the flight controller an Arduino and is it the Arduino that will be connected to the nRF24?

...R

The Flight Controller is an Unofficial Arduino Nano that i loaded with the code that Multiwii supplies:
https://code.google.com/archive/p/multiwii/

by default this arduino "from now referred to as the FC (Flight controller)" is coded to take a PPM signal as input data. The Multiwii code is as i understand it build up by many "Library's?" or .ino files and the different parts of the code are split up into categories in this way, but don't quote me on that.
and as mentioned earlier i'm a bit overwhelmed by it, and therefore reluctant to try and edit it to my need's.

The tutorial/guide i'm following from a youtube use another Arduino nano to receive the signal from the nRF24 and then stream it to the FC via PPM. Since i'm trying to cut out the radio module for now i want to generate the same PPM signal just based on local joystick control instead of the remote controller.

Sorry for the confusion hope i where able to supply the information you where looking for here :confused:

I may be missing something but I can't see anywhere that you even attempt to write anything to your output sigPin except in setup() where it is set HIGH. Which bit of code do you think is sending the PPM?

Steve

slipstick:
I may be missing something but I can't see anywhere that you even attempt to write anything to your output sigPin except in setup() where it is set HIGH. Which bit of code do you think is sending the PPM?

Steve

/*  
 * Check:  http://www.electronoobs.com/eng_robotica_tut5_2_1.php
 * 
 * 
A basic receiver test for the nRF24L01 module to receive 6 channels send a ppm sum
with all of them on digital pin D2.
Install NRF24 library before you compile
Please, like, share and subscribe on my https://www.youtube.com/c/ELECTRONOOBS
 */

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

////////////////////// PPM CONFIGURATION//////////////////////////
#define channel_number 6  //set the number of channels
#define sigPin 2  //set PPM signal output pin on the arduino
#define PPM_FrLen 27000  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PPM_PulseLen 400  //set the pulse length
//////////////////////////////////////////////////////////////////

int ppm[channel_number];

const uint64_t pipeIn =  0xE8E8F0F0E1LL;

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;

void resetData() 
{
  // 'safe' values to use when no radio input is detected
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2= 0;
  
  setPPMValuesFromData();
}

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.yaw,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.roll,     0, 255, 1000, 2000);
  ppm[4] = map(data.AUX1,     0, 1, 1000, 2000);
  ppm[5] = map(data.AUX2,     0, 1, 1000, 2000);  
  }

/**************************************************/

void setupPPM() {
  pinMode(sigPin, OUTPUT);
  digitalWrite(sigPin, 0);  //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 (not very important, sets the timeout for the first interrupt)
  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();
}

void setup()
{  
  resetData();
  setupPPM();
  
  // Set up radio module
  radio.begin();
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false);

  radio.openReadingPipe(1,pipeIn);
  radio.startListening();
}

/**************************************************/

unsigned long lastRecvTime = 0;

void recvData()
{  
  while ( radio.available() ) {        
    radio.read(&data, sizeof(MyData));
    lastRecvTime = millis();
  }
}

/**************************************************/

void loop()
{
  recvData();

  unsigned long now = millis();
  if ( now - lastRecvTime > 1000 ) {
    // signal lost?
    resetData();
  }
  
  setPPMValuesFromData();
}

/**************************************************/

#error Delete this line befor you cahnge the value (clockMultiplier) below
#define clockMultiplier 2 // set this to 2 if you are using a 16MHz arduino, leave as 1 for an 8MHz arduino

ISR(TIMER1_COMPA_vect){
  static boolean state = true;

  TCNT1 = 0;

  if ( state ) {
    //end pulse
    PORTD = PORTD & ~B00000100; // turn pin 2 off. Could also use: digitalWrite(sigPin,0)
    OCR1A = PPM_PulseLen * clockMultiplier;
    state = false;
  }
  else {
    //start pulse
    static byte cur_chan_numb;
    static unsigned int calc_rest;

    PORTD = PORTD | B00000100; // turn pin 2 on. Could also use: digitalWrite(sigPin,1)
    state = true;

    if(cur_chan_numb >= channel_number) {
      cur_chan_numb = 0;
      calc_rest += PPM_PulseLen;
      OCR1A = (PPM_FrLen - calc_rest) * clockMultiplier;
      calc_rest = 0;
    }
    else {
      OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen) * clockMultiplier;
      calc_rest += ppm[cur_chan_numb];
      cur_chan_numb++;
    }     
  }
}

That's very different from the first code you posted. It now seems to have a radio but there's no sign of a joystick. Why is that? What exactly is going on?

Steve

Ekliuz:

/*  

A basic receiver test for the nRF24L01 module to receive 6 channels send a ppm sum
with all of them on digital pin D2.
Install NRF24 library before you compile
Please, like, share and subscribe on my https://www.youtube.com/c/ELECTRONOOBS
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

////////////////////// PPM CONFIGURATION//////////////////////////
#define channel_number 6  //set the number of channels
#define sigPin 2  //set PPM signal output pin on the arduino
#define PPM_FrLen 27000  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PPM_PulseLen 400  //set the pulse length
//////////////////////////////////////////////////////////////////

int ppm[channel_number];

const uint64_t pipeIn =  0xE8E8F0F0E1LL;

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;

void resetData()
{
  // 'safe' values to use when no radio input is detected
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2= 0;
 
  setPPMValuesFromData();
}

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.yaw,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.roll,    0, 255, 1000, 2000);
  ppm[4] = map(data.AUX1,    0, 1, 1000, 2000);
  ppm[5] = map(data.AUX2,    0, 1, 1000, 2000); 
  }

/**************************************************/

void setupPPM() {
  pinMode(sigPin, OUTPUT);
  digitalWrite(sigPin, 0);  //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 (not very important, sets the timeout for the first interrupt)
  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();
}

void setup()

  resetData();
  setupPPM();
 
  // Set up radio module
  radio.begin();
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false);

radio.openReadingPipe(1,pipeIn);
  radio.startListening();
}

/**************************************************/

unsigned long lastRecvTime = 0;

void recvData()

  while ( radio.available() ) {       
    radio.read(&data, sizeof(MyData));
    lastRecvTime = millis();
  }
}

/**************************************************/

void loop()
{
  recvData();

unsigned long now = millis();
  if ( now - lastRecvTime > 1000 ) {
    // signal lost?
    resetData();
  }
 
  setPPMValuesFromData();
}

/**************************************************/

#error Delete this line befor you cahnge the value (clockMultiplier) below
#define clockMultiplier 2 // set this to 2 if you are using a 16MHz arduino, leave as 1 for an 8MHz arduino

ISR(TIMER1_COMPA_vect){
  static boolean state = true;

TCNT1 = 0;

if ( state ) {
    //end pulse
    PORTD = PORTD & ~B00000100; // turn pin 2 off. Could also use: digitalWrite(sigPin,0)
    OCR1A = PPM_PulseLen * clockMultiplier;
    state = false;
  }
  else {
    //start pulse
    static byte cur_chan_numb;
    static unsigned int calc_rest;

PORTD = PORTD | B00000100; // turn pin 2 on. Could also use: digitalWrite(sigPin,1)
    state = true;

if(cur_chan_numb >= channel_number) {
      cur_chan_numb = 0;
      calc_rest += PPM_PulseLen;
      OCR1A = (PPM_FrLen - calc_rest) * clockMultiplier;
      calc_rest = 0;
    }
    else {
      OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen) * clockMultiplier;
      calc_rest += ppm[cur_chan_numb];
      cur_chan_numb++;
    }   
  }
}

slipstick:
That's very different from the first code you posted. It now seems to have a radio but there's no sign of a joystick. Why is that? What exactly is going on?

Steve

My code where meant to replace the radio controller with a wired joystick to test the rest of my build while i wait for the Radio Transceivers i have ordered.
The code i based my code on (the code quoted above) is meant to receive an RF signal from a remote, and i want to replace the remote and RF receiver with a joystick wired to the "receiver" Arduino. Which in turn will send a PPM stream to the FC that will tell the motors on the drone what to do via a PWM signal.

As far as I know the code from the tutorial/ the code i quoted above in this reply. Is in fact working and I concluded that the PPM stream in this code just need's to be initialized in the setup and the data values in struck MyData
are updated in the loop by the folowing function:

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.yaw,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.roll,     0, 255, 1000, 2000);
  ppm[4] = map(data.AUX1,     0, 1, 1000, 2000);
  ppm[5] = map(data.AUX2,     0, 1, 1000, 2000);  
  }

and since the PPM stream is set initialized in the "Void Setup" it might just keep transferring the data values in "MyData" continually? Might be mistaken, but that was the understanding i got to after going through the code myself.

Ekliuz:
The code i based my code on (the code quoted above) is meant to receive an RF signal from a remote, and i want to replace the remote and RF receiver with a joystick wired to the "receiver" Arduino.

It would have been helpful if you had said that the code you were posting wasn't the code you were trying to use instead of just posting it with no comment at all.

Anyway it's difficult modifying code when you don't understand it. From what I can see, in your modified code you took out almost everything to do with the PPM output.

You removed the ISR(TIMER1_COMPA_vect), the part that I think actually writes the PPM signal and you also commented out setupPPM() which I think sets the timer up for that ISR to work doing the writing.

However I've never really done anything with timer interrupts so I'm not qualified to help you putting it back together properly. Sorry.

Steve

slipstick:
It would have been helpful if you had said that the code you were posting wasn't the code you were trying to use instead of just posting it with no comment at all.

Anyway it's difficult modifying code when you don't understand it. From what I can see, in your modified code you took out almost everything to do with the PPM output.

You removed the ISR(TIMER1_COMPA_vect), the part that I think actually writes the PPM signal and you also commented out setupPPM() which I think sets the timer up for that ISR to work doing the writing.

However I've never really done anything with timer interrupts so I'm not qualified to help you putting it back together properly. Sorry.

Steve

Well thank you anyways, it's been somewhat informative and I'll try to look through the code a few more times an do som more research.

So I've tried adding the ISR[TIMER1_COMPA-vect) part to my code now, and i totally forgot to include it. I still can't seem to get any output?

Here's my current code:

////////////////////// Joystick configruation /////////////////////////  
int JoyStick_X = 0; //PS2 joystick X-axis is defined, ANALOG IN of Pin0
int JoyStick_Y = 1; //PS2 joystick Y axis is defined, ANALOG IN of Pin1
int JoyStick_Z = 3; //Defined PS2 joystick Z axis,
int Joystick_aux = 4; //Aux Channel to fill multiwii requirements
///////////////////////////////////////////////////////////////////////


////////////////////////// PPM Configruation //////////////////////////
#define channel_number 4 //Set the number of channels
#define sigPin 2 // Set PPM signal output pin on arduino
#define PPM_FrLen 27000 //set the PPM frame lenght in microseconds (1ms == 1000 microS)
#define PPM_PulseLen 400 // Set the pulse length
///////////////////////////////////////////////////////////////////////

int ppm[channel_number];



struct MyData {
  byte throttle;
  byte roll;
  byte pitch;
  byte yaw;
};

MyData data;

  
void resetData() 
{
  // 'safe' values to use when no radio input is detected
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  
  
  setPPMValuesFromData();
}

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.roll,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.yaw,     0, 255, 1000, 2000);
  
  }

  void setupPPM() {
    pinMode(sigPin, OUTPUT);
    digitalWrite(sigPin, 0);

    
    cli();
  TCCR1A = 0; // set entire TCCR1 register to 0
  TCCR1B = 0;

  OCR1A = 100;  // compare match register (not very important, sets the timeout for the first interrupt)
  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();
  }

  void reciveData() 
  {
    
     
  }

  
  void setup(void)
  {
     resetData();
     //setupPPM();
     Serial.begin(9600);
     pinMode(JoyStick_Z, INPUT_PULLUP); //Z axis is defined as an input PS2
  }
   
  void loop(void)
  {
    
   data.throttle = map(analogRead(A1), 0, 1023, 0, 255);
   data.roll = map(analogRead(A0), 0, 1023, 0, 255);
   data.pitch = map(digitalRead (JoyStick_Z), 1, 0, 127, 255);
   data.yaw = map(digitalRead (Joystick_aux), 0, 1, 0, 255);
   
    //int x,y,z;
    //x=analogRead(JoyStick_X);
    //y=analogRead(JoyStick_Y);
    //z=digitalRead(JoyStick_Z);
    
    Serial.print("Throttle   "); Serial.print(data.throttle); Serial.print("   ");
    Serial.print("Roll   "); Serial.print(data.roll);     Serial.print("   ");
    Serial.print("Pitch   "); Serial.print(data.pitch);    Serial.print("   ");
    Serial.print("Yaw   "); Serial.print(data.yaw);    Serial.print("\n");
    setPPMValuesFromData();
    
    
    //delay(1);
  }
  //#error Delete this line befor you cahnge the value (clockMultiplier) below
#define clockMultiplier 1 // set this to 2 if you are using a 16MHz arduino, leave as 1 for an 8MHz arduino

ISR(TIMER1_COMPA_vect){
  static boolean state = true;

  TCNT1 = 0;

  if ( state ) {
    //end pulse
    PORTD = PORTD & ~B00000100; // turn pin 2 off. Could also use: digitalWrite(sigPin,0)
    OCR1A = PPM_PulseLen * clockMultiplier;
    state = false;
  }
  else {
    //start pulse
    static byte cur_chan_numb;
    static unsigned int calc_rest;

    PORTD = PORTD | B00000100; // turn pin 2 on. Could also use: digitalWrite(sigPin,1)
    state = true;

    if(cur_chan_numb >= channel_number) {
      cur_chan_numb = 0;
      calc_rest += PPM_PulseLen;
      OCR1A = (PPM_FrLen - calc_rest) * clockMultiplier;
      calc_rest = 0;
    }
    else {
      OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen) * clockMultiplier;
      calc_rest += ppm[cur_chan_numb];
      cur_chan_numb++;
    }     
  }
}

and I've tried it with the Multiwii GUI and no luck there, in addition i tried reading the PPM signal with another Arduino. with the following program :

unsigned long ch[7], t[8];
int pulse= 0;


void setup() {
  PCICR |= (1 << PCIE0);
  PCMSK0 |= (1 << PCINT0);
  Serial.begin(9600);

}

void loop() {
  print();
  delay(100);

}

ISR(PCINT0_vect) {
  if (PINB & B00000001) {
    t[pulse] = micros();
    switch (pulse) {
      case 1:
      ch[1] = t[1] - t[0];
      pulse++;
      if (ch[1] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;
      
      case 2:
      ch[2] = t[2] - t[1];
      pulse++;
      if (ch[2] > 3000) {
        t[0] = t[2];
        pulse = 1;
      }
      break;

      case 3:
      ch[3] = t[3] - t[2];
      pulse++;
      if (ch[3] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;

      case 4:
      ch[4] = t[4] - t[3];
      pulse++;
      if (ch[4] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;

      case 5:
      ch[5] = t[5] - t[4];
      pulse++;
      if (ch[5] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;

      case 6:
      ch[6] = t[6] - t[5];
      pulse++;
      if (ch[6] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;

      case 7:
      ch[7] = t[7] - t[6];
      pulse++;
      if (ch[7] > 3000) {
        t[0] = t[1];
        pulse = 1;
      }
      break;

      default:
      pulse++;
      break;
    }
  }
}

void print() {
  Serial.print(ch[0]);
  Serial.print(" - ");
  Serial.print(ch[1]);
  Serial.print(" - ");
  Serial.print(ch[2]);
  Serial.print(" - ");
  Serial.print(ch[3]);
  Serial.print(" - ");
  Serial.print(ch[4]);
  Serial.print(" - ");
  Serial.print(ch[5]);
  Serial.print(" - ");
  Serial.print(ch[6]);
  Serial.print("\n");
}

slipstick:
and you also commented out setupPPM() which I think sets the timer up for that ISR to work doing the writing.

What else can I say?

Steve

slipstick:
What else can I say?

Steve

is this reply based on the code i posted in my last reply?
and where does the quote below come from?

Quote from: slipstick on Feb 10, 2020, 09:27 am
and you also commented out setupPPM() which I think sets the timer up for that ISR to work doing the writing.

I know you mentioned the ISR part i where missing (now found at the bottom of the current code)
but can't find anything about commenting out setupPPM() neither in the code posted prior or the replies?

The quote comes from my post #11 in this thread. I'm obviously wasting my time here if you're not going to bother reading what I write.

In both of the codes you posted there was only ever one call to setupPPM(). It is in setup() and it has been commented out. So that function is never called. If you never call the function that sets up PPM it shouldn't be a surprise if PPM doesn't work.

Steve

slipstick:
The quote comes from my post #11 in this thread. I'm obviously wasting my time here if you're not going to bother reading what I write.

In both of the codes you posted there was only ever one call to setupPPM(). It is in setup() and it has been commented out. So that function is never called. If you never call the function that sets up PPM it shouldn't be a surprise if PPM doesn't work.

Steve

I'm sorry, didn't mean to offend. I have looked through all the code in the thread so far and can't se neither here nor in my code that the PPM setup() is commented out?
The line above the setup is a commented line just to separate that part of the code from the rest, visually.
/*********************************/

It is just commenting out the line above and not the PPM setup(). But in the code window I see that it does not show the /at the end without you scrolling sideways.

But if you where to ignore that line above PPM setup()
And the ISR part is added.

Is there any obvious reason it shouldn't work then or do you have any other suggestions on the problem?

Once again I'm sorry for my lack of attention.

  void setup(void)
  {
     resetData();
     //setupPPM();  <<<<<<<<<<< What's this then?
     Serial.begin(9600);
     pinMode(JoyStick_Z, INPUT_PULLUP); //Z axis is defined as an input PS2
  }

slipstick:

  void setup(void)

{
    resetData();
    //setupPPM();  <<<<<<<<<<< What's this then?
    Serial.begin(9600);
    pinMode(JoyStick_Z, INPUT_PULLUP); //Z axis is defined as an input PS2
  }

OMG I'm freaking blind!!! Once again I'm soo sorry for wasting your time...

I'll see if I get it to work when I get back home today.