Teensy 3.6 interrupts for RC Receiver

Status
Not open for further replies.
I am trying to configure a Teensy 3.6 to use with flysky FS-T6 for PPM. the receiver is powered from the 5v pin on an Arduino.

I have tried using attachInterrupt, attachInterruptVector. I also tried using the PPM libraries and configuring interrupts through the registers. Also tried running the sketch on Windows and Linux laptops. The methods above have also been tried on multiple pins.

All the results I am getting are not correct.
below is the simplest routine I used to measure the pulses from the receiver.

Code:
unsigned long timer_Roll;
uint16_t roll_Reciever_Pulse;

void setup() {
  Serial.begin(9600);
  pinMode(24,INPUT);
  attachInterrupt(24,interrupt,CHANGE);
}

void loop() {

}



void interrupt(){
    if(digitalReadFast(24) == 1){         
      timer_Roll = micros();
    }
    else if(digitalReadFast(24) == 0){
      roll_Reciever_Pulse = micros() - timer_Roll;
      Serial.println(roll_Reciever_Pulse);
   }
}

All the data from the methods above look similar to the data attached. Could someone help me understand? is it something really obvious? I am really out of ideas...View attachment PulseLength.txt
 
Last edited:
I have tried it the data looks the same.
I just wrote this to retest.

Code:
#include <PulsePosition.h>
PulsePositionInput myInput(RISING);

void setup() {
  Serial.begin(9600);
  myInput.begin(23);
}

void loop() {
  if(myInput.available() > 0){
    for(int i = 1; i <= myInput.available(); i++) {
    Serial.print(myInput.available());
    Serial.print(" ");
    Serial.println(myInput.read(i));
    }
  }
  delay(10);
}

Attached is the data
 

Attachments

  • PulsePosition.txt
    2 KB · Views: 132
Last edited:
Maybe you should not put a "Serial.println" inside the interupt service routine (ISR should be quick).
Instead try to put results in a array or so and print out later on.

Also, I dont know how teensy in comparation to ardunio it handles. But you can try to change the pin number in "attachInterrupt(24,interrupt,CHANGE)" into "digitalPinToInterrupt(24)".
 
Serial.println takes roughly a microsecond to run on a teensy 3.6. Once the variable is set the pulses repeat at close to 50hz so there is almost 18000 microseconds free. Its more about getting better pulse data.
I have tried using digitalPinToInterrupt the routine doesnt run if I dont attach the receiver to the pin with the first method above.
 
