Пример #1
0
def configureDig(chassis, module):
    log.info("Configuring DIG in slot {}...".format(module.slot))
    module.handle = key.SD_AIN()
    dig = module.handle
    error = dig.openWithSlotCompatibility('', chassis, module.slot,
                                          key.SD_Compatibility.KEYSIGHT)
    if error < 0:
        log.info("Error Opening - {}".format(error))
    if module.fpga.file_name != "":
        log.info("Loading FPGA image: {}".format(module.fpga.file_name))
        error = dig.FPGAload(os.getcwd() + '\\' + module.fpga.file_name)
        if error < 0:
            log.error('Loading FPGA bitfile: {} {}'.format(
                error, key.SD_Error.getErrorMessage(error)))

#Configure all channels to be DC coupled and 50 Ohm
    for channel in range(1, module.channels + 1):
        error = dig.DAQflush(channel)
        if error < 0:
            log.info("Error Flushing")
    error = dig.channelInputConfig(channel, 2.0,
                                   key.AIN_Impedance.AIN_IMPEDANCE_50,
                                   key.AIN_Coupling.AIN_COUPLING_DC)
    if error < 0:
        log.info("Error Configuring channel")

    for daq in module.daqs:
        log.info("Configuring Acquisition parameters for channel {}".format(
            daq.channel))
        if daq.trigger:
            trigger_mode = key.SD_TriggerModes.SWHVITRIG
        else:
            trigger_mode = key.SD_TriggerModes.AUTOTRIG
        trigger_delay = daq.triggerDelay * module.sample_rate  # expressed in samples
        trigger_delay = int(np.round(trigger_delay))
        pointsPerCycle = int(np.round(daq.captureTime * module.sample_rate))
        error = dig.DAQconfig(daq.channel, pointsPerCycle, daq.captureCount,
                              trigger_delay, trigger_mode)
        if error < 0:
            log.info("Error Configuring Acquisition")
        log.info("Starting DAQ, channel {}".format(daq.channel))
        error = dig.DAQstart(daq.channel)
        if error < 0:
            log.info("Error Starting Digitizer")
Пример #2
0
 def __init__(self, name, chassis, slot_in):
     logging.info(__name__ + ' : Initializing instrument Spectrum')
     Instrument.__init__(self, name, tags=['physical'])
     self.moduleIn = keysightSD1.SD_AIN()
     self.moduleInID = self.moduleIn.openWithSlot("M3102A", chassis,
                                                  slot_in)
     self.mask = 0
     self.trigger_delay = 0
     self.software_nums_multi = 1
     self.software_averages = 1
     self.nop = 256
     self.nums = 1
     self.trigger = keysightSD1.SD_TriggerModes.EXTTRIG
     self.moduleIn.triggerIOconfig(1)
     self.timeout = 10000
     self.impedances = [0] * 5
     self.couplings = [0] * 5
     self.fullscale = [0.0625] * 5
     for ch in range(4):
         self.set_channelinputconfig(ch + 1)
Пример #3
0
    def open_modules(self, slots, type):
        ''' 
        slots = list of slot numbers of device
        type = string 'awg' to open awg modules, 'dig' to
        open digitizer modules
        open_modules creates and returns a list keysightSD1 module objects
        '''
        log_string = ""
        log_status = 20
        options = "channelNumbering=keysight"
        model = ""
        modules = []
        if slots:
            for slot in slots:
                if type == 'awg':
                    module = keysightSD1.SD_AOU()
                elif type == 'dig':
                    module = keysightSD1.SD_AIN()
                else:
                    raise Error('Only AWGs and digitizers are supported')

                # check that we haven't already assigned module to this slot
                if self.slot_free[slot - 1] == True:
                    id_num = module.openWithOptions(model, self.chassis, slot,
                                                    options)
                    if id_num < 0:
                        raise Error(
                            "Error opening module in chassis {}, slot {}, opened with ID: {}"
                            .format(self.chassis, slot, id_num))
                    if not module.hvi:
                        raise Error(
                            "Module in chassis {} and slot {} does not support HVI2.0... exiting"
                            .format(awgModule.getChassis(),
                                    awgModule.getSlot()))
                    modules.append(module)
                    self.slot_free[slot - 1] = False
                    log_string += 'slots status: ' + str(self.slot_free) + '\n'
                else:
                    log_string += 'slot taken, check behavior' + '\n'
                    log_status = 30
        return modules, log_string, log_status
Пример #4
0
    def __init__(self, name, chassis, slot, n_channels = 4):
        super().__init__(name)
        """
        init keysight digitizer

        Args:
            name (str) : name of the digitizer
            chassis (int) : chassis number
            slot (int) : slot in the chassis where the digitizer is.
            n_channels (int) : number of channels on the digitizer card.

        NOTE: channels start for number 1! (e.g. channel 1, channel 2, channel 3, channel 4)
        """
        self.SD_AIN = keysightSD1.SD_AIN()
        dig_name = check_error(self.SD_AIN.getProductNameBySlot(chassis, slot), 'getProductNameBySlot')
        check_error(self.SD_AIN.openWithSlot(dig_name, chassis, slot), 'openWithSlot')

        firmware_version = self.SD_AIN.getFirmwareVersion()
        major,minor,revision = firmware_version.split('.')

        if (major == '02') != is_sd1_3x:
            raise Exception(f'KeysightSD1 driver not compatible with firmware "{firmware_version}"')

        self.chassis = chassis
        self.slot = slot

        self.operation_mode = OPERATION_MODES.SOFT_TRG

        self.use_old_fpga_averaging = False

        self.channel_properties = dict()
        for i in range(n_channels):
            properties = channel_properties(f'ch{i+1}', i + 1)
            self.channel_properties[f'ch{i+1}'] = properties

        self.add_parameter(
            'measure',
            inst_name = self.name,
            parameter_class=line_trace,
            raw =False
            )
Пример #5
0
 def __init__(self, module_dict):
     super().__init__()
     self.module_dict = module_dict
     for key, value in self.module_dict.items():
         if key[2] == '1':
             sd1_obj = keysightSD1.SD_AIN()
             sd1_obj_id = sd1_obj.openWithSlot("", value[0], value[1])
             if sd1_obj_id < 0:
                 print(
                     "[ERROR] Test.__init__: Error opening {}".format(key))
             self._module_instances.append([sd1_obj, key, value])
         elif key[2] == '2':
             sd1_obj = keysightSD1.SD_AOU()
             sd1_obj_id = sd1_obj.openWithSlot("", value[0], value[1])
             if sd1_obj_id < 0:
                 print(
                     "[ERROR] Test.__init__: Error opening {}".format(key))
             self._module_instances.append([sd1_obj, key, value])
         else:
             print(
                 "[ERROR] Test.__init__: Did not properly parse instrument type string."
             )
Пример #6
0
import sys
sys.path.append('C:\Program Files (x86)\Keysight\SD1\Libraries\Python')

import keysightSD1

# MODULE CONSTANTS
PRODUCT = ""
CHASSIS = 1
# change slot number to your value
SLOT = 6

CHANNEL = 0

# CREATE AND OPEN MODULE
module = keysightSD1.SD_AIN()

moduleID = module.openWithSlot(PRODUCT, CHASSIS, SLOT)

if moduleID < 0:
	print("Module open error:", moduleID)
