예제 #1
0
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('--timeout',
                        default=5000,
                        type=int,
                        help='default instrument timeout (ms)')
    parser.add_argument('--log', default='', help='SCPI command log filename')
    args = parser.parse_args()

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

        if vna.connected():
            print("connected: {0}".format(vna.id_string()))
            if args.log:
                vna.open_log(args.log)
                vna.log.write('{0}\n'.format(datetime.datetime.now()))
                vna.log.write('--------------------------\n\n')
                vna.print_info()
            sys.path.insert(0, os.getcwd())
            code.interact('', local=locals())
            sys.exit(0)
        else:
            raise Exception('Could not connect to instrument')
    except SystemExit:
        pass
    except:
        print('Error connecting to instrument\n')
        parser.print_help()
    finally:
        if vna.log:
            vna.close_log()
        if vna.connected():
            vna.close()
예제 #2
0
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('--log', default='',
                        help='SCPI command log filename')
    args = parser.parse_args()

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

        if vna.connected():
            print("connected: {0}".format(vna.id_string()))
            if args.log:
                vna.open_log(args.log)
                vna.log.write('{0}\n'.format(datetime.datetime.now()))
                vna.log.write('--------------------------\n\n')
                vna.print_info()
            code.interact('', local=locals())
        else:
            print('Could not connect to instrument\n')
            parser.print_help()
    except SystemExit:
        pass
    except:
        print('Error connecting to instrument\n')
        parser.print_help()
    finally:
        if vna.log:
            vna.close_log()
        if vna.connected():
            vna.close()
예제 #3
0
# paths
root_path = Path(__file__).parent.resolve()
log_file  = str(root_path / 'vna.log')
set_file  = str(root_path / 'sets' / 'set.znxml')


# IP address
address = '192.168.86.192'


# 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)
예제 #4
0

from rohdeschwarz.general         import print_header
from rohdeschwarz.instruments.vna import Vna
from rohdeschwarz.instruments.vna import SweepType
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
예제 #5
0
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()