PWM or PPM to SBUS or UART converter implemented on STM32F103C (BluePill).
- The algorithm is designed with the lowest possible latency and supports parallel edges. It means that the parser still gives accurate results when there are more rising/falling edges present at the same time.
- Each rising or falling edge on any PPM or PWM inputs generates the same interrupt. This interrupt scans all the microcontroller pins and saves their digital value with the current timestamp into the queue. The main loop processes the queue and updates the PPM and the PWM values.
- Each parsed value appears in the output data immediately when the corresponding item is withdrawn from the queue and processed.
- The current version prints the parsed values via UART using Arduino
Serial
API. The SBUS is not generated by default, it must be enabled by modifying thevoid printChannels()
function in main.cpp:72.
This project is designed with PlatformIO IDE in VS Code. The functionality is tested on STM32F103C8 (BluePill).
The program supports one PPM channel and several PWM channels. The default configuration uses 12 PWM channels.
You can define your wiring by modification of lines 5 -- 9 of the main.cpp file.
#define PPM_PIN PB5
#define NUM_PPM_CHANNELS 15
const uint8_t NUM_PWM_CHANNELS = 12;
const uint8_t pwmChannels[NUM_PWM_CHANNELS] = {PB12, PB13, PB14, PB15, PA0, PB8, PA6, PB1, PA7, PA4, PA2, PA3};
- The
PPM_PIN
constant defines where is the source PPM signal connected. - The
NUM_PPM_CHANNELS
constant defines how many channels are present in the provided PPM signal. - The
NUM_PWM_CHANNELS
constant defines how many wires with PWM signal are connected to the microcontroller. - The
pwmChannels[NUM_PWM_CHANNELS]
array defines where are the PWM wires connected. The output contains the parsed PWM values in the same order as in this array.
Then, you can modify the void printChannels()
function in main.cpp:72 to send the parsed data in your preferred output format.