US English (US)
JP Japanese
CN Chinese
KR Korean

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Knowledge Base Home
  • Contact Us
English (US)
US English (US)
JP Japanese
CN Chinese
KR Korean
  • Home
  • Moku:Go
  • Moku:Go Frequency Response Analyzer

Measuring impedance with Moku:Go (part 1)

Measuring resistance with Moku:go and Python

Written by Paul Cracknell

Updated at December 21st, 2023

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • 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
+ More

These two Python scripts accompany the application note “Measuring Impedance with Moku:Go, part 1, resistance”.

 

One port method

# moku example: Single-Port Impedance Test
#
# This example demonstrates how you can take an impedance of a device under
# test using the single-port method
#

# Initializing the Instrument and Functions
from moku.instruments import FrequencyResponseAnalyzer
import numpy as np
import math

# Connect to your Moku by its ip address using FrequencyResponseAnalyzer('192.168.###.###')
# or by its serial number using FrequencyResponseAnalyzer(serial=123)
i = FrequencyResponseAnalyzer('192.168.73.1', force_connect=True)

try:
    
   # Configure Input Parameters
    i.set_output(1, 1)
    i.measurement_mode('In')
    
    # For Moku:Go
    i.set_frontend(1, "50Ohm", "DC", "10Vpp")
    
    # For Moku:Lab and Moku:Pro 
    #i.set_frontend(1, "50Ohm", "DC", "4Vpp")
    
    
     # Configure output sweep parameters
    i.set_sweep(start_frequency=6e4, stop_frequency=100, num_points=256,
                averaging_time=1e-6, settling_time=1e-6, averaging_cycles=1, settling_cycles=1)
    
    # Check the parameters of the FRA 
    print(i.summary())

    # Start the sweep 
    i.start_sweep(single=True)

    # Get a single sweep frame. This will block until the sweep is complete,
    # beware if you include low frequencies there will be a longer
    # measurement time for the frame
    
    frame = i.get_data()

    # Known  
    # Input Impedance for the Moku:Lab and Moku:Pro
    # For Moku:Go, this is the parallel resistance with a 50 ohm 
    # terminator resistor in parallel with the input
    Z_in = 50 #ohms 
    
    # Amplitude of the Output Voltage from the FRA
    V_out = 1 #Vpp
    
    
    # Output Impedance of the Moku
    # Make sure the correct one is put into your equation below
    Z_out_Go = 200 #ohms
    Z_out_Pro_Lab = 50 #ohms
    
    
    
    #Taking needed Power Measurement
    frequency = frame['ch1']['frequency']
    magnitude = frame['ch1']['magnitude']
    
    
    
    
    # Check Outputs
    #print(frame['ch1']['magnitude'])
    #print(frame['ch1']['frequency'])

    
    # Pull the Power Measurement at the Frequency of 300 Hz
    index_300hz = np.argmin(np.abs(np.array(frequency) - 300))
    dBm = magnitude[index_300hz]
    

    # Assuming Moku is expressing the dBm
    V_in = math.sqrt(8 * Z_in * ((10 ** (dBm / 10)) / 1000))

    print(f"The magnitude at 300 Hz is {dBm:.2f} dBm, which corresponds to {V_in:.4f} V.")
    
    
    # Calculate Z_DUT
    # Make sure the correct Z_out is being used
    Z_dut = ((V_out * Z_in) / V_in) - (Z_in + Z_out_Go)
    print(f"The impedance of the device under test is: {Z_dut:.2f} Ohms")
    
except Exception as e:
    print(f'Exception occurred: {e}')
finally:
    # Close the connection to the Moku device
    # This ensures network resources and released correctly
    i.relinquish_ownership()

 

Two port method

# moku example: Two-Port Impedance Test
#
# This example demonstrates how you can take an impedance of a device under
# test using the two-port method
#

#
from moku.instruments import FrequencyResponseAnalyzer
import numpy as np
import math