Code:
  if(myInput.available() > 0){
    for(int i = 1; i <= myInput.available(); i++) {
    Serial.print(myInput.available());
    Serial.print(" ");
    Serial.println(myInput.read(i));
    }

Use myInput.available() only once per data set, like the example code:

Code:
void loop() {
  int i, num;

  // Every time new data arrives, simply print it
  // to the Arduino Serial Monitor.
  num = myIn.available();
  if (num > 0) {
    count = count + 1;
    Serial.print(count);
    Serial.print(" :  ");
    for (i=1; i <= num; i++) {
      float val = myIn.read(i);
      Serial.print(val);
      Serial.print("  ");
    }
    Serial.println();
  }
}

Click File > Examples > PulsePosition > LoopBack

Run the example with pins 9 and 10 connected. Then disconnect the pins and connect your PPM data to pin 10.
 
I did this during the writing of that example. I will try using the pulse position example instead. I set a variable

Code:
int j = myInput.available();

and the for loop was limited by j.

Code:
for(int i = 1; i <= j; i++)

The data was still no good. Thank you for the feedback its been really quick.

Is there anything else I can try?
 
Can you attach a photo of your wiring. Do you have a common ground? Are you getting the PPM from the trainer cable on the FS-T6 transmitter? What is the max voltage of the PPM signal? (T3.6 is NOT 5v tolerant)

Do you have scope or logic analyzer with which to monitor the PPM signal?

EDIT: Here is PulsePosition loopback example results for PPM signal from Spektrum Dx5E trainer cable, PulsePositionInput myIn(FALLING); and sticks in neutral position

Code:
     2792 :  1425.02  1500.92  1500.73  1501.90  1600.92  1101.04
     2793 :  1424.77  1500.92  1501.15  1501.60  1601.04  1100.79
     2794 :  1424.90  1500.90  1501.17  1501.60  1601.04  1100.77

spektrum.png
 
Last edited:
Is there anything else I can try?

Sure, there are lots of things you can try. But the question is what sort of thing to try next...

Since you got wrong results with the known-good PulsePosition example, I'd imagine more fiddling on the software side or with interrupts to be very unlikely to help.

The 2 directions to take at this point are investigating whether your signal really is PPM encoded, and whether you've connecting it properly to Teensy. Both of these are best done with an oscilloscope or logic analyzer to actually see the waveform.
 
I have an Arduino which measures the pulses correctly, Similarly to the first method above. I don't have an oscilliscope. I will attach a photo of the wiring shortly.

Would the 5v tolerance be an issue if its measuring such short pulses?

I dont know how I would measure the voltage from the receiver. The receiver itself is 5v...
 
Unfortunately having tried to upload a photo it repeatedly says upload failed but its quite easy to just explain.

Essentially I have the receiver powered by the Arduino with two cables, Ground and 5v. 1 wire connecting the receiver to the Teensy is what I have been using to measure the PPM.

Given that the receiver could send pulses of 5v is it possible that the low value of the pulses could register as high by the Teensy?
 
You may need to shrink your photo. forum has limit on file size.

? The RC receivers that i am familiar with have 3-pin group for each channel, and for the power/gnd connection. And the signal pin in the 3-pin group is doing PWM not PPM. PPM is coming in via the radio signal. PWM is used to drive each servo motor.

The 5v signal may have damaged the T3.6
 
I did try changing the file size but will remember for next time.

That is really useful to know. All the forums I read made me believe I was looking to read PPM signals but PWM seems obvious now.

I dont think the teensy is damaged. Its been connected for roughly only 10 seconds when testing.

What would be the simplest method converting the signals to 3.3v?
 
as Paul notes the voltage divider
resistive-logic-downshifter.png

I can't speak to the likelihood of damage from 5v servo PWM to T3.6 pin
 
Last edited:
I did think of using a voltage divider but is this a feasible solution for four channels?

Is the strength of the signals proportional to the strength of the resistors? Could I use "too strong" resistors?

I think I may be wrong about the teensy being broken. If i print digitalRead of the pin I was testing on without anything attached its reading 1...

Is there a more effective and efficient way to lower signal voltage with a little research?
 
I think I may be wrong about the teensy being broken. If i print digitalRead of the pin I was testing on without anything attached its reading 1...
Hard to say what voltage is of "floating" input pin.
A better test is to read pin (pinMode INPUT) in a loop() and then jumper GND to the pin, or jumper 3v3 to the pin. Remember for T3.6, no 5v testing!
 
I did think of using a voltage divider but is this a feasible solution for four channels?

Is the strength of the signals proportional to the strength of the resistors? Could I use "too strong" resistors?

This is really a question about the output capability of your "flysky FS-T6". Generally the higher value the resistors, the less they will load the FS-T6 output, but the weaker the signal they'll deliver to Teensy. I recommend at most 15K+10K resistors. While higher values might work, those will give a good signal that's still certain to work with Teensy.

Since you're talking about 4 signals, it sounds like these are each a PWM signal containing 1 value which repeats every cycle?

PPM signals contain up to 16 values, where all the values repeat on every cycle of the waveform. PWM=1, PPM=many. Important to know the difference!
 
its so easy when people tell you! you can spend days doing something that someone can fix in 1 hour.

Having testing the floating pin by connecting to ground it doesn't actually look broken....

Which is there best method to measure PWM waveform given that I have a voltage divider. I would really like to have to pulse length correct for just one channel at the moment. I am using 1k and 2k resistors (they are all I have for the ratio in hand).
 
Having added the voltage divider, and using the routine in the library above the data still doesn't look correct. below should be a photo of the wiring. the order I have the resistors in is signal wire from receiver - 1k resistor - signal to teensy - 2k resistor.

Photo of wiring:
20180216_234015.jpg

data is attached... View attachment Data.txt

really appreciate any feedback.
 
Me thinks you need a common ground since you have two separate power supplies. Run a jumper from ground on Arduino to ground on T3.6. (or at least I can't see common ground in photo)
 
Do I really need a logic converter for the receiver signals. My thinking is that the effective voltage would be less which is why I was happy to test 5v on teensy. In the same way you can control LED brightness with PWM. Is that reasonable... I am relatively new to understanding hardware.

Also why did sharing the common ground solve this problem?
 
Status
Not open for further replies.
Back
Top