def setUp(self):
     vna = Vna()
     vna.open_tcp()
     vna.clear_status()
     vna.manual_sweep = True
     timeout_ms = 2 * vna.sweep_time_ms + 5000
     vna.start_sweeps()
     vna.pause(timeout_ms)
     self.vna = vna
Esempio n. 2
0
 def setUp(self):
     self.serial_no = "123"
     self.settings = default_settings.copy()
     path = get_root_path() / "test_measure"
     self.settings['save']['directory'] = path
     vna = Vna()
     vna.open_tcp()
     vna.clear_status()
     self.vna = vna
 def setUp(self):
     root_path = get_root_path() / "test_diagram"
     serial_no = "123"
     by_serial_no = True
     self.path = SavePath(root_path, serial_no, by_serial_no)
     vna = Vna()
     vna.open_tcp()
     vna.clear_status()
     vna.manual_sweep = True
     timeout_ms = 2 * vna.sweep_time_ms + 5000
     vna.start_sweeps()
     vna.pause(timeout_ms)
     self.vna = vna
     self.settings = default_settings.copy()
Esempio n. 4
0
 def test_save_measurement_locally(self):
     vna = Vna()
     vna.open_tcp('rsa22471.local')
     vna.preset()
     ports = [1, 2]
     ch = vna.channel()
     try:
         success = ch.save_measurement_locally('test', ports)
     except:
         print(sys.exc_info()[0])
         print(vna.errors)
         raise
     if not success:
         print(vna.errors)
         vna.clear_status()
     self.assertTrue(success)
Esempio n. 5
0
 def setUp(self):
     source_root = os.path.dirname(os.path.realpath(__file__))
     self.source_root = Path(source_root)
     root_path = get_root_path() / "test_html"
     serial_no = self.serial_no = "123"
     by_serial_no = True
     self.path = SavePath(root_path, serial_no, by_serial_no)
     vna = Vna()
     vna.open_tcp()
     vna.clear_status()
     vna.manual_sweep = True
     timeout_ms = 2 * vna.sweep_time_ms + 5000
     vna.start_sweeps()
     vna.pause(timeout_ms)
     self.vna = vna
     self.settings = default_settings.copy()
Esempio n. 6
0
# create Vna instance
vna = Vna()

# log
vna.open_log(log_file)
vna.print_info()

# connect to instrument (no visa)
vna.open_tcp(address)

# alternatively, using pyvisa:
# vna.open('gpib', 20)

# preset and clear errors
vna.clear_status()
vna.preset()
vna.pause()

# create an interesting setup
# to save
ch1 = vna.channel(1)
ch1.start_frequency_Hz = 1.0e9
ch1.stop_frequency_Hz  = 2.0e9
ch1.points             = 401

trc1 = vna.trace('Trc1')
trc1.parameter = 'S11'

index = vna.create_diagram()
Esempio n. 7
0
import matplotlib.pyplot as plt
import numpy             as np

# Open instrument connection
vna = Vna()
vna.open('TCPIP', '127.0.0.1')

# SCPI command log
vna.open_log("SCPI Command Log.txt")
print_header(vna.log, "Measure with a1", "0.0.1")
vna.print_info()

# Preset
vna.preset()
vna.pause()
vna.clear_status()

# Setup channel 1
ch1                 = vna.channel(1)
ch1.sweep_type      = SweepType.power
ch1.start_power_dBm = -20.0
ch1.stop_power_dBm  = 0
ch1.points          = 201
ch1.if_bw_Hz        = 1, 'kilo'
ch1.cal_group       = 'example'
ch1.manual_sweep    = True

# Setup Trc1: S21
s21_trace           = vna.trace('Trc1')
s21_trace.parameter = 'S21'
def main():
    parser = argparse.ArgumentParser(
        description='Connect to a Rohde & Schwarz VNA')
    parser.add_argument('--visa',
                        metavar='bus',
                        default=False,
                        help="use VISA with 'bus'")
    parser.add_argument('--address',
                        default='127.0.0.1',
                        help='instrument address')
    parser.add_argument('--port',
                        default=5025,
                        type=int,
                        help='port (TCP only)')
    parser.add_argument('--timeout',
                        default=5000,
                        type=int,
                        help='default instrument timeout (ms)')
    parser.add_argument('--log', help='SCPI command log filename')
    parser.add_argument(
        '--export-cal-data',
        action='store_true',
        help='Save corrections to numpy `savez` (*.pyz) data file')
    parser.add_argument('--outer-channel',
                        type=int,
                        help='channel with outer corrections')
    parser.add_argument('--outer-cal-group',
                        help='cal group containing outer corrections')
    parser.add_argument('--inner-channel',
                        type=int,
                        help='channel with inner corrections')
    parser.add_argument('--inner-cal-group',
                        help='cal group containing inner corrections')
    parser.add_argument('--filename',
                        default='Port {port}.s2p',
                        help="default: 'Port {port}.s2p'")
    parser.add_argument('ports',
                        type=int,
                        nargs='+',
                        help='VNA ports to extract DUTs from')
    args = parser.parse_args()

    if not args.inner_channel and not args.inner_cal_group:
        print('error: must include inner source, either channel or cal group')
        parser.print_help()
        sys.exit(-1)
    if not args.outer_channel and not args.outer_cal_group:
        print('error: must include outer source, either channel or cal group')
        parser.print_help()
        sys.exit(-1)

    vna = Vna()
    try:
        if args.visa:
            vna.open(args.visa, args.address)
        else:
            vna.open_tcp(args.address, args.port)
        if args.timeout:
            vna.timeout_ms = args.timeout

        if vna.connected():
            if args.log:
                vna.open_log(args.log)
                print_header(vna.log, 'R&S S2P Extractor', '1.0')
                vna.print_info()
        else:
            raise Exception('Could not connect to instrument')

        if args.outer_channel:
            outer_source = Source(Type.CHANNEL, args.outer_channel)
        else:
            outer_source = Source(Type.CAL_GROUP, args.outer_cal_group)
        if args.inner_channel:
            inner_source = Source(Type.CHANNEL, args.inner_channel)
        else:
            inner_source = Source(Type.CAL_GROUP, args.inner_cal_group)
        print(f"ports: {args.ports}")
        for port in args.ports:
            filename = args.filename.format(port=port)
            print(f'  {filename}')
            calculate(vna, outer_source, inner_source, port, filename,
                      args.export_cal_data)
    except Exception as err:
        parser.print_help()
        raise
    finally:
        if vna.connected():
            vna.errors
            vna.clear_status()
        if vna.log:
            vna.close_log()
        if vna.connected():
            vna.close()