Python: Digital Filter Box (plotting)
Learn how to use Python's libraries to create a Digital Filter Box and create a visual representation of the filtered signal.
-
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
Example Python script to implement the Digital Filter Box (plotting)
For more Python examples, please refer to this link.
# # Moku example: Plotting Digital Filter Box # # This example demonstrates how you can configure the Digital # Filter Box instrument to filter and display two signals. Filter # 1 takes its input from Input1 and applies a lowpass Butterworth # filter. Filter 2 takes its input 2 and then implements a low sampled # Butterworth lowpass to show the difference from sampling rates. # # (c) 2023 Liquid Instruments Pty. Ltd. # import matplotlib.pyplot as plt from moku import MokuException from moku.instruments import DigitalFilterBox # Launch Digital Filter Box and connect to your device via IP i = DigitalFilterBox('192.168.###.###', force_connect=True) try: # SetChannel 1 and 2 to DC coupled, 1 Mohm impedance, and # default input range (400 mVpp range on Moku:Pro, 1 Vpp # range on Moku:Lab, 10 Vpp range on Moku:Go) i.set_frontend(1, coupling='DC', impedance='1MOhm', attenuation='0dB') i.set_frontend(2, coupling='DC', impedance='1MOhm', attenuation='0dB') # Channel 1 signal: Input 1 # Channel 2 signal: Input 1 + Input 2 i.set_control_matrix(1, input_gain1=1, input_gain2=0) i.set_control_matrix(2, input_gain1=1, input_gain2=1) # Configure Digital Filter on Channel 1 and Channel 2 # Channel 1 and 2 are 8th-order ChebyshevI filters # Channel 1 is the high sampling rate and Channel 2 is the # low sampling rate. i.set_filter(1, "39.06MHz", shape="Lowpass", type="ChebyshevI", low_corner=1e3, order=8) i.set_filter(2, "4.883MHz", shape="Lowpass", type="ChebyshevI", low_corner=1e3, order=8) # Monitor ProbeA: Filter Channel1 output # Monitor ProbeB: Filter Channel2 output i.set_monitor(1, "Output1") i.set_monitor(2, "Output2") # Enable Digital Filter Box output ports i.enable_output(1, signal=True, output=True) i.enable_output(2, signal=True, output=True) # View +/- 1 microsecond with the trigger point centered i.set_timebase(-1e-3, 1e-3) # Get initial data frame to set up plotting parameters. data = i.get_data() # Set up the plotting parameters plt.ion() plt.show() plt.grid(True, which='both', axis='both') plt.ylim([-1, 1]) plt.xlim([data['time'][0], data['time'][-1]]) line1, = plt.plot([]) line2, = plt.plot([]) # Configure labels for axes ax = plt.gca() # This loops continuously updates the plot with new data while True: # Get new data data = i.get_data() # Update the plot line1.set_ydata(data['ch1']) line2.set_ydata(data['ch2']) line1.set_xdata(data['time']) line2.set_xdata(data['time']) plt.pause(0.001) except MokuException as e: print("Couldn't configure Moku. Please check your IP address and that you've updated the script parameters (such as sampling rate) to match your device.") raise e finally: # Releasing ownership of the Moku allows other users to connect # to it without forcing a takeover. i.relinquish_ownership()