PyQa40x: PyQa40x_freq_response_with_mask.py

The PyQa40x repo was updated with a new example called PyQa40x_freq_response_with_mask.py

This example will perform an expo chirp. The left channel output will connect to the DUT input, the left channel input will be the DUT output, and the right channel input is the reference (connected directly to the right channel output). This allows both frequency and phase of the DUT to be measured. The example also include the ability to specify a mask for both frequency and phase.

The resulting output is shown below. In the first row, you can see the expo chirp output of the left and right channels. In the second row, you can see the inputs to the left and right channels. The left channel amplitude decreases after the 20,000th sample or so because a low-pass filter is being measured. Because the right channel is the reference, there’s no change to the magnitude.

The third row shows the impulse response for both channels, and the associated frequency response of the IR in the 4th row. Note that the right channel is effectively in loopback, and thus you see a bit of ringing at low frequencies and rapid rolloff at high frequencies due to the anit-alias filter in the DAC and ADC.

The fifth row computes the relative magnitude and phase. Here, we have almost no artifacts at low frequencies are high frequencies, because the measurement is being compared to the reference which effectively erases any ringing and ADC/DAC rolloff.

And because it’s a low pass filter we’re testing, the frequency and phase perform as expected. The masks shown are “hand rolled” and thus not tracking the actual response very well. But you can adjust the text file as needed to the get response you desire. The mask_freq.txt file is below. This says “at 20 Hz, we want an upper mask limit of 1 dB, and lower mask limit of -1 dB.

20     1   -1
50     1   -1
100    1   -1
200    1   -1
500    0   -2
1000  -2   -4
2000  -5   -7
5000 -10  -12
10000 -15 -17
20000 -19 -21

It’s similar for phase, but the units are degrees: In the mask_phase.txt shown below, this says we want an upper limit of 5 degrees at 20 Hz, and a lower limit of -5 degrees.

20     5   -5
50     0  -10
100   -5  -15
200  -15  -25
500  -30  -40
1000 -40  -50
2000 -55  -65
5000 -65  -75
10000 -70 -80
20000 -75 -85

1 Like