PPM
How PPM Works
CRSF PPM Overview
CRSF information is communicated with frames that consist of PPM pulses that represent channel values and a reset pulse. Below is an example of a frame for 8 channels.
The PPM pulses are unique in that the HIGH time is always the same, but the period changes depending on the channel value.
CRSF PPM Math
N = number of channels
Frame total length = N * 1670us + 3300us
PPM pulse length/period = HIGH time + LOW time.
Channel Value Pulse
HIGH time: 300us
LOW time: 700us + 970us * channel value (0%-100%)
Reset Pulse
HIGH time: 300us
LOW time: frame total length - sum of all channel value pulse lengths
RC Sender Interface
A generic interface for sending RC (Radio Control) signal
/* Set the value of a specific channel (0.0-1.0). Returns 1 if success, 0 if failed. */
virtual uint8_t setChannelValue(uint8_t channel, float value) = 0;
/* Initialize the RC output. */
virtual void init() = 0;
/* A callback that gets called after each RC value is sent. */
virtual void interrupt_callback(TIM_HandleTypeDef* timer) = 0;
PPM Output Driver
The driver for outputting PPM. Implements the RC sender interface.
/* Constructor */
PPMChannelOut(TIM_HandleTypeDef* timer, uint16_t timer_channel, uint8_t num_channels);
/* Implementation of the RcSender Interface. See LOS_D_RcSender.hpp */
uint8_t setChannelValue(uint8_t channel, float value);
/* Implementation of the RcSender Interface. See LOS_D_RcSender.hpp
* After initialization, we will be constantly sending PPM signals.
*/
void init();
/* Implementation of the RcSender Interface. See LOS_D_RcSender.hpp */
void interrupt_callback(TIM_HandleTypeDef* timer);
/* Set the number of channels. Returns 1 if success, 0 if failed. */
uint8_t setNumChannels(uint8_t num_channels);