Skip to content
Snippets Groups Projects
Commit 5579ed9b authored by David Tebbe's avatar David Tebbe
Browse files

Works now with Labber defined Functions

parent 66cf991f
Branches
No related tags found
1 merge request!2Druiver for Keithley 3390 Arbitrary Waveform Generator
......@@ -146,28 +146,35 @@ def_value: 0.0
unit: V
set_cmd: :VOLT:OFFS
###########################################################################
#[Sample rate]
#datatype: DOUBLE
#def_value: 1E9
#unit: Hz
#set_cmd: :SOUR1:FUNC:ARB:SRAT
#state_quant: Function
#state_value_1: Arb
#[Filter]
#datatype: COMBO
#def_value: Step
#combo_def_1: Normal
#combo_def_2: Step
#combo_def_3: Off
#cmd_def_1: NORM
#cmd_def_2: STEP
#cmd_def_3: OFF
#set_cmd: :SOUR1:FUNC:ARB:FILT
#state_quant: Function
#state_value_1: Arb
##############################################################################
[Waveform selection]
datatype: COMBO
def_value: Labber Defined
combo_def_1: Exponential Rise
combo_def_2: Exponential Fall
combo_def_3: Negative Ramp
combo_def_4: Sinc
combo_def_5: Cardiac
combo_def_6: Labber Defined
cmd_def_1: EXP_RISE
cmd_def_2: EXP_FALL
cmd_def_3: NEG_RAMP
cmd_def_4: SINC
cmd_def_5: CARDIAC
cmd_def_6: LABBER
set_cmd: :FUNC:USER
state_quant: Function
state_value_1: Arb
[Border]
datatype: COMBO
def_value: Swapped
combo_def_1: Normal
combo_def_2: Swapped
cmd_def_1: NORM
cmd_def_2: SWAP
set_cmd: :FORM:BORD
state_quant: Waveform selection
state_value_1: Labber Defined
[Duty cycle]
datatype: DOUBLE
......
......@@ -35,7 +35,9 @@ class Driver(VISA_Driver):
# if final call and wave is updated, send it to AWG
if self.isFinalCall(options) and self.bWaveUpdated:
# Double check that the waveform truly changed
self.log('Final Call and bwaveUpdated', level=30)
if not np.array_equal(self.getValueArray('Arb. Waveform'), self.waves):
self.log('Arb.Waveform is going to be changed', level=30)
# store and send waveforms
self.waves = np.copy(self.getValueArray('Arb. Waveform'))
self.sendWaveform()
......@@ -48,30 +50,29 @@ class Driver(VISA_Driver):
def sendWaveform(self):
"""Rescale and send waveform data to the AWG"""
Vpp = self.getValue('Voltage')
Vpp = self.getValue('Amplitude')
self.log(Vpp)
# get data
data = self.getValueArray('Arb. Waveform')
# get range and scale to U16
data16 = self.scaleWaveformToI16(data, Vpp)
length = len(data16)
# create data as bytes with header
length = b'%d' % (2*length)
header = b':DATA:DAC VOLATILE, #%d%s' % (len(length), length)
datanor = self.scaleWaveform(data, Vpp)
# write header + data
self.write_raw(header + data16.tobytes())
header = ':DATA VOLATILE'
# write header + data
for i in datanor:
header+=', '+str(i)
self.writeAndLog(header)
# select waveform
self.write(':DATA:COPY LABBER')
self.write(':FUNC:USER LABBER')
self.writeAndLog(':DATA:COPY LABBER, VOLATILE')
self.writeAndLog(':FUNC:USER LABBER')
# Setting ARB resets amplitude and offset, so we set those again
self.sendValueToOther('Voltage', Vpp)
self.sendValueToOther('Amplitude', Vpp)
self.sendValueToOther('Offset', self.getValue('Offset'))
def scaleWaveformToI16(self, data, Vpp):
"""Scales the waveform and returns data in a string of I16"""
# scale waveform to use full DAC range
def scaleWaveform(self, data, Vpp):
"""Scales the waveform and returns data in intervall from -1 to 1"""
data = np.array(data)/np.max(data)
return np.array(32767*data, dtype=np.int16)
return np.array(data)
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment