ESP32 support ?
I'm trying to use your PPM-Reader with an Adafruit ESP32 Huzzah Feather and I'm not able to get anything but zeros for all 6 channels. I'm using a Radiolink T8S transmitter and an R8EF receiver. The two are correctly paired and I can drive a servo correctly from the transmitter receiver pair . The R8EF is in PPM /SBUS mode and I believe I have the right pins to be getting PPM. I'm using the code from your example only modified to point at a different pin. I suspect this has to do with needing to set up the HW interrupts on that pin i'm usoing. In ESP32 any GPIO can have a HW interrupt.. but I only know how to set them up with a unuqe ISR. Have you gotten this to work with ESP32. ? An earlier posted issue seems to indicate it used to work. Any help MUCH appreciated. Thank you for creating this !
John Cohn [email protected]
/* This example outputs values from all PPM channels to Serial in a format compatible with Arduino IDE Serial Plotter */
#include <PPMReader.h>
// Initialize a PPMReader on digital pin 3 with 6 expected channels. byte interruptPin = 13; // original example used pin 3 byte channelAmount = 6; PPMReader ppm(interruptPin, channelAmount);
void setup() { Serial.begin(115200); }
void loop() { // Print latest valid values from all channels for (byte channel = 1; channel <= channelAmount; ++channel) { unsigned value = ppm.latestValidChannelValue(channel, 0); Serial.print(value); if(channel < channelAmount) Serial.print('\t'); } Serial.println(); delay(20); }
I found a fix for this; try the code on my fork at the following commit of the esp32-integration branch : https://github.com/grybouilli/PPM-reader/tree/019b7f09d8dc18e6d796040e763b2d948be0e0ee
Explantion It seems that interrupts have to be attached during the setup phase on ESP32 (and maybe more boards...). So to fix the problem on ESP32 boards (and maybe others):
- Declare both
static PPMReader *ppmandstatic void PPM_ISR(void)as public members of thePPMReaderclass ; - Write a public
void begin(void)function that does the following job (previously done in the constructor, those lines should be removed from the constructor):
void PPMReader::begin()
{
if(ppm == NULL) {
ppm = this;
attachInterrupt(digitalPinToInterrupt(interruptPin), PPM_ISR, RISING);
}
}
Here is a working example :
#include <PPMReader.h>
// Initialize a PPMReader on digital pin 3 with 6 expected channels.
byte interruptPin = D3;
byte channelAmount = 8;
PPMReader ppm(interruptPin, channelAmount);
void setup() {
Serial.begin(9600);
ppm.begin(); // <---- this is new
}
void loop() {
// Print latest valid values from all channels
for (byte channel = 1; channel <= channelAmount; ++channel) {
unsigned value = ppm.rawChannelValue(channel);
Serial.print(value);
if(channel < channelAmount) Serial.print('\t');
}
Serial.println();
delay(200);
}
I will try this on traditionnal AVR boards : if it does work, I will make a pull request