# Calculating Filter Coefficients to Store in a Microcontroller

Recently there have been some email support requests regarding the calculation of filter coefficients (and other types of parameters) for storage in a microcontroller. The basic idea is to store a table of parameters in the microcontroller and download them to the appropriate addresses in the SigmaDSP's parameter RAM when required. SigmaStudio includes a few tools to help make this possible.

Method 1: Direct coefficient calculation

This method is not really preferred because it takes time and effort compared to the other methods, and doesn't offer any real benefits. In the help file, equations used for calculating first-order and second-order (biquad) IIR filter coefficients are given. For example, for a butterworth LPF:

f5899e3887795e22a95f55bbb5e2fcc4.bin

These equations can be used to calculate parameters directly, but are a bit cumbersome.

Method 2: Fixed Point Filter Table Generator

Open the fixed point filter table generator under the Tools menu.

73b8f6de58b636c4c577e7994f1933d2.bin

Here you can enter in parameters for a number of filter curves that you desire, then hit the generate button to see the generated curves on the graph.

cd95a479e83f16b01ff55ca345162193.bin

Click the value table tab to see the biquad filter coefficients to be stored in RAM (5 coefficients are listed for each filter generated).

18988d4505aa79c9e8e8e5229ef2f878.bin

Click the Show Values button and then Generate again to show the decimal values and parameter names for each filter, along with the associated boost.

7bb958fc42bdd03e7d484ace545c3543.bin

These values can be loaded directly into a 2nd-order general filter, set to IIR Coefficient mode in SigmaStudio. Important: Because of the way the values are stored in RAM, the coefficients for a1 and a2 must be inverted from what is shown in the filter table generator. The filter table generator shows coefficients as they are stored in RAM, whereas the IIR Coefficient filter box shows their true values as calculated by the equations.

72353e7659761d0208d5f326169fd2de.bin

The filter table generator allows a large number of coefficients to be calculated and stored in RAM for applications such as a user-controllable tone control.

Method 3:Use the capture window

Start a project and make sure the SigmaDSP is connected to a USBi communication channel in the Hardware Configuration tab. Insert any filter into your project and compile. Then change the filter values. The values written to the SigmaDSP's RAM are shown in the capture window (open by default, toggle by pressing Ctrl+5).