Commit 1c58faa2 authored by Matthieu Cattin's avatar Matthieu Cattin

test40: Fix hex2signed function, selects right box output channel, prints more info.

parent 0377f85e
......@@ -61,7 +61,7 @@ BYTES_PER_SAMPLE = 2
TRIG_THRES_VOLT = 0.007
TRIG_THRES_FILT = 20
INT_TRIG_TEST_MODE = True
INT_TRIG_TEST_MODE = False
TRIG_DEL = 0 # in samples
......@@ -89,9 +89,9 @@ def fmc_adc_init(spec, fmc):
# Converts two's complement hex to signed
def hex2signed(value):
if(value & 0x8000):
return -((~value & 0xFFFC) + 1)
return -((~value & 0xFFFF) + 1)
else:
return (value & 0xFFFC)
return (value & 0xFFFF)
# Converts digital value to volts
def digital2volt(value, full_scale, nb_bit):
......@@ -136,7 +136,7 @@ def acq_channels(fmc, carrier, adc_fs, pause):
if(ACQ_TIMEOUT < timeout):
print "Acquisition timeout. Missing trigger?."
print "Acq FSm state: %s"%fmc.get_acq_fsm_state()
return 1
sys.exit()
# Retrieve data trough DMA
trig_pos = fmc.get_trig_pos()
# Enable "DMA done" interrupt
......@@ -285,6 +285,8 @@ def main (default_directory='.'):
# Internal trigger test mode
if INT_TRIG_TEST_MODE == True:
print("\n==================================================")
print("Internal trigger test mode ENABLED!")
fmc.int_trig_tst_en()
##################################################
......@@ -299,26 +301,28 @@ def main (default_directory='.'):
fmc.set_trig_config(trig_hw_sel, trig_hw_pol, trig_hw_en, trig_sw_en, trig_channel, trig_thres, TRIG_DEL, TRIG_THRES_FILT)
print("==================================================")
print("Channel: %d\nInput range: %s\nInput term: %s\nTrigger threshold: %1.1fV\nTrigger threshold filter: %d\nTrigger delay: %d"%(CHANNEL, IN_RANGE, IN_TERM, TRIG_THRES_VOLT, TRIG_THRES_FILT, TRIG_DEL))
print("Channel: %d\nInput range: %s\nInput term: %s\nTrigger threshold: %2.4fV\nTrigger threshold filter: %d\nTrigger delay: %d"%(CHANNEL, IN_RANGE, IN_TERM, TRIG_THRES_VOLT, TRIG_THRES_FILT, TRIG_DEL))
print("==================================================")
# Print configuration
fmc.print_adc_core_config()
#time.sleep(3)
#fmc.print_adc_core_config()
##################################################
# Set awg sine params
##################################################
sine.frequency = 10E3
sine.frequency = 20E3
sine.amplitude = 0.4 * ADC_FS[IN_RANGE]
sine.dc = 0
print "\nSine frequency:%3.3fMHz amplitude:%2.3fVp offset:%2.3fV" % (sine.frequency/1E6, sine.amplitude, sine.dc)
# Set AWG
gen.connect()
gen.play(sine)
gen.output = True
time.sleep(AWG_SET_SLEEP)
print("Can use <pd-extended> to generate noisy sinewave from a soundcard (see sine_noise.pd).")
##################################################
# Configure analogue input
##################################################
......@@ -327,8 +331,8 @@ def main (default_directory='.'):
time.sleep(SSR_SET_SLEEP)
# connect AWG to current channel
#box.select_output_ch(CHANNEL)
#time.sleep(BOX_SET_SLEEP)
box.select_output_ch(CHANNEL)
time.sleep(BOX_SET_SLEEP)
##################################################
# Apply gain and offset correction
......@@ -430,6 +434,8 @@ def main (default_directory='.'):
g = adc_corr_data[IN_RANGE]['gain'][CHANNEL-1]
o = adc_corr_data[IN_RANGE]['offset'][CHANNEL-1]
#g = 0x8000
#o = 0
#print "\nApply ADC offset correction: gain=0x%04X, offset=0x%04X" %(g, o)
fmc.set_adc_gain_offset_corr(CHANNEL, g, o)
......
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