Hi all,
I'm using a Teensy 3.5 and having trouble using the PulsePosition library to read a regular RC servo signal. Here's the deal.
Using a simple pulseIN() code works ok, but of course is not ideal. Code as below:
Output:
The LoopBack example of PulsePosition also works ok if the two pins are connected toegther (10 to 6 in this case) as shown below(I changed the input pin to pin 6 in this case):
Output:
However, the same code above will not detect any pulse if connected to a RC servo PWM generator. The generator has been tested with many different servos as well as with an Arduino and is working fine. I've tried connecting an RC receiver (verified working) and that does not trigger any signal as well.
This leads me to think that the issue is in software and not hardware, as all hardware seems to be working normally.
Can anyone offer any ideas as to why this behavior?
I'm using a Teensy 3.5 and having trouble using the PulsePosition library to read a regular RC servo signal. Here's the deal.
Using a simple pulseIN() code works ok, but of course is not ideal. Code as below:
Code:
char pin = 6;
void setup() {
Serial.begin(9600);
while (!Serial);
pinMode(pin, INPUT);
}
void loop() {
Serial.println(pulseIn(pin, HIGH));
delay(500);
}
Output:
Code:
1493
1331
990
990
990
1233
1754
1949
2015
2014
1949
1380
990
990
991
990
990
990
990
990
990
990
990
The LoopBack example of PulsePosition also works ok if the two pins are connected toegther (10 to 6 in this case) as shown below(I changed the input pin to pin 6 in this case):
Code:
#include <PulsePosition.h>
// Simple loopback test: create 1 output to transmit
// test pulses, and 1 input to receive the pulses
PulsePositionOutput myOut;
PulsePositionInput myIn;
void setup() {
myOut.begin(10); // connect pins 6 and 10 together...
myIn.begin(6);
myOut.write(1, 600.03);
myOut.write(2, 1500);
myOut.write(3, 759.24);
// slots 4 and 5 will default to 1500 us
myOut.write(6, 1234.56);
}
int count=0;
void loop() {
int i, num;
// Every time new data arrives, simply print it
// to the Arduino Serial Monitor.
num = myIn.available();
if (num > 0) {
count = count + 1;
Serial.print(count);
Serial.print(" : ");
for (i=1; i <= num; i++) {
float val = myIn.read(i);
Serial.print(val);
Serial.print(" ");
}
Serial.println();
}
}
Output:
Code:
1 : 521.12 852.88 251.25 493.80 1450.07 345.50 410.95
2 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
3 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
4 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
5 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
6 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
7 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
8 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
9 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
10 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
11 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
12 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
13 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
14 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
15 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
16 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
17 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
18 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
19 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
20 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
21 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
22 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
23 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
24 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
25 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
26 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
27 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
28 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
29 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
30 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
31 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
32 : 600.02 1500.00 759.23 1500.00 1500.00 1234.55
However, the same code above will not detect any pulse if connected to a RC servo PWM generator. The generator has been tested with many different servos as well as with an Arduino and is working fine. I've tried connecting an RC receiver (verified working) and that does not trigger any signal as well.
This leads me to think that the issue is in software and not hardware, as all hardware seems to be working normally.
Can anyone offer any ideas as to why this behavior?
Last edited: