How do I generate a custom filter for laser lock box with scipy?
Laser Lock Box customer 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:Lab laser lock box implements a 2 cascaded direct form I second-order stages IIR filter. It has a fixed sampling rate at 31.25 MHz. The coefficients can be set by set_custom_filter function in pymoku or MATLAB API, or directly loaded on the iPad with a 6 by 2 (6 columns, 2 rows) array as the following:
s1 | b0.1 | b1.1 | b2.1 | a1.1 | a2.1 |
s2 | b0.2 | b1.2 | b2.2 | a1.2 | a2.2 |
Each ‘a’ coefficient must be a float in the range [-2.0, +2.0). ‘s’ coefficients are multiplied into each ‘b’ coefficient before being sent to the device. These products (sN x b0.N, sN x b1.N, sN x b2.N) must also fall in the range [-2.0, +2.0). Internally, the ‘a’ and ‘b’ coefficients are represented as signed 32-bit fixed-point numbers, with 30 fractional bits.
For example, we can use scipy package to generate the coefficients for a second order butterworth filter like the following. It returns the coefficients array that can be later used in the set_custom_filter function. Please note negative signs are added to all 'a' coefficients for the direct form I filter.
from scipy import signal def gen_butterworth(corner_frequency): """ Generate coefficients for a second order butterworth low-pass filter. Corner frequencies for laser lock box second harmonic filtering should be in the range: 1 kHz < corner frequency < 31.25 MHz. """ sample_rate = 31.25e6 normalised_corner = corner_frequency / (sample_rate / 2) b, a = signal.butter(2, normalised_corner, 'low', analog = False) coefficient_array = [[1.0, b[0], b[1], b[2], -a[1], -a[2]], [1.0, 1.0, 0.0, 0.0, 0.0, 0.0]] return coefficient_array