Giter VIP home page Giter VIP logo

symaxrx's Introduction

SYMAX Receiver

Thanks to

Goal

This code decodes frames from the X5C-1, X11, X11C, X12... transmitter (blue or green led) with an arduino and a nrf24L01+ chip. NOT the old x5c! This code has not been tested enough and it is not super reliable. So don't use it with dangerous rc model as planes, helicopters, cars...

DEMO VIDEO

Hardware

Arduino, nrf24l01+ chip Connect SCK, MISO, MOSI on pins D13, D12 and D11. Then connect CE and CS on digital pins you have chosen in the code (see the wireless.setPins() method below). Finally connect nrf24l01 VCC and GND to arduino 3.3V (if you plan to NOT use the chip in low power mode, get a proper 3.3v power supply or you may destroy the Arduino) and GND pins.

Use

There are two classes :

  • nrf24l01p : handle the spi protocol to communicate with the nrf24l01p chip
  • symax_protocol : handle the symax protocol

symax_rx.ino is an example showing how use theses classes.

These two classes are instantiated :

nrf24l01p wireless; 
symaxProtocol protocol;

The nrf24l01 pins must be defined in arduino setup function. setPins method arguments define the nrf24L01 CE (chip enable) and CS (SPI chip select) pins in this order. In my example, I did not use SS arduino pin as CS but SS pin must be set to output to activate the SPI mode to master.

void setup() {
  ...
  // SS pin must be set as output to set SPI to master !
  pinMode(SS, OUTPUT);

  // Set CE pin to 10 and CS pin to 9
  wireless.setPins(10,9);
  
  // Set power (PWRLOW,PWRMEDIUM,PWRHIGH,PWRMAX)
  wireless.setPwr(PWRLOW);
  
  protocol.init(&wireless);
  ...
}

SPI wrapper (nrf24l01p class) are linked to the protocol in the setup function

protocol.init(&wireless);

In the loop function, symaxProtocol Run() method must be called AT MOST every 4ms with & rx_values_t structure:

uint8_t value = protocol.run(&rxValues);

This function has several kind of returns from an enum :

enum rxReturn
{
   BOUND_NEW_VALUES = 0,   // Bound state, frame received with new TX values
   BOUND_NO_VALUES,        // Bound state, no new frame received
   NOT_BOUND,              // Not bound, initial state
   BIND_IN_PROGRESS,       // Bind in progress, first frame has been received with TX id, wait no bind frame.
   UNKNOWN                 // Not used for moment
};

When a frame is received (BOUND_NEW_VALUES), rx_values_t structure can be read :

typedef struct __attribute__((__packed__)) {
  uint8_t throttle; // 0...255
  int8_t yaw; // 127...-127
  int8_t pitch; // 127...-127
  int8_t roll; // 127...-127
  int8_t trim_yaw; // 31...-31
  int8_t trim_pitch; // 31...-31
  int8_t trim_roll; // 31...-31
  bool video; // true means button is down
  bool picture; // true means button is down
  bool highspeed; // true means high speed mode selected
  bool flip; // true means button is down
} rx_values_t;

Four axis, 3 trims values and buttons are available.

Improvements

Some improvements :

  • Handle missing frame : for each frequency, transmitter send two frames in 8 ms. If there are lost, received will wait 4 frequency switching * 8ms to get frame. It would be interesting to jump some frequencies to retrieve the channel switching faster.

symaxrx's People

Contributors

suxsem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symaxrx's Issues

incrementChannel UnBinds the TX

if i disable incrementChannel in symax_protocol.cpp at line 80 , The TX Works with Arduino and never cuts. Else it cuts after sending 2 frames of data.

You should have a variable to set this in the example file.

I used Syma x5-C Blue Led Remote.

Does not bind

Thanks for uploading the library, I am trying to get it working but when I run the code I can't get past Bind in progress.

I am using almost the exact sample code you posted, nothing else is connected to the Arduino. Pins connected as follows:

SCK -> 13
MO -> 11
MI -> 12
CSN -> 9
CE -> 10

Code:

#include <SPI.h>
#include <symax_protocol.h>

nrf24l01p wireless; 
symaxProtocol protocol;

unsigned long time = 0;

void setup() {

  Serial.begin(115200);

  // SS pin must be set as output to set SPI to master !
  pinMode(SS, OUTPUT);

  // Set CE pin to 10 and CS pin to 9
  wireless.setPins(10,9);
  
  // Set power (PWRLOW,PWRMEDIUM,PWRHIGH,PWRMAX)
  wireless.setPwr(PWRLOW);
  
  protocol.init(&wireless);
  
  time = micros();
  Serial.println("Start");
  
}

rx_values_t rxValues;

unsigned long newTime;