else:
	print("Module opened:", moduleID)
	print("Module name:", module.getProductName())
	print("slot:", module.getSlot())
	print("Chassis:", module.getChassis())
	print()

	# CONFIGURE AND START DAQ
	POINTS_PER_CYCLE = 100
	CYCLES = 500
	TRIGGER_DELAY = 0
    def performOpen(self, options={}):
        """Perform the operation of opening the instrument connection"""
        # number of demod blocks in the FPGA
        self.num_of_demods = 5
        # self.demod_n_pts = self.num_of_demods * 15
        self.demod_n_pts = 80
        self.bit_stream_name = ''

        # set time step and resolution
        self.nBit = 16
        self.bitRange = float(2**(self.nBit - 1) - 1)
        # timeout
        self.timeout_ms = int(1000 * self.dComCfg['Timeout'])
        # get PXI chassis
        self.chassis = int(self.dComCfg.get('PXI chassis', 1))
        # create AWG instance
        self.dig = keysightSD1.SD_AIN()
        AWGPart = self.dig.getProductNameBySlot(self.chassis,
                                                int(self.comCfg.address))
        self.log(
            'Serial:',
            self.dig.getSerialNumberBySlot(self.chassis,
                                           int(self.comCfg.address)))
        if not isinstance(AWGPart, str):
            raise Error('Unit not available')
        # check that model is supported
        dOptionCfg = self.dInstrCfg['options']
        for validId, validName in zip(dOptionCfg['model_id'],
                                      dOptionCfg['model_str']):
            if AWGPart.find(validId) >= 0:
                # id found, stop searching
                break
        else:
            # loop fell through, raise ID error
            raise IdError(AWGPart, dOptionCfg['model_id'])
        # set model
        self.setModel(validName)
        # sampling rate and number of channles is set by model
        if validName in ('M3102', 'M3302'):
            # 500 MHz models
            self.dt = 2E-9
            self.nCh = 4
        else:
            # assume 100 MHz for all other models
            self.dt = 10E-9
            self.nCh = 4
        # create list of sampled data
        self.lTrace = [np.array([])] * self.nCh
        self.demod_output_ssb = np.zeros((0, ), dtype='complex')
        self.demod_buffer = np.zeros((0, ), dtype=np.int16)

        self.dig.openWithSlot(AWGPart, self.chassis, int(self.comCfg.address))
        # get hardware version - changes numbering of channels
        hw_version = self.dig.getHardwareVersion()
        if hw_version >= 4:
            # KEYSIGHT - channel numbers start with 1
            self.ch_index_zero = 1
        else:
            # SIGNADYNE - channel numbers start with 0
            self.ch_index_zero = 0
        self.log('HW:', hw_version)
        self.configure_FPGA()
Пример #8
0
import matplotlib.pyplot as plt
import numpy as np

# MODULE CONSTANTS
PRODUCT = ""
CHASSIS = 1

# change slot numbers to your values
SLOT_IN = 3
SLOT_OUT = 2

NUM_CHANNELS = 3
CHANNEL_TRIG_CONTROL = 3

# CREATE AND OPEN MODULE IN
moduleIn = keysightSD1.SD_AIN()

moduleInID = moduleIn.openWithSlot(PRODUCT, CHASSIS, SLOT_IN)

if moduleInID < 0:
    print("Error opening module IN - error code:", moduleInID)
else:
    print("===== MODULE IN =====")
    print("ID:\t\t", moduleInID)
    print("Product name:\t", moduleIn.getProductName())
    print("Serial number:\t", moduleIn.getSerialNumber())
    print("Chassis:\t", moduleIn.getChassis())
    print("Slot:\t\t", moduleIn.getSlot())

print()
Пример #9
0
import sys
import keysightSD1
import matplotlib.pyplot as plt

chassis = 1
slotdig = 9
slotawg = 16
product = ""

dig = keysightSD1.SD_AIN()
awg = keysightSD1.SD_AOU()
digopen = dig.openWithSlot(product, chassis, slotdig)
print(digopen)
awgopen = awg.openWithSlot(product, chassis, slotawg)
print(awgopen)

dig.channelInputConfig(1, 3, keysightSD1.AIN_Impedance.AIN_IMPEDANCE_50, keysightSD1.AIN_Coupling.AIN_COUPLING_AC)
dig.channelTriggerConfig(1, keysightSD1.SD_AIN_TriggerMode.RISING_EDGE, 1)
dig.DAQconfig(1, 1000000, 3, 0, keysightSD1.SD_TriggerModes.ANALOGTRIG)
dig.DAQstart(1)

awg.channelWaveShape(1, keysightSD1.SD_Waveshapes.AOU_SINUSOIDAL)
awg.channelAmplitude(1, 1.5)
awg.channelFrequency(1, 1e6)

arr = []

arr.append(dig.DAQread(1, 30000, 2))
s = [1:30000]

plt.plot(arr)