@rangerr,
Is this what you were aiming for?
I added a second low going 300µs 'Stop pulse' to show that the Channel pulse has ended.
I split the 'Rest of frame' into two parts, each less than 16383µs.
Here is the revised code:
#define PPM_PIN 9
#define CHANNEL_VALUE 1900 // in microseconds (can change this value)
#define FRAME_LENGTH 22500 // in microseconds (22.5 ms for one frame)
#define PULSE_LENGTH 300 // in microseconds (spacing between channels)
void setup() {
pinMode(PPM_PIN, OUTPUT);
digitalWrite(PPM_PIN, HIGH); // idle state HIGH
}
void loop() {
// Start frame sync pulse (Low)
digitalWrite(PPM_PIN, LOW);
delayMicroseconds(PULSE_LENGTH); // Sync pulse length
// Channel value: High pulse for the actual signal (variable length)
digitalWrite(PPM_PIN, HIGH);
delayMicroseconds(CHANNEL_VALUE - PULSE_LENGTH); // pulse for channel
digitalWrite(PPM_PIN, LOW); // Added: Stop pulse ends Channel signal
delayMicroseconds(PULSE_LENGTH);
digitalWrite(PPM_PIN, HIGH);
// Rest of frame time (idle between channels) Now split into two - Each less than 16383µs
delayMicroseconds(10000);
delayMicroseconds(FRAME_LENGTH - CHANNEL_VALUE - PULSE_LENGTH - 10000); // Fill the rest of frame
// Repeat the process
}
