A complete PPM-Frame has a length of 22.5 ms. It exists of an overlong start information and 8 channel information. A stop information with 0.3 ms follows on every channel impulse. The length of a channel impulse ranges from 0.7 ms to 1.7 ms and corresponds to the stick position. Consequently, the illustration shows a transmitter with full amplitude right in channel 1, channel 2 on full amplitude left, channel 3 on middle,.. the start impulse supplements the 8 channel impulses, so that the total length of 22.5 ms emerges.
/* Sync pulse detection */
if (ppmDev.deltaTime > PPM_IN_MIN_SYNC_PULSE_US) {
if (ppmDev.pulseIndex == ppmDev.numChannelsPrevFrame
&& ppmDev.pulseIndex >= PPM_IN_MIN_NUM_CHANNELS
&& ppmDev.pulseIndex <= PPM_IN_MAX_NUM_CHANNELS) {
/* If we see n simultaneous frames of the same
number of channels we save it as our frame size */
if (ppmDev.stableFramesSeenCount < PPM_STABLE_FRAMES_REQUIRED_COUNT) {
ppmDev.stableFramesSeenCount++;
} else {
ppmDev.numChannels = ppmDev.pulseIndex;
}
} else {
ppmDev.stableFramesSeenCount = 0;
}
/* Check if the last frame was well formed */
if (ppmDev.pulseIndex == ppmDev.numChannels && ppmDev.tracking) {
/* The last frame was well formed */
for (i = 0; i < ppmDev.numChannels; i++) {
captures[i] = ppmDev.captures[i];
}
for (i = ppmDev.numChannels; i < PPM_IN_MAX_NUM_CHANNELS; i++) {
captures[i] = PPM_RCVR_TIMEOUT;
}
ppmFrameCount++;
}
ppmDev.tracking = true;
ppmDev.numChannelsPrevFrame = ppmDev.pulseIndex;
ppmDev.pulseIndex = 0;
/* We rely on the supervisor to set captureValue to invalid
if no valid frame is found otherwise we ride over it */
} else if (ppmDev.tracking) {
/* Valid pulse duration 0.75 to 2.5 ms*/
if (ppmDev.deltaTime > PPM_IN_MIN_CHANNEL_PULSE_US
&& ppmDev.deltaTime < PPM_IN_MAX_CHANNEL_PULSE_US
&& ppmDev.pulseIndex < PPM_IN_MAX_NUM_CHANNELS) {
ppmDev.captures[ppmDev.pulseIndex] = ppmDev.deltaTime;
ppmDev.pulseIndex++;
} else {
/* Not a valid pulse duration */
ppmDev.tracking = false;
for (i = 0; i < PWM_PORTS_OR_PPM_CAPTURE_COUNT; i++) {
ppmDev.captures[i] = PPM_RCVR_TIMEOUT;
}
}
}
コメント