nrf24l01 as receiver for FLYSKY transmitter

Hi guys i was wondering if it is possible for nrf modules to catch and decode the signal of a flysky transmitter and use arduino+nrf as a receiver for the stock transmitter ?
Here I have a stock Flysky CT-6B transmitter and couple of nrf's .

Does the FLYSKY use an nRF24 device? If so it may be possible. If not it is unlikely.

There was another Forum Thread a while back about using an nRF24 with an RC transmitter but I can't remember what type it was.

Why not make your own transmitter?

...R
Simple nRF24L01+ Tutorial

Thank you Robin2 you have been always helpful for my queries regarding nrf's .I did make my own transmitter and receiver and it worked out very well but due to poor chinese joysticks used I was facing some issues in controls. Youtuber Iforce2D made using similar process and faced the same issue so he used joystick from an old flysky transmitter he had as shown in his videos .He clearly showed this particular thing. Since quality joysticks are not available here loosely hence i bought a barely used Flysky CT6B transmitter without receiver.
Hence I thought if without modifying the internals with arduino and nrf if I could catch those RF signals and decode then it might be better .
Thanks
Link to my makes: Nrf_Transmitter, airplane_using_same, Quadcopter_using_same

Good luck at trying to decode AFHDS system.

Receivers both 3 and 6 channel are available for less than AU$20.00.

Note that you will need a manual and a programming lead to change/set the internal settings of the transmitter.

Manual here......http://www.ky-model.com/copterx/CX-CT6A_manual.pdf

Programming Lead........ Firmware Upgrade Download Data Cable For Flysky fly sky FS T6 I6 FS T6 FS I6 FS CT6B|flysky cable|fly skyfs t6 - AliExpress

Archut:
Hence I thought if without modifying the internals with arduino and nrf if I could catch those RF signals and decode then it might be better .

IMHO it will be 10 times faster to replace the internals with Arduino stuff unless you can find a complete tutorial for interpreting the FLYSKY wireless on the web.

...R

Thanks for the replies .I was going for replacing internals as suggested by Robin2 when I saw that it has a ps2 slot which is connected to pc for usage with simulator.
Researching on it I found that it gives a ppm output so I thought if I connect that pin to Arduino and transmit it using nrf hence I won't be needing to modify internals .
But my question is would I be facing a time lag ?

Archut:
Researching on it I found that it gives a ppm output so I thought if I connect that pin to Arduino and transmit it using nrf hence I won't be needing to modify internals .
But my question is would I be facing a time lag ?

I'm not clear what you are thinking of doing. It sounds as if you are proposing to transmit the PPM pulses but that would be completely impractical.

You need to detect the width of the pulses, in microseconds, and transmit the microseconds value for each channel (all the channels in a single nRF24 message). If pulses for all the channels are produced from the same output pin on the TX then your Arduino program will have figure out which pulse belongs to which channel. Speaking personally, I would just replace the internals.

I don't think there would be an appreciable time lag.

...R

Robin2:
I'm not clear what you are thinking of doing. It sounds as if you are proposing to transmit the PPM pulses but that would be completely impractical.
...R

I meant to decode the ppm signal and then transmit it using nrf24l01 in any form possible such as i used byte values in struct earlier and then decode and convert to whatever form you want in the receiver side.
Basically just instead of modifying internals use the ps2 pinout to access the internals.

Robin2:
Speaking personally, I would just replace the internals.
...R

I always appreciate your answers but still I wanted to try this since i knew this is possible hence i kept your answer as the last approach and further tried for catching and decoding those ppm signals and yes,
I did attain success!!!!
Here are some pics ,I'll upload the code and some explanatory pics tommorrrow as a tutorial like yours "simple nrf" so that it'll be beneficial for all.


P.S. The sole purpose of this was to use the transmitter maintaining its originality and hence i didn't want to solder wires and hack internals with arduino if possible(yes i made it possible :smiley: )
I'll test it with receiver for time lag and stuff then post the conclusion and tutorial for attaining this.
Thanks @Robin2(always helps out) & @bluejets

1 Like

From the last photo it appears you are not "decoding" anything , just simply tapping the ppm signal.

bluejets:
From the last photo it appears you are not “decoding” anything , just simply tapping the ppm signal.

Maybe i mistook tapping for decoding hence I wrote.

Archut:
P.S. The sole purpose of this was to use the transmitter maintaining its originality and hence i didn’t want to solder wires and hack internals with arduino if possible(yes i made it possible :smiley: )

What i wanted to achieve has been clearly mentioned so you can probably guess what is it tapping for decoding(my fault i didn’t get the difference.)

Well today i checked everything thoroughly and seems to work as expected ,the response and everything is working well .

Here’s my code to decode/tap those ppm signals

const int totalChannels = 6, inputPin = 3, betweenChannelDelay = 450, betweenPacket = 4000;
volatile int channel[totalChannels];
volatile byte currentChannel = 0;
volatile long lastMs = 0, p;

void ppmPulse() {
  p = micros() - lastMs;

  if (p > betweenChannelDelay)
    if (p > betweenPacket) 
      currentChannel = 0;
    else
    {
      channel[currentChannel % totalChannels] = p;
      currentChannel++;
    }

  lastMs = micros();
}