# Connect to your Moku by its ip address using FrequencyResponseAnalyzer('192.168.###.###')
# or by its serial number using FrequencyResponseAnalyzer(serial=123)
i = FrequencyResponseAnalyzer('192.168.73.1', force_connect=True)

try:

    # Configure output sweep amplitudes
    # Channel 1 - 1Vpp
    i.set_output(1, 1)

    # Configure output sweep parameters

    i.measurement_mode('In')
    i.set_sweep(start_frequency=10e4, stop_frequency=100, num_points=256,
                averaging_time=1e-6, averaging_cycles=1, settling_cycles=1,
                settling_time=1e-6)
    
    
     # For Moku:Go
    i.set_frontend(1, "50Ohm", "DC", "10Vpp")
    
    # For Moku:Lab and Moku:Pro 
    #i.set_frontend(1, "50Ohm", "DC", "4Vpp")

    
    # Start the single sweep
    i.start_sweep(single=True)

    # Get a single sweep frame. This will block until the sweep is complete,
    # beware if your range includes low frequencies!
    frame = i.get_data()
    

    # Known 
    # Note that Z_in will vary for Moku:Go based on the parallel resistance
    Z_in= 50 #ohms
    V_out = 1 #Vpp
    

    # Check the parameters of the FRA 
    print(i.summary())
    
    
    # Taking Power Measurement at 300 Hz from Input 1 and Input 2
    frequency_1 = frame['ch1']['frequency']
    magnitude_1 = frame['ch1']['magnitude']
    index_1_300hz = np.argmin(np.abs(np.array(frequency_1) - 300))
    magnitude_300hz_ch1 = magnitude_1[index_1_300hz]
    
    frequency_2 = frame['ch2']['frequency']
    magnitude_2 = frame['ch2']['magnitude']
    index_2_300hz = np.argmin(np.abs(np.array(frequency_2) - 300))
    magnitude_300hz_ch2 = magnitude_2[index_2_300hz]

    
    # Print the corresponding magnitude values at the desired frequency
    print(f"The magnitude of channel 1 at 300 Hz is: {magnitude_300hz_ch1:.4f} dBm")
    print (f"The magnitude of channel 2 at 300 Hz is: {magnitude_300hz_ch2:.4f} dBm")
    
    # Convert magnitudes from dBm to linear scale
    linear_magnitude_1 = 10 ** (magnitude_300hz_ch1 / 10)
    linear_magnitude_2 = 10 ** (magnitude_300hz_ch2/ 10)

    # Take the ratio of Channel 2 to Channel 1 
    linear_result = linear_magnitude_2 / linear_magnitude_1

    # Convert linear result back to dBm
    result_dB = 10 * np.log10(linear_result)


    # Print result (Ch2/Ch1)
    print(f"Channel 2 divided by Channel 1 results in: {result_dB:.4f} dBm")

    
    # Use the power ratio to calculate the impedance of your device under test 
    x = 10**(result_dB/10)
    power_ratio= np.sqrt(x)
    Z_dut = (power_ratio*Z_in)-Z_in
    print(f"The impedance of the device under test is: {Z_dut:.2f} Ohms")
    

except Exception as e:
    print(f'Exception occurred: {e}')
finally:
    # Close the connection to the Moku device
    # This ensures network resources and released correctly
    i.relinquish_ownership()
    
mokugo impedance measure python

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How can I plot the ratio of input 1 and input 2 using the Moku Frequency Response Analyzer?
  • How do I export measured data from my Moku?

Sitemap

  • Moku:Lab
  • Instruments
  • Software
  • Company
  • Support
  • Store
  • Terms & Conditions
  • Privacy Policy

Offices

United States
+1 (619) 332-6230
12526 High Bluff Dr
Suite 150
San Diego, CA 92130

Australia
+61 2 6171 9730
243 Northbourne Avenue
Suite 2
Lyneham, ACT 2602

Australia
+61 03 7073 3594
700 Swanston Street
Suite 5E, Level 5
Carlton, VIC 3053

Follow us

Youtube LinkedIn

官方微信

Contact us
© 2025 Liquid Instruments. All rights reserved.

Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand