Commit 90d9ef1b authored by Matthieu Cattin's avatar Matthieu Cattin

svec_test12: Use acquisition methods from fmc_adc class.

parent 81384105
......@@ -29,7 +29,7 @@ from numpy import *
"""
svec_test12: Takes an aqcuisition of all channels and print it to a file
Set UTC and read UTC time-tags
Set UTC and read UTC time-tags
Note: Requires svec_test00.py to run first to load the firmware!
"""
......@@ -50,66 +50,6 @@ NB_SHOTS = 1
ACQ_LENGTH = 10000 # in samples
def open_all_channels(fmc):
for i in range(1,NB_CHANNELS+1):
fmc.set_input_range(i, 'OPEN')
time.sleep(SSR_SET_SLEEP)
def fmc_adc_init(bus, fmc):
print "Initialise FMC board.\n"
# Reset offset DACs
fmc.dc_offset_reset()
# Make sure all switches are OFF
open_all_channels(fmc)
# Set software trigger
fmc.set_soft_trig()
# Set acquisition
fmc.set_pre_trig_samples(PRE_TRIG_SAMPLES)
fmc.set_post_trig_samples(POST_TRIG_SAMPLES)
fmc.set_shots(NB_SHOTS)
# Converts two's complement hex to signed
def hex2signed(value):
if(value & 0x8000):
return -((~value & 0xFFFF) + 1)
else:
return value
# Converts digital value to volts
def digital2volt(value, full_scale, nb_bit):
return float(value) * float(full_scale)/2**nb_bit
def acq_channels(fmc, carrier, adc_fs, pause):
# Make sure no acquisition is running
fmc.stop_acq()
time.sleep(pause)
# Start acquisition
fmc.start_acq()
time.sleep(pause)
# Trigger
fmc.sw_trig()
# Wait end of acquisition
timeout = 0
while('IDLE' != fmc.get_acq_fsm_state()):
time.sleep(.1)
timeout += 1
if(ACQ_TIMEOUT < timeout):
print "Acquisition timeout. Missing trigger?."
print "Acq FSm state: %s"%fmc.get_acq_fsm_state()
return 1
# Retrieve data trough DMA
trig_pos = fmc.get_trig_pos()
# Read ACQ_LENGTH samples after the trigger for all channels
print('Getting data from DDR...')
channels_data = fmc.get_data((trig_pos<<3), ACQ_LENGTH*8)
#print [hex(val) for val in channels_data[0::4][:10]]
channels_data = [hex2signed(item) for item in channels_data]
#print [hex(val) for val in channels_data[0::4][:10]]
channels_data = [digital2volt(item,adc_fs,16) for item in channels_data]
#print channels_data[0::4][:10]
return channels_data
def main (default_directory='.'):
# Constants declaration
......@@ -164,7 +104,8 @@ def main (default_directory='.'):
print('[FMC slot %d]'%(i+1))
# Initialise fmc adc
fmc_adc_init(bus, fmc[i])
#fmc_adc_init(bus, fmc[i])
fmc[i].acq_init(PRE_TRIG_SAMPLES, POST_TRIG_SAMPLES, NB_SHOTS)
# Use test data instead of data from ADC
# fmc.test_data_en()
......@@ -204,7 +145,7 @@ def main (default_directory='.'):
# Perform an acquisition
print "\nAcquiring channels"
acq_data = acq_channels(fmc[i], carrier, ADC_FS[IN_RANGE], ACQ_PAUSE)
acq_data = fmc[i].acq_channels('svec', carrier, ADC_FS[IN_RANGE], ACQ_LENGTH, ACQ_PAUSE)
for ch in range(NB_CHANNELS):
channels_data[ch] = acq_data[ch::4]
# Get time-tags
......@@ -225,7 +166,7 @@ def main (default_directory='.'):
ch_mean.append(mean(channels_data[ch]))
# Make sure all switches are OFF
open_all_channels(fmc[i])
fmc[i].open_all_channels()
fmc_channels[i] = channels_data
......
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