sebseb7/SbusToPPM — pull request #1 by prattmic (2014-02-07 04:28:39+00:00)
Title: Update S-Bus to PPM conversion logic

First, update the formula used for converting S-Bus values to PPM pulse widths. Based on measurements on a Saleae Logic, the pulse widths of the board PPM output did not match the PWM outputs from a Futaba receiver. So, S-Bus data and PWM pulse widths were captured for various outputs. These data were used to perform a linear regression, creating a new conversion function, with an R^2 error of 0.999.

The S-Bus parsing and regression code can be found along with the raw S-Bus and pulse width data can be found at: https://gist.github.com/prattmic/8857047

Also, the floating point arithmetic performed for the conversion is very slow (>750us, if some of the benchmarks are to be believed, though I didn't measure). Performing these computations while interrupts are disabled delays handling of the PPM timer comparator interrupt. Ultimately, this results in glitches on the PPM output, most notably, doubled pulses once every second or so (I forgot to screencap the waveform, sorry). By performing the computations while interrupts are enabled, this can be avoided.