Calculations of components of the filter that shapes sine wave signals from square wave signal generated by microcontroller. The calculations are made using wxMaxima.
Nominal transmitance is calculated using formula for selected topology of the active filter. The transmitance is product of the sallen-key filter and following RC filter.

Initial values of components comes from on-line calculator and simulations. Maximum of the transmitance is calculated - it must be below nominal sine wave frequency because the test frequency should be placed on the steep part of the transmitance. Gain at nominal test wave frequency is about 1.5.

Next an error is calculated to obtain a value of calibrating resistor. Two kinds of errors are calculated - maximum and root sum squared.

Using the calculated error and nominal gain values the adjusting resistor is calculated. This is an approximation (slope of the filter characteristics as linear function). Calibrating resistors min and max values are calculated using the gain value increased or decreased by the error. Then additionally minimum and maximum gain with minimum and maximum values of the resistor is calculated.

Finally the input resistor of the sallen-key filter is divided into 4 resistors network that translates logic levels from microcontroller to appropriate signal. Following requirements must be fulfilled: thevenin equivalent must be unchanged to preserve transfer function; first harmonic of the input square multiplied by filter gain must give the target output signal level (2Vpp); amplifier inputs must be biased about 1/2VDD to not overdrive them.

The first plan was to consider higher error for low capacitance connected to input of op-amp (which adds some pF). Next 1% capacitors were added to schematic instead. Finally the calculations didn't work for 100kHz - adjustable resistance had to be decreased to achieve enough gain (faster op-amp may be needed to achieve filter complying the calculations results).
