I'm using the PPMOut example and have added the updateTimings() method as updateTimingsFF() so I can switch back and forth. Of cource the new method was added to the PPMOut.h file. What I'm getting looks like no pause period is being set. I've looked on an Oscope. But when I throw some debug into the channel read section of loop() that must delay enough because then my FrSky receiver at least gets jittering data.
I also added this update I saw you mention in another thread:
Here's my TestPPMOut.ino example( using Adafruit Trinket Pro 5v ):
/* ---------------------------------------------------------------------------** 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/** -------------------------------------------------------------------------*///NOTE: weird formating while posting, this line is not in the code: include <PPMOut.h>#include<PPMOut.h>#include<Timer1.h>#define DEBUG // enable FTDI port output for debugging, disable serial write of JSIG data#ifdef DEBUG#define DEBUG_PRINT(x) Serial.print (x)#define DEBUG_PRINTLN(x) Serial.println (x)#else#define DEBUG_PRINT(x)#define DEBUG_PRINTLN(x)#endif#define CHANNELS 2uint8_tg_pins[CHANNELS]={A0,A1};//, A1, A1};//, A1, A1, A1, A1}; // Input pinsuint16_tg_input[CHANNELS];// Input buffer in microsecondsuint8_tg_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::PPMOutg_PPMOut(CHANNELS,g_input,g_work,CHANNELS);voidsetup(){// Initialize timer1, this is required for all features that use Timer1// (PPMIn/PPMOut/ServoIn/ServoOut)rc::Timer1::init();// use (true) for debugging(ie slows everything down;for(uint8_ti=0;i<CHANNELS;++i){// set up input pinspinMode(g_pins[i],INPUT);// fill input buffer, convert raw values to microsecondsg_input[i]=1500;//DJL map(analogRead(g_pins[i]), 0, 1024, 1000, 2000);}// initialize PPMOut with some settingsg_PPMOut.setPulseLength(448);//448); // pulse length in microsecondsg_PPMOut.setPauseLength(10448);//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);g_PPMOut.start(9,true);// inverts the PPM signal#ifdef DEBUGSerial.begin(19200);DEBUG_PRINTLN("Start DEBUG");#endif }voidloop(){// update the input bufferfor(uint8_ti=0;i<CHANNELS;++i){// fill input buffer, convert raw values to microsecondsg_input[i]=map(analogRead(g_pins[i]),0,1024,1000,2000);if(i==0){DEBUG_PRINTLN("");DEBUG_PRINT("mapped AnalogRead=");DEBUG_PRINT(g_input[i]);}else{DEBUG_PRINT(":");DEBUG_PRINT(g_input[i]);}}// tell PPMOut there are new values available in the input bufferg_PPMOut.update();}
PPMOut.cpp added method:
// fixed frame...
void PPMOut::updateTimingsFF()
{
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;
}
Last edit: Doug LaRue 2015-11-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using the PPMOut example and have added the updateTimings() method as updateTimingsFF() so I can switch back and forth. Of cource the new method was added to the PPMOut.h file. What I'm getting looks like no pause period is being set. I've looked on an Oscope. But when I throw some debug into the channel read section of loop() that must delay enough because then my FrSky receiver at least gets jittering data.
I also added this update I saw you mention in another thread:
Here's my TestPPMOut.ino example( using Adafruit Trinket Pro 5v ):
PPMOut.cpp added method:
Last edit: Doug LaRue 2015-11-04
I grabbed v.04 and it worked with the output inverted using the default timing in the example.