Commit 652fe9d6 authored by Matthieu Cattin's avatar Matthieu Cattin

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

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