void loop() 
{
  time = micros();
  uint8_t value = protocol.run(&rxValues); 
  newTime = micros();
   
  switch( value )
  {
    case  NOT_BOUND:
        Serial.println("Not bound");
    break;

    case  BIND_IN_PROGRESS:
        Serial.println("Bind in progress");
    break;
    
    case BOUND_NEW_VALUES:
      Serial.print(newTime - time);
      Serial.print(" :\t");Serial.print(rxValues.throttle);
      Serial.print("\t"); Serial.print(rxValues.yaw);
      Serial.print("\t"); Serial.print(rxValues.pitch);
      Serial.print("\t"); Serial.print(rxValues.roll);
      Serial.print("\t"); Serial.print(rxValues.trim_yaw);
      Serial.print("\t"); Serial.print(rxValues.trim_pitch);
      Serial.print("\t"); Serial.print(rxValues.trim_roll);
      Serial.print("\t"); Serial.print(rxValues.video);
      Serial.print("\t"); Serial.print(rxValues.picture);
      Serial.print("\t"); Serial.print(rxValues.highspeed);
      Serial.print("\t"); Serial.println(rxValues.flip);
      //time = newTime;

      //do stuff
      
    break;

    case BOUND_NO_VALUES:
      //Serial.print(newTime - time); Serial.println(" : ----");
    break;

    default:
    break;

  }  
}

It starts up reporting Not bound, I turn on my Syma X5HW-1 controller (blue LED flashing), move the stick all the way up and down (blue LED solid). Serial output then changes to Bind in progress but it never manages to bind. Any idea what is going wrong?

error compil

C:\Users\YSkor\Documents\Arduino\libraries\symaxrx-master\symax_protocol.cpp:258:44: error: 'START_CHANS_3' was not declared in this scope

         mRFChanBufs[i] = pgm_read_byte(START_CHANS_3 + i) + (laddress & 0x07);

                                        ^

exit status 1
Error compiling for board WAVGAT UNO R3.

Led pin

Hello,
Thanks for this share code.
In your prototype, i see a red Led.
Which arduino pin drive this Led ?
Thanks

Does not get past "Bind In Progress" Please help.

I am also having this same issue, it does not look like Bluse7en had ever solved his version, but mine is the exact same thing. Once the code has been uploaded to the Pro Mini, the Com output does not show the transmitter binding. I am using Suxsem's version of the code but its almost exactly the same. It shows not bound initially and once the transmitter is switched on, it changes to Bind In Progress but thats it. Moving the throttle does nothing. I have been trying to get this to work now for about 5 days and am out of ideas. Any help would be very much appreciated.

-Thank You so much!

doesn't bind at all to an x11 contoller

serial monitor constantly returns "not bound" (code is the example but without the servo)

#include <SPI.h>

#include <symax_protocol.h>
#include <nrf24l01p.h>

/* symax_rx.ino -- An arduino sketch to test the protocol symax
 *
 */

//#include <Servo.h>

//Servo myservo;  // create servo object to control a servo

nrf24l01p wireless; 
symaxProtocol protocol;

unsigned long time = 0;

void setup() {

  Serial.begin(115200);

  //myservo.attach(8);  // attaches the servo on pin 8 to the servo object

  // SS pin must be set as output to set SPI to master !
  pinMode(SS, OUTPUT);

  // Set CE pin to 10 and CS pin to 9
  wireless.setPins(10,9);
  //RF24 radio(10, 9);
  
  // Set power (PWRLOW,PWRMEDIUM,PWRHIGH,PWRMAX)
  wireless.setPwr(PWRMEDIUM);
  
  protocol.init(&wireless);
  
  time = micros();
  Serial.println("Start");
  
}

rx_values_t rxValues;

unsigned long newTime;

void loop() 
{
  time = micros();
  uint8_t value = protocol.run(&rxValues); 
  newTime = micros();
   
  switch( value )
  {
    case  NOT_BOUND:
        Serial.println("Not bound");
    break;

    case  BIND_IN_PROGRESS:
        Serial.println("Bind in progress");
    break;
    
    case BOUND_NEW_VALUES:
      Serial.print(newTime - time);
      Serial.print(" :\t");Serial.print(rxValues.throttle);
      Serial.print("\t"); Serial.print(rxValues.yaw);
      Serial.print("\t"); Serial.print(rxValues.pitch);
      Serial.print("\t"); Serial.print(rxValues.roll);
      Serial.print("\t"); Serial.print(rxValues.trim_yaw);
      Serial.print("\t"); Serial.print(rxValues.trim_pitch);
      Serial.print("\t"); Serial.print(rxValues.trim_roll);
      Serial.print("\t"); Serial.print(rxValues.video);
      Serial.print("\t"); Serial.print(rxValues.picture);
      Serial.print("\t"); Serial.print(rxValues.highspeed);
      Serial.print("\t"); Serial.println(rxValues.flip);
      //time = newTime;

      //myservo.write(map(rxValues.roll, -127, 127, 0, 180));              // tell servo to go to position
      
    break;

    case BOUND_NO_VALUES:
      //Serial.print(newTime - time); Serial.println(" : ----");
    break;

    default:
    break;

  }

}

bind in progress

hi !
i am having a problem binding with syma x5c-1 blue led
when code starts serial monitor shows no bound after when i turn on the transmitter it gets not bound TO BOND IN PROGRESS
and stucks at this point even if i turn of my transmitter but no luck ,looking for a possible solution
all of my connections of NRF24L01

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.