How to change the phase of the demodulation signal in Moku Lock-In Amplifier
Learn how to adjust the phase of the demodulation signal in a Moku Lock-In Amplifier to optimize signal processing and achieve more accurate measurements.
- 
                        Moku:Go
                        
                        
                            Moku:Go General Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Digital Filter Box Moku:Go FIR Filter Builder 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 Lock-in Amplifier 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 Time & Frequency Analyzer Moku:Lab Waveform Generator Moku:Lab Logic Analyzer/Pattern Generator
- 
                        Moku:Pro
                        
                        
                            Moku:Pro General 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 Laser Lock Box Moku:Pro Digital Filter Box Moku:Pro FIR Filter Builder Moku:Pro Phasemeter Moku:Pro Multi-instrument Mode 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
- mokucli
Moku Lock-In Amplifier uses dual-phase demodulation to determine the X and Y components of a signal. The phase of the demodulation signal can be shifted in Python by adjusting the demodulation signal properties.
This example demonstrates how the demodulation signal phase can be adjusted.
#
# Moku example: Phase change in Moku Lock-In Amplifier
#
# This example demonstrates how you can shift the phase of the demodulation signal
# in the Lock-In Amplifier instrument
#
# (c) 2024 Liquid Instruments Pty. Ltd.
#
# This is configured for Moku:Lab and is compatible with Moku:Go and Moku:Pro
#
# Setup : loopback Moku output 2 to input 1 with a BNC cable.
#
# The phase of the demodulation signal is then swept
# a full 360 degrees and the resulting LIA output DC signal 
# reflects the phase offset between the PLL and input 1.
#
from moku.instruments import LockInAmp
import statistics
import matplotlib.pyplot as plt
# Launch Lock In Amplifier and connect to your device via IP
i = LockInAmp('192.168.2.74', force_connect=True)
try:
   # Configure analog input port 1 as 50 Ohm and 0 dB attenuation
   i.set_frontend(1, coupling='DC', impedance='50Ohm', attenuation='0dB')   
   # Output a 1MHz sine wave and demodulate at same
   i.set_demodulation(mode='Internal', frequency=1e6)
   i.set_filter(corner_frequency=1e1, slope="Slope6dB")
   # Output the 'X' (I) signal and the local-oscillator sine wave on the two
   # DAC channels. 
   i.set_aux_output(frequency=1e6, amplitude=1)
   i.set_outputs(main='X', aux='Aux', main_offset=0, aux_offset=0)
   
   i.use_pid("Off")
   i.set_gain(main=0, aux=0)
   # Monitor the I and Q signals from the mixer, before filtering
   i.set_monitor(1, 'Input1')
   i.set_monitor(2, 'MainOutput')
   # Trigger on Monitor 'B' ('I' signal), rising edge, 0V with 0.1V hysteresis
   i.set_trigger(source='ProbeB', edge='Rising', hysteresis=0.1)
   # View +- 0.1 second, i.e. trigger in the centre
   i.set_timebase(-2e-6, 2e-6)
   
   # Set up the plotting parameters
   plt.figure(num="Moku Lock-in Amplifier")
   plt.ylabel("Voltage (V)")
   plt.xlabel("Time [s]")
   line1, = plt.plot([], label='Input 1')
   line2, = plt.plot([], label='LIA X out')
   # Configure labels for axes
   ax = plt.gca()
   plt.pause(1)
   # This loops through a phase range of 0 to 350 degrees with a step size of 10
   for a in range(0, 351, 10):
       # Set a demodulation phase
       i.set_demodulation(mode='Internal', phase=a)
       data = i.get_data(wait_complete=True, wait_reacquire=True)
       dc2 = data['ch2']
       # Print out the demodulation phase and mean value of the output
       print(f'New Phase: {a}')
       print(f'Mean: {statistics.mean(dc2)}')
       # Update the Plotting
       line1.set_ydata(data['ch1'])
       line1.set_xdata(data['time'])
       
       line2.set_ydata(data['ch2'])
       line2.set_xdata(data['time'])
       
       plt.pause(0.1)
       plt.legend(loc='upper left')
       # Ensure frequency axis is a tight fit
       ax.relim()
       ax.autoscale_view()
finally:
   # Close the connection to the Moku device
   # This ensures network resources and released correctly
   i.relinquish_ownership()
