Python: Phasemeter (plotting)
-
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 Phasemeter (plotting)
For more Python examples, please refer to this link.
#
# Moku example: Plotting Phasemeter
#
# This example demonstrates how you can configure the Phasemeter instrument
# and collect live samples from it's output.
# The signal amplitude is calculated using these samples, and plotted for
# real-time viewing.
#
# (c) 2023 Liquid Instruments Pty. Ltd.
#
from moku.instruments import Phasemeter
import matplotlib.pyplot as plt
import time
# Launch Phasemeter and connect to your device via IP
i = Phasemeter('192.168.###.###', force_connect=True)
try:
# Set samplerate to 37 Hz/s
i.set_acquisition_speed(speed='37Hz')
# Set Channel 1 and 2 to DC coupled, 1 MOhm impedance, and 4Vpp range
i.set_frontend(1, coupling='DC', impedance='1MOhm', range='4Vpp')
i.set_frontend(2, coupling='DC', impedance='1MOhm', range='4Vpp')
# Configure output channel 1 to generate sine waves at 0.5Vpp, 5 MHz
i.generate_output(1, 'Sine', amplitude=0.5, frequency=5e6)
# Configure output channel 2 to generate sine waves at 1Vpp, 10 MHz
i.generate_output(1, 'Sine', amplitude=1, frequency=10e6)
# Get auto acquired frequency for channel 1 and 2
i.get_auto_acquired_frequency(channel=1)
i.get_auto_acquired_frequency(channel=2)
# Get initial data frame to set plot bounds
data = i.get_data()
# Set plot bounds
plt.ion()
plt.show()
plt.grid(True)
line1, = plt.plot([])
line2, = plt.plot([])
xdata1 = []
xdata2 = []
ydata1 = []
ydata2 = []
# Configure labels for axes
ax = plt.gca()
plt.legend(['Ch1', 'Ch2'])
plt.xlabel('Time [s]')
plt.ylabel('Frequency [Hz]')
# This loop continuously updates the plot with new data
start = time.time()
while True:
# Get new data
data = i.get_data()
# Update the plot
ydata1 += [data['ch1']['frequency']]
ydata2 += [data['ch2']['frequency']]
line1.set_ydata(ydata1)
line2.set_ydata(ydata2)
end = time.time()
xdata1.append( end - start)
xdata2.append( end - start)
line1.set_xdata(xdata1)
line2.set_xdata(xdata2)
ax.relim()
ax.autoscale_view()
plt.pause(0.001)
plt.draw()
except Exception as e:
print(f'Exception Occured: {e}')
finally:
# Close the connection to the Moku device
# This ensures network resources are released correctly
i.relinquish_ownership()