Commit 5cafc73b authored by Projects's avatar Projects

pulsegen: Removed 'samples' parameter.

Number of samples used for creating an arbitrary waveform
is now automatically adjusted.
parent adbd3b8d
......@@ -99,13 +99,11 @@ class PulseGen:
# clear errors
self.ser.write(b'*CLS\r\n')
def pulse(self, count, freq, width, samples):
def pulse(self, count, freq, width):
""" Configures the pulse burst signal.
:param count: Number of requested pulses
:param freq: Frequency of pulses [Hz]
:param width: Pulse duration [s]
:param samples: Number of samples used to generate an arbitrary waveform,
if needed
"""
# Select the way of generating pulses
# 33250A has a limit of 1e6 pulses in a single burst. To overcome this
......@@ -140,7 +138,9 @@ class PulseGen:
# generate the string that represents the requested waveform
duty_cycle = width / period
one_count = int(samples * duty_cycle)
# number of samples to accurately represent the signal
samples = min(math.ceil(10.0 * period / width), 65535)
one_count = math.ceil(samples * duty_cycle)
zero_count = samples - one_count
# generator DAC values mapping
......@@ -149,14 +149,14 @@ class PulseGen:
zero_value = b', -2047'
# single pulse (take into account the duty cycle)
chunk = b'%s%s' % (zero_count * zero_value, one_count * one_value )
chunk = b'%s%s' % (zero_count * zero_value, one_count * one_value)
# full waveform (repeat the pulse 'div' times)
pattern = chunk * div
# update all variables basing on the divider
freq = freq / div
count = math.ceil(count / div)
width = duty_cycle * period
width = one_count / samples * period
# the actual number of pulses is rounded to the number of pulses in
# the arbitrary waveform
real_count = count * div
......@@ -247,7 +247,6 @@ if __name__ == '__main__':
count = 2000000
freq = 2e6 # Hz
width = 250e-9 # s
samples = 100 # number of samples for arbitrary waveform
def usage():
print('(c) CERN 2017')
......@@ -261,7 +260,6 @@ if __name__ == '__main__':
print('-c|--count= number of requested pulses (default: %d)' % count)
print('-f|--freq= frequency of the pulses [Hz] (default: %G)' % freq)
print('-w|--width= pulse width [s] (default: %G)' % width)
print('-s|--samples= arbitrary waveform samples count (default: %d)' % samples)
print('')
print('-h|--help shows this information')
......@@ -285,13 +283,6 @@ if __name__ == '__main__':
device = arg
elif opt in ('-f', '--freq'):
freq = float(arg)
elif opt in ('-s', '--samples'):
samples = int(float(arg))
if samples > 65536:
print('ERROR: Samples number limit is 65536')
sys.exit(2)
elif opt in ('-w', '--width'):
width = float(arg)
elif opt in ('-h', '--help'):
......@@ -306,7 +297,7 @@ if __name__ == '__main__':
try:
gen = PulseGen(device, baud)
gen.reset()
gen.pulse(count, freq, width, samples)
gen.pulse(count, freq, width)
print('Signal generation started')
gen.trigger()
gen.wait()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment