How to change the phase of the demodulation signal in Moku Lock-In Amplifier
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 Pymoku by adjusting the demodulation signal properties.
This example demonstrates how the demodulation signal 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) 2023 Liquid Instruments Pty. Ltd. # from moku.instruments import LockInAmp import statistics import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter # Launch Lock In Amplifier and connect to your device via IP # Locks to external reference 10 MHz clock i = LockInAmp('192.168.###.###', force_connect=True, set_default=True, use_external=True) try: # Output a 1MHz sine wave but demodulate at a harmonic (2MHz) i.set_demodulation(mode='Internal', frequency=1e6) i.set_filter(corner_frequency=1e6, slope="Slope6dB") # Output the 'X' (I) signal and the local-oscillator sine wave on the two # DAC channels. Configure a PID controller on the main 'X' output with # a proportional gain of 10x, integrator cross-over of 10Hz and integrator # saturation at 100x i.set_outputs(main='X', aux='None', main_offset=0, aux_offset=0) i.set_by_frequency(prop_gain=10, int_crossover=10, int_saturation=10) i.use_pid("Main") # 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' ('Q' 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) # Get initial data frame to set up plotting parameters. This can be done # once if we know that the axes aren't going to change (otherwise we'd do # this in the loop) data = i.get_data() dt = data['time'] # Set up the plotting parameters plt.ion() plt.show() plt.grid() line1, = plt.plot([]) line2, = plt.plot([]) line1.set_xdata(dt) line2.set_xdata(dt) # 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.phase_demod = a # get a frame of data data = i.get_data() dc2 = data['ch2'] # Print out the demodulation phase and mean value of the output print(f'New Phase: {i.phase_demod}') print(f'Mean: {statistics.mean(dc2)}') # Update the Plotting line1.set_ydata(data['ch1']) line2.set_ydata(data['ch2']) plt.pause(1) # 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()