Menu

Using the PPMout example

Bugs
Anonymous
2020-08-27
2020-08-31
  • Anonymous

    Anonymous - 2020-08-27

    Hey, I just wanted to thank you for working through all this code and making an awesome library set.

    I'm having some weird things going on when trying to use the PPMout example code. I've only changed the number of channels to 6 and added the additional analog pins.`/ ---------------------------------------------------------------------------
    This software is in the public domain, furnished "as is", without technical
    support, and with no warranty, express or implied, as to its usefulness for
    any purpose.

    ppmout_example.pde
    Demonstrate Pulse Position Modulation Output functionality

    Author: Daniel van den Ouden
    Project: ArduinoRCLib
    Website: http://sourceforge.net/p/arduinorclib/
    -------------------------------------------------------------------------/

    include <ppmout.h></ppmout.h>

    include <timer1.h></timer1.h>

    define CHANNELS 6

    uint8_t g_pins[CHANNELS] = {A0, A1, A2, A3, A4, A5}; // Input pins
    uint16_t g_input[CHANNELS]; // Input buffer in microseconds
    uint8_t g_work[PPMOUT_WORK_SIZE(CHANNELS)]; // we need to have a work buffer for the PPMOut class

    // PPMOut requires two buffers:
    // Input buffer containing input samples in microseconds
    // Work buffer of ((channels + 1) * 2) elements for internal calculations and frame buffering
    // This setup removes any limit on the number of channels you want, and makes sure the library doesn't use more
    // memory than it really needs, since the client code supplies the buffers.
    rc::PPMOut g_PPMOut(CHANNELS, g_input, g_work, CHANNELS);

    void setup()
    {
    // Initialize timer1, this is required for all features that use Timer1
    // (PPMIn/PPMOut/ServoIn/ServoOut)
    rc::Timer1::init();

    for (uint8_t i = 0;  i < CHANNELS; ++i)
    {
        // set up input pins
        pinMode(g_pins[i], INPUT);
    
        // fill input buffer, convert raw values to microseconds
        g_input[i] = map(analogRead(g_pins[i]), 0, 1024, 1000, 2000);
    }
    
    // initialize PPMOut with some settings
    g_PPMOut.setPulseLength(448);   // pulse length in microseconds
    g_PPMOut.setPauseLength(10448); // length of pause after last channel in microseconds
    // note: this is also called the end of frame, or start of frame, and is usually around 10ms
    
    // start PPMOut, use pin 9 (pins 9 and 10 are preferred)
    g_PPMOut.start(9);
    

    }

    void loop()
    {
    // update the input buffer
    for (uint8_t i = 0; i < CHANNELS; ++i)
    {
    // fill input buffer, convert raw values to microseconds
    g_input[i] = map(analogRead(g_pins[i]), 0, 1024, 1000, 2000);
    }

    // tell PPMOut there are new values available in the input buffer
    g_PPMOut.update();
    

    }`
    I've got 4 out of my 6 pins tied HIGH while the other two have pots attached. I tested the analog read with this code:

    void setup() {
      // put your setup code here, to run once:
    Serial.begin(9600);
    }
    
    void loop() 
    {
    
    Serial.print(analogRead(A0));
    Serial.print("\t");
    Serial.print(analogRead(A1));
    Serial.print("\t");
    Serial.print(analogRead(A2));
    Serial.print("\t");
    Serial.print(analogRead(A3));
    Serial.print("\t");
    Serial.print(analogRead(A4));
    Serial.print("\t");
    Serial.println(analogRead(A5));
    
    
    }
    
    Outputs this:
    535 1023    614 1023    1023    1023
    535 1023    612 1023    1023    1023
    535 1023    613 1023    1023    1023
    535 1023    612 1023    1023    1023
    535 1023    614 1023    1023    1023
    535 1023    614 1023    1023    1023
    535 1023    614 1023    1023    1023
    535 1023    612 1023    1023    1023
    535 1023    612 1023    1023    1023
    535 1023    613 1023    1023    1023
    535 1023    612 1023    1023    1023
    535 1023    613 1023    1023    1023
    

    So, I would assume that the PPM signal I generate would look something like: 1.5, 2, 1.55,2,2,2 (in total length).

    However, when comparing it with the PPM out signal from my FSi6 (with a logic analyzer), they aren't even close. I've attached the images of the logic.

    My end goal is to generate a PPMout with the arduino and feed it into the PPMin of my FSi6 transmitter.

    Do you have any thoughts as to why this is happening?

    Cheers,

     
    • dvdouden

      dvdouden - 2020-08-31

      weird...
      I haven't touched this code in 5 years or so, so there might have been changes in the Arduino landscape that broke this bit of functionality, but it's more likely that I messed up somewhere...
      I'll see if I can find a working Arduino in my parts collection and test it somewhere this week...

       

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.