Menu

Frsky anyone? :)

Features
Anonymous
2013-02-07
2013-11-16
  • Anonymous

    Anonymous - 2013-02-07

    Hi,

    im trying this lib with my FrSKY modules. Got one DHT Hack Module on my Arduino Mini (5V, 16MHz) and a CPPM receiver at my Mega.

    Receiver is working (need to use pin 53 for CPPM input)

    But the sender... Dont know how to setup the pulse & pause lengths... any help ? :)

    Regards, Frederik

     
  • dvdouden

    dvdouden - 2013-02-11

    RC equipment usually isn't that picky when it comes to pulse and pause lengths. 500 microseconds for pulse and 10000 for pause should be a good starting point.

     
  • Anonymous

    Anonymous - 2013-04-21

    Hm, cat get it.

    got some other code, but i want to use your lib

    void setupPPM() {
    
      // configure Timer1 for PPM generation
      noInterrupts();
      TCCR1A = B00110001;   // COM1B1, COM1B0, WGM10 set to 1 (8-bit register)
      TCCR1B = B00010010;   // WGM13 & CS11 set to 1 (8-bit register)
      TCCR1C = B00000000;
      TIMSK1 = B00000010;   // All interrupts are individually masked with the Timer Interrupt Mask Register TIMSK1
      TIFR1  = B00000010;       // Int on compare B
      OCR1A = PPM_PERIOD;   // PPM frequency (double buffered Output Compare 16-bit Register)
      OCR1B = PPM_LOW;      // (double buffered Output Compare 16-bit Register), hard-wired to PPM_PIN 
      interrupts();
    
    }
    
    // Generate PPM sequence
    ISR(TIMER1_COMPA_vect) {
      static byte Chan_idx_byt = CHANNELS;
      static word Chan_pulse_int[CHANNELS]; // pulse widths (microseconds)
      static word Sum_int = 0;
    
      if (Chan_idx_byt < CHANNELS) {
        word chanpulse_int = Chan_pulse_int[Chan_idx_byt++];
        // send current channel pulse
        OCR1A = chanpulse_int;
        Sum_int += chanpulse_int;
      }
      else {
        // send final sync pulse
        Chan_idx_byt = 0;
        OCR1A = PPM_PERIOD - Sum_int;
        Sum_int = 0;
        // Read input controls and update Chan_pulse_int[]
        // Execution time: [2308, 2324] microseconds < OCR1A
        for (byte chan_byt = 0; chan_byt < CHANNELS; chan_byt++) {
          word control_value_int = 0;
    #ifdef TEST_MODE
          if (RunMode_int == RUNMODE_TEST)
            control_value_int = get_test_value(chan_byt);
          else
    #endif
            control_value_int = read_control(chan_byt);
          Chan_pulse_int[chan_byt] =  compute_channel_pulse(chan_byt, control_value_int, true);
        }
        if (RequestPpmCopy_bool) {
          // copy the PPM sequence values into global array for the "print ppm" command
          for (byte chan_byt = 0; chan_byt < CHANNELS; chan_byt++)
            PpmCopy_int[chan_byt] = Chan_pulse_int[chan_byt] ;
          RequestPpmCopy_bool = false;
        }
      }
    }
    
    // Compute the channel pulse corresponding to given analog value
    // chan_byt : 0-based, channel number - 1
    // ana_value_int : read from input: [0,1023]
    // enable_calibration_bool : true=apply calibration data to analog input controls, false=do not apply calibration
    // Return value: PWM pulse width, microseconds
    word compute_channel_pulse(byte chan_byt, word ana_value_int, boolean enable_calibration_bool) {
        word retval_int = 0;
        float value_flt = ana_value_int;
    
        // Map analog inputs to PPM rates
        retval_int =  map(constrain(value_flt, 0, 1023), 0, 1023, pwm_min, pwm_max);
    
        // Limit pulse pulse width between CHAN_PWL, CHAN_PWH
        retval_int = constrain(retval_int, pwm_min, pwm_max);
    
        return retval_int;
    }
    
     

    Last edit: dvdouden 2013-04-21
    • dvdouden

      dvdouden - 2013-04-21

      That code looks okay. I'd probably do things a bit differently but I don't see any big issues. If you want to use my code, check out the PPMOut class and its example.

       
  • Anonymous

    Anonymous - 2013-04-21

    Hm, i have tried to find the differences. but i dont find the catch...

     
  • Anonymous

    Anonymous - 2013-04-21

    btw, i use the following timing params for the code above:

    const word PPM_PERIOD = 20000; // microseconds; send PPM sequence every 20ms for 6 channels
    const word PPM_LOW = 400; // microseconds; fixed channel sync pulse width in the PPM signal

     
    • dvdouden

      dvdouden - 2013-04-22

      http://diydrones.com/profiles/blogs/why-frsky-cppm-signal-is-so-disappointing
      try 18000 or 27000 for PPM_PERIOD, it seems to be what FRSky is using.

       
      • Anonymous

        Anonymous - 2013-04-22

        PPM_PERIOD = 20000 is ok for the above code. My problem is: dont know what to pulse & pause in your code. :)

        Tried some combin ations but still no luck. The servo at the receiver is shacking in al directions every second

         
        • Anonymous

          Anonymous - 2013-04-22

          Great, SourceForge won't let me post under my own name again...

          Aaah, you should've said that in the first place ;)

          400 for pulse, about 4000 for pause should be enough. PPMOut has a variable frame width, I'm not sure how well FRSky will deal with that, but it shouldn't be a problem (a lot of (cheap) transmitters work this way).

          If that doesn't work, try replacing updateTimings in PPMOut.cpp with the following:

          void PPMOut::updateTimings()
          {
              uint16_t* scratch = m_timings;
              uint16_t pause = m_pauseLength;
              // copy all pre-calculated timings
              for (uint8_t i = 0; i < m_channelCount; ++i)
              {
                  // set pulse length
                  *scratch = m_pulseLength;
                  ++scratch;
                  // set timing
                  *scratch = m_channelTimings[i] - m_pulseLength;
                  pause -= m_channelTimings[i];
                  ++scratch;
              }
              // set final pulse length
              *scratch = m_pulseLength;
              ++scratch;
              // set pause length
              *scratch = pause - m_pulseLength;
              // update number of timings
              m_timingCount = (m_channelCount + 1) * 2;
          }
          

          and set pause length to 20000, this will make PPMOut generate a fixed width frame.

           

          Last edit: dvdouden 2013-04-22
          • Anonymous

            Anonymous - 2013-04-22

            Ah! Thanks, will try it later @home!

             
          • Anonymous

            Anonymous - 2013-04-22

            Ok, patched PPM Code working like a charm :)

            My Projekt btw: http://dt.pe/GAl2nw

             
            • Anonymous

              Anonymous - 2013-04-23

              Great! Glad it works, I'll put in on my patch list :)

              And holy f..., is that a remote controlled lawnmower? O_O

              DvdOuden (SourceForge acting up again)

               

              Last edit: dvdouden 2013-04-23
              • Anonymous

                Anonymous - 2013-04-23

                It is ;)

                 
              • Anonymous

                Anonymous - 2013-04-28

                Small Video. Much use of the Library (ppmin, expo & dualrate)

                http://youtu.be/hcQXAF7YBXM

                 
                • Anonymous

                  Anonymous - 2013-04-29

                  That's just awesome :)

                   
  • Anonymous

    Anonymous - 2013-11-16
    Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.