void setup() {
  Serial.begin(9600);
  while (!Serial);

  pinMode(inputPin, INPUT);

  for (int i = 0; i < totalChannels; i++)
    channel[i] = 0;

  attachInterrupt (digitalPinToInterrupt (inputPin), ppmPulse, CHANGE);
}
int b[]={2,3,1,0,4,5,7,8};

unsigned long t = 0, d = 0;
void loop() {
  if (millis() > t)
  {
    if (d > 0)
      d = millis() - d;

    Serial.print(d);

    for (int i = 0; i < totalChannels; i++)
    {
      Serial.print(i == 0 ? ":" : ",");
     int a=map(channel[b[i]],764,1480,1000,2000);
      Serial.print(channel[b[i]]);
    }
    Serial.println();
    d = millis();
    t = d + 9;
    delay(500);
  }
}

Here’s the code to use the Flysky Transmitter with nrf24l01 using the Trainer Port’s ppm pin

#include <SPI.h>
#include <nRF24L01.h>             
#include <RF24.h> 
#include <avr/wdt.h>  
const int totalChannels = 6, inputPin = 3, betweenChannelDelay = 450, betweenPacket = 4000;
volatile int channel[totalChannels];
volatile byte currentChannel = 0;
volatile long lastMs = 0, p;
unsigned long t = 0, d = 0;

const uint64_t pipeOut = 123; //IMPORTANT: The same as in the receiver!!!

RF24 radio(9, 10); // select  CE and CSN  pins
// The sizeof this struct should not exceed 32 bytes
// This gives us up to 32 8 bits channals
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
  byte AUX3;
};

MyData data;

void resetData() 
{
  //This are the start values of each channal
  // Throttle is 0 in order to stop the motors
  //127 is the middle value of the 10ADC.
    
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2 = 0;
  data.AUX3=0;
}
byte ack;

void setup() {
  Serial.begin(9600);
  pinMode(inputPin, INPUT); 
  for (int i = 0; i < totalChannels; i++)
  channel[i] = 0;

  attachInterrupt (digitalPinToInterrupt (inputPin), ppmPulse, CHANGE);// enabling interrupt at pin 3
  radio.begin();
  radio.enableAckPayload();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
  resetData();
  
}
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}

void loop() {
read_rc();
send_nrf();
}
void ppmPulse() {
  p = micros() - lastMs;

  if (p > betweenChannelDelay)
    if (p > betweenPacket) 
      currentChannel = 0;
    else
    {
      channel[currentChannel % totalChannels] = p;
      currentChannel++;
    }

  lastMs = micros();
}
void send_nrf(){
if(radio.isChipConnected ()){
  data.throttle = mapJoystickValues( channel[2], 776, 1096, 1432,false );
  data.yaw      = mapJoystickValues( channel[3],  900, 1108, 1316, true );
  data.pitch    = mapJoystickValues( channel[1], 948, 1112, 1280, false );
  data.roll     = mapJoystickValues( channel[0],924, 1108, 1300, true );
  data.AUX1=map(channel[5],596,1624,0,255);
  data.AUX2=map(channel[4],596,1624,0,255);
  //Serial.print("throttle-");
  //Serial.print(data.throttle);
  //Serial.print(" ");
  //Serial.print("yaw-");
  //Serial.print(analogRead(A1));
  //Serial.print(" ");
  //Serial.print("pitch-");
  //Serial.print(analogRead(A2));
  //Serial.print(" ");
  //Serial.print("roll-");
  //Serial.print(analogRead(A3));
  //Serial.println();
  //Serial.print(data.AUX1);
  //Serial.print(" ");
  //Serial.print(data.AUX2);
  //Serial.print(" ");  Serial.println(data.AUX3);

  radio.write(&data, sizeof(MyData));
   if ( radio.isAckPayloadAvailable() ) {
            radio.read(&ack, sizeof(ack));
             Serial.println(ack);     
             digitalWrite(5,LOW); 
            }
            
      

else{
  
  Serial.println("no ack");
  digitalWrite(5,HIGH);

}

}
else{
  Serial.println("Make proper connections"); //no radio inserted or bad connection
}
}  
void read_rc(){
  if (millis() > t)
  {
    if (d > 0)
      d = millis() - d;

    Serial.print(d);

    for (int i = 0; i < totalChannels; i++)
    {
      Serial.print(i == 0 ? ":" : ",");
      Serial.print(channel[i]);
    }
    Serial.println();
    d = millis();
    t = d + 9;
    //delay(500); uncomment to check serial monitor values slowly
  }
}

Thank you but there’s a new query since using the ppm requires to turn on the transmitter from battery pack it is transmitting meanwhile or basically radios with 2.4GHz are working.
Will these interrupt nrf signal which will work in parallel ,also uses 2.4GHz and give me problems .Though i’ll be performing a small range test since pandemic is on but still want to know from you guys.

Archut:
Will these interrupt nrf signal which will work in parallel ,also uses 2.4GHz and give me problems

You may need to try different nRF24 channels.

...R

Robin2:
You may need to try different nRF24 channels.

...R

Thanks ,I achieved what I wanted and flew my quadcopter with any disturbances in a confined area due to pandemic .This was proved as was constantly receiving ack which I kept to know for wireless issues only.
I'll go for a long distance test once pandemic is over and then check for the wireless disturbances and try changing the channels then.
Thanks :slight_smile: