PPM output using pulseposition library on teensy 3.6

Status
Not open for further replies.

Moobie

Member
Hello,

I am facing trouble using the pulseposition library.

i would like to send PPM signal (16 channels) on a Pixhawk to simulate RC Command with my teensy 3.6.
I am using the pulseposition library but when i look at the signal received by the Pixhawk on Mission planner, i can see that some of the PPM signal are not received by the Pixhawk (or at least not shown on mission planner in real time) and when i am controling a real robot using this library to send PPM Signal i have a big delay >50 ms between the command and the motion of the drone (i am using a teensy to overwrite the RC Command).
below the code that i am using for my test:

Code:
#include <PulsePosition.h>
PulsePositionOutput myOut;
int i;
void setup() {
  myOut.begin(6,7);  // myOut.begin(6, 7);  // txPin = 6, framePin = 7
  pinMode(2, OUTPUT); 
  pinMode(2, HIGH);
  i=0;
}

void loop() {
  pinMode(2, HIGH);
  myOut.write(0, 1100+i*10);
  myOut.write(1, 1200+i*10);
  myOut.write(2, 1300+i*10);
  myOut.write(3, 1400+i*10);
  myOut.write(4, 1500+i*10);
  myOut.write(5, 1600+i*10);
  myOut.write(6, 1700+i*10);  
  myOut.write(7, 1800+i*10);
  i++;
  if(i>10){
    i=0;
  }
}
I have try loopback and it was working well.
Do i have to modify anithing and the arduino software before the complying (modify the CPU Speed for example)?
Do i have to connect pin other that the pin 6 to my pixhawk (to send the PPM Signal).

Thanks a lot for your help.

(Ps: sorry for my bad english)
 
Last edited:
you left out a few lines on your sample sketch. it doesn't compile.
also in loop() you are changing encoder values about 100,000 times per second, but of course your PPM stream cycles every 20 ms, so maybe for testing add a delay(1000); at the end of loop(). Not sure where the 50 ms delay is coming from. do you have logic analyzer or scope?
 
i forgot the following line before int i;


Code:
PulsePositionOutput myOut;

I already try to add delay around 20 or 50 ms, and it is not working. When i set a delay of 1000ms is it working correctly.
I don't have any scoop to visualize the PPM send.
 
As Manitou noted - the code presented isn't complete and compile-able as it should be - there is no define for :: myOut.

Based on the delay(1000) making it work it seems the updates to the PWM value are too rapid to be properly processed. The Teensy will be running this loop() as noted at or over 100,000 times per second.

Is this code written to work always updating all 8 channels - or just done to test the function?
 
channels are numbered starting with 1 so i'm not sure what myOut.write(0, 1100+i*10); does
 
looks like:

Code:
bool PulsePositionOutput::write(uint8_t channel, float microseconds)
// ...
  if (channel < 1 || channel > PULSEPOSITION_MAXCHANNELS) return false;
 
I am sorry for the poor copy/past of my code.
This code is supposed to update all the channels (up to 16 channels) at a rate of 10~20ms.
 
The RC type Pulse control has an update interval of typically 20ms, if this is sent from your controller to a robot controller, and the robot controller then outputs the same type of signals to a servo then you must add the delay in sending from the Teensy, in interpreting the signal by the robot (drone) controller and then the delay from the robot controller to the motor. So perhaps 50 ms is what one can expect.
 
Status
Not open for further replies.
Back
Top