def connect(args, force=False): if len([x for x in (args.serial, args.name, args.ip) if x]) != 1: print("Please specify exactly one of serial, name or IP address of " "target Moku") exit(1) force = force or args.force if args.serial: moku = Moku.get_by_serial(args.serial, force=force) print(moku.get_name()) elif args.name: moku = Moku.get_by_name(args.name, force=force) else: moku = Moku(args.ip, force=force) return moku
def main(): print("Beginning automated testing sequence") # Connect to the Moku device by name moku = Moku.get_by_name('Moku') try: # Run Phase 1 - Rise Times res1, fails1, criteria1 = phase1(moku) # Run Phase 2 - Line Widths res2, fails2, criteria2 = phase2(moku) generate_results_file(moku, res1, fails1, criteria1, res2, fails2, criteria2) print("Testing complete") finally: moku.close()
from pymoku import Moku, ValueOutOfRangeException from pymoku.instruments import * import time, logging import matplotlib import matplotlib.pyplot as plt logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(message)s') logging.getLogger('pymoku').setLevel(logging.DEBUG) # Use Moku.get_by_serial() or get_by_name() if you don't know the IP m = Moku.get_by_name("Aqua") i = m.discover_instrument() if i is None or i.type != 'signal_generator': print "No or wrong instrument deployed" i = SignalGenerator() m.attach_instrument(i) else: print "Attached to existing Signal Generator" i.set_defaults() i.synth_sinewave(1, 1.0, 1000000) i.synth_squarewave(2, 1.0, 2000000, risetime=0.1, falltime=0.1, duty=0.3) i.commit() try: while True: try:
from scipy import fft import math import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter # Specify nyquist and cutoff (-3dB) frequencies nyq_rate = 125e6 / 2**10 / 2.0 cutoff_hz = 1e3 # Calculate FIR kernel using 1000 taps and a chebyshev window with -60dB # stop-band attenuation taps = firwin(1000, cutoff_hz / nyq_rate, window='hamming') # Connect to your Moku by its device name # Alternatively, use Moku.get_by_serial('#####') or Moku('192.168.###.###') m = Moku.get_by_name('Moku') try: i = m.deploy_or_connect(FIRFilter) # Configure the Moku:Lab frontend settings i.set_frontend(1, fiftyr=True, atten=False, ac=False) i.set_frontend(2, fiftyr=True, atten=False, ac=False) # Both filter channels are configured with the same FIR kernel. A # decimation factor of 10 is used to achieve the desired nyquist rate and # FIR kernel length of 1000. i.set_filter(1, decimation_factor=10, filter_coefficients=taps) i.set_filter(2, decimation_factor=10, filter_coefficients=taps) # Channel 1 has unity input/output gain and acts solely on ADC1.
from pymoku import Moku, MokuException from pymoku.instruments import * import pymoku.plotly_support as pmp import time, logging, traceback logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(message)s') logging.getLogger('pymoku').setLevel(logging.INFO) # Use Moku.get_by_serial() or get_by_name() if you don't know the IP m = Moku.get_by_name('example') i = m.discover_instrument() if i is None or i.type != 'oscilloscope': print "No or wrong instrument deployed" i = Oscilloscope() m.attach_instrument(i) else: print "Attached to existing Oscilloscope" linespec = { 'color' : '(rgb(100,0,0),)', 'shape' : 'spline', 'width' : '2' } try: i.set_defaults() i.set_samplerate(10)
from pymoku import Moku, MokuException from pymoku.instruments import * import time, logging, traceback logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(message)s') logging.getLogger('pymoku').setLevel(logging.DEBUG) # Use Moku.get_by_serial() or get_by_name() if you don't know the IP m = Moku.get_by_name('example') i = m.discover_instrument() if i is None or i.type != 'oscilloscope': print "No or wrong instrument deployed" i = Oscilloscope() m.attach_instrument(i) else: print "Attached to existing Oscilloscope" try: i.set_defaults() i.set_samplerate(1000) #10ksps i.set_xmode(OSC_ROLL) i.commit() if i.datalogger_busy(): i.datalogger_stop() i.datalogger_start(start=0, duration=10, filetype='net') while True:
from pymoku import Moku, MokuException, NoDataException from pymoku.instruments import * import time, logging, traceback logging.basicConfig(format="%(asctime)s:%(name)s:%(levelname)s::%(message)s") logging.getLogger("pymoku").setLevel(logging.INFO) # Use Moku.get_by_serial() or get_by_name() if you don't know the IP m = Moku.get_by_name("example") i = Oscilloscope() m.attach_instrument(i) try: i.set_samplerate(10) i.set_xmode(OSC_ROLL) i.commit() time.sleep(1) i.datalogger_stop() i.datalogger_start(start=0, duration=100, use_sd=False, ch1=True, ch2=False, filetype="net") while True: ch, idx, d = i.datalogger_get_samples(timeout=5) print("Received samples %d to %d from channel %d" % (idx, idx + len(d) - 1, ch)) except NoDataException as e: # This will be raised if we try and get samples but the session has finished. print(e) except Exception as e: print(traceback.format_exc())
# # (c) 2019 Liquid Instruments Pty. Ltd. # from pymoku import Moku from pymoku.instruments import PIDController def from_dB(dB): # Helper function that converts from dB to linear scale return 10**(dB / 20.0) # Connect to your Moku by its device name # Alternatively, use Moku.get_by_serial('#####') or Moku('192.168.###.###') m = Moku.get_by_name("Moku") try: i = m.deploy_instrument(PIDController) # Configure the PID Controller using frequency response characteristics # P = -10dB # I Crossover = 100Hz # D Crossover = 10kHz # I Saturation = 10dB # D Saturation = 10dB # Double-I = OFF # Note that gains must be converted from dB first i.set_by_frequency(1, kp=from_dB(-10), i_xover=1e2,