Commit 353cfc0d authored by Matthieu Cattin's avatar Matthieu Cattin

test39: Fix hex2signed function, prints more info.

parent f2439563
...@@ -76,9 +76,9 @@ def fmc_adc_init(spec, fmc): ...@@ -76,9 +76,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):
...@@ -370,12 +370,13 @@ def main (default_directory='.'): ...@@ -370,12 +370,13 @@ def main (default_directory='.'):
# Apply a DC offset # Apply a DC offset
################################################## ##################################################
dc_offset = 0xA000 dc_offset = 0xA000
print("\nSet dc offset to: 0x%08X"%(dc_offset))
fmc.set_dc_offset_corrected(1, IN_RANGE, dc_offset, print_value=True) fmc.set_dc_offset_corrected(1, IN_RANGE, dc_offset, print_value=True)
################################################## ##################################################
# Acquire channel 1 # Acquire channel 1
################################################## ##################################################
print "\nAcquiring channel 1" print "Acquiring channel 1"
# Configure analogue input # Configure analogue input
fmc.set_input_range(1, IN_RANGE) fmc.set_input_range(1, IN_RANGE)
fmc.set_input_term(1, IN_TERM) fmc.set_input_term(1, IN_TERM)
...@@ -406,6 +407,8 @@ def main (default_directory='.'): ...@@ -406,6 +407,8 @@ def main (default_directory='.'):
################################################## ##################################################
g = adc_corr_data[IN_RANGE]['gain'][0] g = adc_corr_data[IN_RANGE]['gain'][0]
o = adc_corr_data[IN_RANGE]['offset'][0] o = adc_corr_data[IN_RANGE]['offset'][0]
#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(1, g, o) fmc.set_adc_gain_offset_corr(1, g, o)
...@@ -414,7 +417,7 @@ def main (default_directory='.'): ...@@ -414,7 +417,7 @@ def main (default_directory='.'):
################################################## ##################################################
# Acquire channel 1 # Acquire channel 1
################################################## ##################################################
print "\nAcquiring channel 1" print "Acquiring channel 1"
# Perform an acquisition # Perform an acquisition
acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE) acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE)
channel_data = acq_data[0::4] channel_data = acq_data[0::4]
...@@ -434,6 +437,7 @@ def main (default_directory='.'): ...@@ -434,6 +437,7 @@ def main (default_directory='.'):
# Set saturation # Set saturation
################################################## ##################################################
sat_thres = 10000 sat_thres = 10000
print("\nSet saturation to: 0x%08X"%(sat_thres))
fmc.fmc_adc_csr.set_field('CH1_SAT', 'VAL', sat_thres) fmc.fmc_adc_csr.set_field('CH1_SAT', 'VAL', sat_thres)
fmc.fmc_adc_csr.set_field('CH2_SAT', 'VAL', sat_thres) fmc.fmc_adc_csr.set_field('CH2_SAT', 'VAL', sat_thres)
fmc.fmc_adc_csr.set_field('CH3_SAT', 'VAL', sat_thres) fmc.fmc_adc_csr.set_field('CH3_SAT', 'VAL', sat_thres)
...@@ -442,7 +446,7 @@ def main (default_directory='.'): ...@@ -442,7 +446,7 @@ def main (default_directory='.'):
################################################## ##################################################
# Acquire channel 1 # Acquire channel 1
################################################## ##################################################
print "\nAcquiring channel 1" print "Acquiring channel 1"
# Perform an acquisition # Perform an acquisition
acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE) acq_data, trig_timetag = acq_channels(fmc, carrier, ADC_FS[IN_RANGE], ACQ_PAUSE)
channel_data = acq_data[0::4] channel_data = acq_data[0::4]
......
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