Reading RC Receiver Switch signal with an Arduino Zero


hey,

i stuck problem deals decoding of ppm-signals(i suppose) coming rc remote. rc transmitter model robbe futaba f-14, corresponding robbe futaba fp-r118f receiver, hooked arduino zero.

i can in fact decode pitch/roll/yaw/throttle stick signals given in seperate channels, remote control expandable multi-switch module 8 switches gets encoded onto single rc channel have decode. suspected ppm , informed myself bit, signal doesn't normal ppm me.
(attached files: pseudooscilloscopechange.png shows state of pin, returned interrupt routine, timechange.png shows time between 1 pin change; change indicates interrupt routine set change)

my code:
code: [select]


volatile unsigned long f_start_time = 0l;
volatile unsigned long f_now = 0l;
volatile unsigned long f_val = 0l;
volatile short f_values[9];
volatile int f_index = 0;
volatile boolean f = false;

int min_f = 200000;
int max_f = 0;

const int rc_functionpin = 12;

//############################################################################

void setup() {
  serial.begin(19200);
  setupinterrupts();
}

//############################################################################

void loop() {
//  serial.println(f_val);
  serial.println(f);
//  serial.print('\t');
//  serial.print(max_f);
//  serial.print('\t');
//  serial.println(min_f);
//  serial.print('\t');
//  for(int = 0; < 7; i++) {
//    serial.print(f_values[i]);
//    serial.print('\t');
//  }
//  serial.println(f_values[7]);
}

//############################################################################

void setupinterrupts() {
  pinmode(rc_functionpin, input);
  attachinterrupt(rc_functionpin, functionhandler, change);
}


void functionhandler() {
  f = !f;                                       /*f shows state of pin when interrupt set change, arduino can act oscilloscope*/
  f_now = micros();
  f_val = f_now - f_start_time;
  f_start_time = f_now;
//  
//  if(f_val >= 18000) {
//    f_index = 0;
//  }else {
//    f_values[f_index] = f_val;
//    f_index = ((f_index + 1) % 9);
//  }
}


the commented out stuff in loop() debugging various things, in functionhandler(), comments idea of parsing ppm-channels, didnt work since filled first index in array.

what correct way decode function of rc transmitter? normal ppm , kinda dumb or special? if of these cases apply, can explain mistake/give me directions work with?

any really appreciated, , feel free ask something,
thebeast

ok, record, solved it.
the reciever isn't using ppm, shifted pwm.

the new code needed 1 addition in isr:
code: [select]


volatile unsigned long f_start_time = 0l;
volatile unsigned long f_now = 0l;
volatile unsigned long f_val = 0l;
volatile short f_values[9];
volatile int f_index = 0;
volatile boolean f = false;

int min_f = 200000;
int max_f = 0;

const int rc_functionpin = 12;

//############################################################################

void setup() {
  serial.begin(19200);
  setupinterrupts();
}

//############################################################################

void loop() {
  serial.print('\t');
  serial.print(max_f);
  serial.print('\t');
  serial.println(min_f);
  serial.print('\t');
  for(int = 0; < 7; i++) {
    serial.print(f_values[i]);
    serial.print('\t');
  }
  serial.println(f_values[7]);
}

//############################################################################

void setupinterrupts() {
  pinmode(rc_functionpin, input);
  attachinterrupt(rc_functionpin, functionhandler, change);
}


void functionhandler() {
  f_now = micros();
  f_val = f_now - f_start_time;
  f_start_time = f_now;
 
  if(f_val < 1000) {
    f_index = -1;
  }else if(f_val >= 18000) {
    f_index = ((f_index + 1) % 10);
  }else {
    f_values[f_index] = f_val;
  }
}


Arduino Forum > Using Arduino > Project Guidance > Reading RC Receiver Switch signal with an Arduino Zero


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts