Compile error in PulsePositionIMXRT library

mogplus8

Member
Hi All,
I am using a Teensy LC (Yes I know it's old and no longer supported, but thought I'd ask anyway) for a project using the PulsePosition library. I got some odd results, and after a bit of research I found there is another version for the LC (and others) called PulsePositionIMXRT. I tried that but it threw two compile errors, which are:
Code:
In file included from /home/ian/Arduino/TeensyLC/TeensyLC.ino:2:
/home/ian/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/PulsePosition/PulsePositionIMXRT.h:49:26: error: 'IMXRT_TMR_t' does not name a type
   49 |                 volatile IMXRT_TMR_t* tmr;
      |                          ^~~~~~~~~~~
/home/ian/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/PulsePosition/PulsePositionIMXRT.h:67:84: error: 'IMXRT_TMR_CH_t' does not name a type
   67 |         static inline void checkAndProcessTimerCHInPending(uint8_t index, volatile IMXRT_TMR_CH_t *tmr_ch);
      |                                                                                    ^~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1
Since my knowledge of C++ is zero, what do I have to do to fix these errors?
Thanks.
 
IMXRT is Teensy 4.0. The PulsePosition library should use it automatically when you have Teensy 4.0 or 4.1 selected.
 
Last edited:
Thanks for the reply. I appreciate the effort to support old hardware. :)

I'm using pin 6, which is one of the allowed pins. Here's the code.
Code:
#define __IMXRT1062__
#include "PulsePositionIMXRT.h"
PulsePositionOutput ppm;

void setup() {
  // put your setup code here, to run once:
  ppm.begin(6);
}

void loop() {
  // put your main code here, to run repeatedly:
  ppm.write(1, 1000);
  ppm.write(2, 1100);
  ppm.write(3, 1200);
  ppm.write(4, 1300);
  ppm.write(5, 1400);
  ppm.write(6, 1600);
  ppm.write(7, 1800);
  ppm.write(8, 2000);
}

Thanks.
 
Delete the first 2 lines and replace with normal PulsePosition.h include. Then is compiles with Teensy LC without any error.

Code:
#include <PulsePosition.h>

PulsePositionOutput ppm;

void setup() {
  // put your setup code here, to run once:
  ppm.begin(6);
}

void loop() {
  // put your main code here, to run repeatedly:
  ppm.write(1, 1000);
  ppm.write(2, 1100);
  ppm.write(3, 1200);
  ppm.write(4, 1300);
  ppm.write(5, 1400);
  ppm.write(6, 1600);
  ppm.write(7, 1800);
  ppm.write(8, 2000);
}

I ran it here on a Teensy LC connected to my oscilloscope.

1721385787432.png


file.png
 
Hi Paul, and thanks again for you help.

This is what I get when I run it using PulsePosition. To try to make things a bit easier to see, I changed the pulse lengths so they alternated between 1000 and 2000 (i.e. channels 1, 3, 5, and 7 were 1000, 2, 4, 6, 8 were 2000). My results don't seem to correlate with that at all, in fact there were no pulses that were either 1000 or 2000 in the whole sample. The space between pulses should be 300us but that doesn't seem to be happening either. This is why I originally thought I was using the wrong version, and tried the IMXRT version. (the github doc mentions Teensy 3.x and LC, so I thought I was on a winner!)
View attachment 35126

Just for fun I ran the same program on a Teensy 4.1, and it worked much better. Although all the 1000us pulses were 900us, and all the 2000us pulses were 1900us, and the inter pulse gap (for want of a better description) were all 100us, but apart from that, perfect. One other thing, it's upside down.
1721448207001.png

;-) Ian
 
PPM is Pulse Position Modulation. It is not Pulse Width Modulation (PWM).

Your screenshot shows 100us high pulses followed by 900us low where you configured 1000us. It is working exactly as expected. This is PPM. The position of the pulse is the thing you're controlling.
 
Hi Paul,

You are correct, it does work correctly, on a Teensy 4.1 (with a couple of caveats, as I mentioned in my previous post). However I get completely different results running it on the LC. The screenshot I tried to post in my last post of the results from the LC seems to have disappeared into cyber space, so I've attached it (and a couple more showing more detail) as attachments this time. But when I did that I got a popup that asked me if I'd like to insert them, so I clicked yes. Not entirely sure what I've done but I hope you get to see them.
Screenshot_20240721_125358.png
Screenshot_20240721_125333.png


Thanks, Ian
 

Attachments

  • Screenshot_20240721_125304.png
    Screenshot_20240721_125304.png
    41.9 KB · Views: 36
Before I look at this yet again, please give me the exact program you're running for these tests. Even if it's "trivial" to figure out from your description in msg #6, save me some time and guesswork by giving me the exact code to copy into Arduino IDE.
 
Yeah I think we are rapidly approaching the point of diminishing returns. I was hoping to avoid pulling the veroboard out of my tranny and completely rewiring it to use a different chip (something a bit more recent perhaps?...) as it will be a right royal PITA, but it may be the only viable solution. So, hoping for the best while fearing the worst (as my dear old mum used to say), here's the code.

Code:
#include <PulsePosition.h>
PulsePositionOutput ppm;

void setup() {
  // put your setup code here, to run once:
  ppm.begin(6);
}

void loop() {
  // put your main code here, to run repeatedly:
  ppm.write(1, 1000);
  ppm.write(2, 2000);
  ppm.write(3, 1000);
  ppm.write(4, 2000);
  ppm.write(5, 1000);
  ppm.write(6, 2000);
  ppm.write(7, 1000);
  ppm.write(8, 2000);
}
 
Back
Top