How do I generate a custom filter for Moku Laser Lock Box with SciPy?
Laser Lock Box custom filter
-
Moku:Go
Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier Moku:Go General Moku:Go Logic Analyzer/Pattern Generator Moku:Go Time & Frequency Analyzer Moku:Go Laser Lock Box Moku:Go Phasemeter
-
Moku:Lab
Moku:Lab General Moku:Lab Arbitrary Waveform Generator Moku:Lab Data Logger Moku:Lab Digital Filter Box Moku:Lab FIR Filter Builder Moku:Lab Frequency Response Analyzer Moku:Lab Laser Lock Box Moku:Lab Lock-in Amplifier Moku:Lab Oscilloscope Moku:Lab Phasemeter Moku:Lab PID Controller Moku:Lab Spectrum Analyzer Moku:Lab Waveform Generator Moku:Lab Time & Frequency Analyzer Moku:Lab Logic Analyzer/Pattern Generator
-
Moku:Pro
Moku:Pro Arbitrary Waveform Generator Moku:Pro Data Logger Moku:Pro Frequency Response Analyzer Moku:Pro Oscilloscope Moku:Pro PID Controller Moku:Pro Spectrum Analyzer Moku:Pro Waveform Generator Moku:Pro Lock-in Amplifier Moku:Pro Digital Filter Box Moku:Pro FIR Filter Builder Moku:Pro Phasemeter Moku:Pro Multi-instrument Mode Moku:Pro General Moku:Pro Logic Analyzer/Pattern Generator Moku:Pro Time & Frequency Analyzer
- Python API
- MATLAB API
- Arbitrary Waveform Generator
- Data Logger
- Digital Filter Box
- FIR Filter Builder
- Frequency Response Analyzer
- Laser Lock Box
- Lock-in Amplifier
- Oscilloscope
- Phasemeter
- PID Controller
- Spectrum Analyzer
- Time & Frequency Analyzer
- Waveform Generator
- Logic Analyzer & Pattern Generator
- Multi Instrument Mode
- Moku Cloud Compile
- Moku general
- LabVIEW
Moku Laser Lock Box implements a filter upstream of the setpoint and before the signal is split into fast and slow paths. In addition to lowpass and bandstop shapes, it is possible to realise a custom filter with user-provided coefficients.
The custom IIR filter is implemented as four cascaded, direct-form I, second-order sections, with a final output gain stage. The total transfer function is given by:
To specify a filter, you must supply a text file containing the filter coefficients. The file should have six coefficients per line, with each line representing a single stage. If output scaling is required, this should be given on the first line:
g (optional) | 7.8357416 | |||||
Stage 1 | 1.0000000 | 0.0044157 | 0.0088314 | 0.0044157 | -1.669291 | 0.969226 |
Stage 2 | 1.0000000 | 0.0472217 | 0.0944434 | 0.0472217 | -1.898858 | 0.9341904 |
Stage 3 | 1.0000000 | 0.0375275 | 0.0750551 | 0.0375275 | -1.9259771 | 0.9311308 |
⋮ |
s | bo | b1 | b2 | a1 | a2 |
Entries should be comma-separated, e.g.
7.8357416974, 1.0000000000, 0.0044157, 0.0088314, 0.0044157, -1.669291, 0.969226, 1.0000000000, 0.0472217, 0.0944434, 0.0472217, -1.898858, 0.9341904, 1.0000000000, 0.0375275, 0.0750551, 0.0375275, -1.9259771, 0.9311308,
Each coefficient must be in the range [-4.0, +4.0). Internally, these are represented as signed 48-bit fixed-point numbers, with 45 fractional bits. The output scaling can be up to 8,000,000.
The filter sample rate depends on the device in use:
Moku Pro - 78.125 MHz
Moku Lab - 31.25 MHz
Moku Go - 7.8125 MHz
Filter coefficients can be computed using signal processing toolboxes. For example, we can use the scipy package to generate the coefficients for a second-order Butterworth filter for Moku Lab as follows:
from scipy import signal
import numpy def gen_butterworth(corner_frequency): """ Generate coefficients for a second order butterworth low-pass filter. Corner frequencies should be in the range: 1 kHz < corner frequency < 31.25 MHz for Moku Lab. """ sample_rate = 31.25e6 b, a = signal.butter(2, corner_frequency, 'low', analog = False, fs = sample_rate) coeffs = [[1.0, b[0], b[1], b[2], a[1], a[2]]] numpy.savetxt("coeffs.txt", coeffs, delimiter=",")
Filter coefficients may also be set using API calls, see set_custom_filter.