Post by aquin43 on Jan 18, 2019 13:30:24 GMT -5
Digital Impedance Measurement
I had been using an Audio Precision test set for pickup measurements but it failed recently and is expensive to repair. Inspired by the example of MS, I decided to try making the measurements with a computer audio interface, in this case a Focusrite Scarlett 2i2.
The measurement method remains essentially as before. The pickup is driven by a current from a large resistor and the voltage across it is measured. The measured voltage is converted to an impedance with phase and is then corrected for the parallel loading of the feed resistor and the test set input capacitance.
I already had the necessary buffer preamp for the reading so all that was needed was a 10X gain amplifier to drive the feed resistor. Half a TL072 and two resistors made the amplifier, helped by the Scarlett 2i2 having electronically balanced outputs so an inverted signal is also available.
A search on the internet came up with cs.uwaterloo.ca/~mannr/ (bottom of the page -publications), where links to a suite of open source software that uses the Octave maths programming language can be found. This has programs for generating the test signals and making measurements. One of these programs, 'SoundCardSetup', has a simple graphical user interface and was easily modified and adapted to the task of measuring pickups.
The Scarlett 2i2 being intended for audio, its amplitude response is specified flat to 0.1dB up to 20kHz. Its actual response is much better than this, except at the highest preamp gains. With a sampling frequency of 96kHz it is theoretically possible to measure out to 48kHz but 40kHz was chosen as a sensible limit.
The system is set up so that one of the stereo output channels drives the pickup while the other is looped back to its corresponding input. The two channel input gains are kept equal. This is important, because the measurement is made as a ratio between the two channels in the hope that any gain and phase variations will be the same in both and so will cancel. A low value (2k) trim-pot wired at the reference channel input allows this matching.
The waveform used for the measurement is a maximum length pseudo random sequence (MLS). The idea is that although the sequence consists of switching between only two digital levels, it contains an equal distribution of all the frequencies up to half the sample rate. The pickup is driven by two and a half of these sequences placed end to end and a chunk of the response exactly one sequence long is extracted for the measurement. This gives time for the ringing of a high Q pickup to die down before the measurement is made. The use of the exact number of samples from the repeated sequence is effectively the same as sampling a repetitive waveform. This ensures that all of the frequency components of the sequence are properly aligned so that each frequency will appear entirely at one location in the subsequent Fourier transform. This means that the computed gain and phase will be correct at each frequency.
The measurement and reference waveforms are converted to frequencies and real and imaginary responses by fast Fourier transform, which Octave does natively. The ratio of the transformed signals is the measurement, which is then converted to a 'gain' and phase.
Phase is always a problem in audio measurements because any variation in frequency response produces a phase change long before the gain change becomes a problem. The drive amplifier has a bandwidth of 155kHz, so it is already producing 17 degrees of lag at 40 kHz. Fortunately, the roll off has a simple single pole low pass characteristic so it is easy to compute the necessary correction and add it back into the measurement.
The initial measurements immediately revealed a problem that wasn't visible with the previous stepped frequency measurements. Because the signal now contains all of the frequency spectrum at once, the level at any frequency is much lower for any given drive amplifier output swing. Mains interference with single coil pickups manifested itself. There is a magnetic field at 50Hz with a strong harmonic at 150Hz in my workroom that comes from a buried cable in the street. I had it measured once by the electricity company - 80 micro Tesla. The interference created spikes on the phase and impedance graphs. Fortunately, these are easy to remove with a digital median filter. This is just a mathematical process that steps along the array of measurements taking groups of adjacent measurements and replacing the middle one with the median of the group. This seems to eliminate spikes with no discernable effect on the overall shape of the curve. Its the same trick as is used to remove specks from photographs.
The program cycles repeatedly, making measurements and displaying the results. With a short (32k) sequence loaded, the measurement and calculation cycle repeats about every 2 seconds so it is fairly easy to adjust levels while watching the display.
Calibration is done by replacing the pickup with a 100k resistor and saving a reverse corrected reading as a reference. The reference is also saved to a file that is automatically loaded when the program starts.
The actual output is saved after loading the longest sequence which has a frequency resolution of 0.366Hz. Further filtering is applied to remove noise and the number of points saved is reduced to 200 or 500, averaged from the full array. Because the measured points are so close together it is possible to select according to a log scale, so that the output naturally fits on a log plot, or to a linear scale which better suits high Q pickups. The output file is a text list of coordinates that can easily be imported into any other program.
Octave is available free for Linux, Windows and Mac. It is an interpreted language that operates on vectors and matrices so it can do some powerful numerical computing at speed while not needing to be compiled. It is very similar to Matlab; in fact the two are often considered as practically equivalent.
I am running the program on a Linux laptop but I have also had it running on a Mac.
I had been using an Audio Precision test set for pickup measurements but it failed recently and is expensive to repair. Inspired by the example of MS, I decided to try making the measurements with a computer audio interface, in this case a Focusrite Scarlett 2i2.
The measurement method remains essentially as before. The pickup is driven by a current from a large resistor and the voltage across it is measured. The measured voltage is converted to an impedance with phase and is then corrected for the parallel loading of the feed resistor and the test set input capacitance.
I already had the necessary buffer preamp for the reading so all that was needed was a 10X gain amplifier to drive the feed resistor. Half a TL072 and two resistors made the amplifier, helped by the Scarlett 2i2 having electronically balanced outputs so an inverted signal is also available.
A search on the internet came up with cs.uwaterloo.ca/~mannr/ (bottom of the page -publications), where links to a suite of open source software that uses the Octave maths programming language can be found. This has programs for generating the test signals and making measurements. One of these programs, 'SoundCardSetup', has a simple graphical user interface and was easily modified and adapted to the task of measuring pickups.
The Scarlett 2i2 being intended for audio, its amplitude response is specified flat to 0.1dB up to 20kHz. Its actual response is much better than this, except at the highest preamp gains. With a sampling frequency of 96kHz it is theoretically possible to measure out to 48kHz but 40kHz was chosen as a sensible limit.
The system is set up so that one of the stereo output channels drives the pickup while the other is looped back to its corresponding input. The two channel input gains are kept equal. This is important, because the measurement is made as a ratio between the two channels in the hope that any gain and phase variations will be the same in both and so will cancel. A low value (2k) trim-pot wired at the reference channel input allows this matching.
The waveform used for the measurement is a maximum length pseudo random sequence (MLS). The idea is that although the sequence consists of switching between only two digital levels, it contains an equal distribution of all the frequencies up to half the sample rate. The pickup is driven by two and a half of these sequences placed end to end and a chunk of the response exactly one sequence long is extracted for the measurement. This gives time for the ringing of a high Q pickup to die down before the measurement is made. The use of the exact number of samples from the repeated sequence is effectively the same as sampling a repetitive waveform. This ensures that all of the frequency components of the sequence are properly aligned so that each frequency will appear entirely at one location in the subsequent Fourier transform. This means that the computed gain and phase will be correct at each frequency.
The measurement and reference waveforms are converted to frequencies and real and imaginary responses by fast Fourier transform, which Octave does natively. The ratio of the transformed signals is the measurement, which is then converted to a 'gain' and phase.
Phase is always a problem in audio measurements because any variation in frequency response produces a phase change long before the gain change becomes a problem. The drive amplifier has a bandwidth of 155kHz, so it is already producing 17 degrees of lag at 40 kHz. Fortunately, the roll off has a simple single pole low pass characteristic so it is easy to compute the necessary correction and add it back into the measurement.
The initial measurements immediately revealed a problem that wasn't visible with the previous stepped frequency measurements. Because the signal now contains all of the frequency spectrum at once, the level at any frequency is much lower for any given drive amplifier output swing. Mains interference with single coil pickups manifested itself. There is a magnetic field at 50Hz with a strong harmonic at 150Hz in my workroom that comes from a buried cable in the street. I had it measured once by the electricity company - 80 micro Tesla. The interference created spikes on the phase and impedance graphs. Fortunately, these are easy to remove with a digital median filter. This is just a mathematical process that steps along the array of measurements taking groups of adjacent measurements and replacing the middle one with the median of the group. This seems to eliminate spikes with no discernable effect on the overall shape of the curve. Its the same trick as is used to remove specks from photographs.
The program cycles repeatedly, making measurements and displaying the results. With a short (32k) sequence loaded, the measurement and calculation cycle repeats about every 2 seconds so it is fairly easy to adjust levels while watching the display.
Calibration is done by replacing the pickup with a 100k resistor and saving a reverse corrected reading as a reference. The reference is also saved to a file that is automatically loaded when the program starts.
The actual output is saved after loading the longest sequence which has a frequency resolution of 0.366Hz. Further filtering is applied to remove noise and the number of points saved is reduced to 200 or 500, averaged from the full array. Because the measured points are so close together it is possible to select according to a log scale, so that the output naturally fits on a log plot, or to a linear scale which better suits high Q pickups. The output file is a text list of coordinates that can easily be imported into any other program.
Octave is available free for Linux, Windows and Mac. It is an interpreted language that operates on vectors and matrices so it can do some powerful numerical computing at speed while not needing to be compiled. It is very similar to Matlab; in fact the two are often considered as practically equivalent.
I am running the program on a Linux laptop but I have also had it running on a Mac.
The simple schematic
The program in action on a Linux laptop.
A typical measurement saved as 200 point linear frequency.
Arthur