Commit 53c77073 authored by Matthieu Cattin's avatar Matthieu Cattin

test20: Takes calibration data in the FMC EEPROM instead of in a file.

parent e002f02b
...@@ -297,11 +297,10 @@ def main (default_directory = '.'): ...@@ -297,11 +297,10 @@ def main (default_directory = '.'):
for item in box_calibr_data.iteritems(): for item in box_calibr_data.iteritems():
print "%5s: %1.5fV" % (item[0], float(item[1])) print "%5s: %1.5fV" % (item[0], float(item[1]))
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Get ADC and DAC offset and gain correction parameters # Get ADC and DAC offset and gain correction parameters
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
print "\nRead calibration data from file:" print "\nRead calibration data from FMC EEPROM:"
adc_corr_data = {'10V':{'offset':[],'gain':[]}, adc_corr_data = {'10V':{'offset':[],'gain':[]},
'1V':{'offset':[],'gain':[]}, '1V':{'offset':[],'gain':[]},
...@@ -311,17 +310,16 @@ def main (default_directory = '.'): ...@@ -311,17 +310,16 @@ def main (default_directory = '.'):
'1V':{'offset':[],'gain':[]}, '1V':{'offset':[],'gain':[]},
'100mV':{'offset':[],'gain':[]}} '100mV':{'offset':[],'gain':[]}}
"""
# Read calibration data from file
all_corr_data = [] all_corr_data = []
in_filename = CALIBR_FILENAME in_filename = CALIBR_FILENAME
f_in = open(in_filename,"r+") f_in = open(in_filename,"r+")
for line in f_in: for line in f_in:
all_corr_data.append(int(line,16)) all_corr_data.append(int(line,16))
# print "0x%04X" % all_corr_data[-1] print "0x%04X" % all_corr_data[-1]
f_in.close() f_in.close()
"""
for item in all_corr_data:
print "0x%04X" % item
# Read entire EEPROM # Read entire EEPROM
eeprom_data_read = fmc.sys_i2c_eeprom_read(0, EEPROM_SIZE) eeprom_data_read = fmc.sys_i2c_eeprom_read(0, EEPROM_SIZE)
...@@ -335,20 +333,21 @@ def main (default_directory = '.'): ...@@ -335,20 +333,21 @@ def main (default_directory = '.'):
# Get calibration data # Get calibration data
print "Get calibration data from EEPROM." print "Get calibration data from EEPROM."
eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read() eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read()
eeprom_corr_data = ipmi_get_internal_use_data(eeprom_data) int_use_data = ipmi_get_internal_use_data(eeprom_data)
#print "Calibration data length (bytes): %d" % len(eeprom_corr_data) # Re-arrange correction data into 16-bit number (from bytes)
print "correction data from eeprom" eeprom_corr_data = []
print eeprom_corr_data for i in range(0,len(int_use_data),2):
#for item in eeprom_corr_data: eeprom_corr_data.append((int_use_data[i+1] << 8) + (int_use_data[i]))
# print "0x%s" % item print "Calibration data length (16-bit): %d" % len(eeprom_corr_data)
print "Correction data from eeprom:"
print "\nGet ADC correctioon parameters:" print "\nGet ADC correctioon parameters:"
for IN_RANGE in RANGES: for IN_RANGE in RANGES:
for ch in range(NB_CHANNELS): for ch in range(NB_CHANNELS):
adc_corr_data[IN_RANGE]['offset'].append(hex2signed(all_corr_data.pop(0))) adc_corr_data[IN_RANGE]['offset'].append(hex2signed(eeprom_corr_data.pop(0)))
for ch in range(NB_CHANNELS): for ch in range(NB_CHANNELS):
adc_corr_data[IN_RANGE]['gain'].append(all_corr_data.pop(0)) adc_corr_data[IN_RANGE]['gain'].append(eeprom_corr_data.pop(0))
for ranges in adc_corr_data.iteritems(): for ranges in adc_corr_data.iteritems():
print "%s:" % ranges[0] print "%s:" % ranges[0]
...@@ -362,9 +361,9 @@ def main (default_directory = '.'): ...@@ -362,9 +361,9 @@ def main (default_directory = '.'):
print "\nGet DAC correctioon parameters:" print "\nGet DAC correctioon parameters:"
for IN_RANGE in RANGES: for IN_RANGE in RANGES:
for ch in range(NB_CHANNELS): for ch in range(NB_CHANNELS):
dac_corr_data[IN_RANGE]['offset'].append(hex2signed(all_corr_data.pop(0))) dac_corr_data[IN_RANGE]['offset'].append(hex2signed(eeprom_corr_data.pop(0)))
for ch in range(NB_CHANNELS): for ch in range(NB_CHANNELS):
dac_corr_data[IN_RANGE]['gain'].append(all_corr_data.pop(0)) dac_corr_data[IN_RANGE]['gain'].append(eeprom_corr_data.pop(0))
for ranges in dac_corr_data.iteritems(): for ranges in dac_corr_data.iteritems():
print "%s:" % ranges[0] print "%s:" % ranges[0]
...@@ -381,7 +380,6 @@ def main (default_directory = '.'): ...@@ -381,7 +380,6 @@ def main (default_directory = '.'):
print "\nApply DAC correction\n" print "\nApply DAC correction\n"
fmc.set_dac_corr(dac_corr_data) fmc.set_dac_corr(dac_corr_data)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# ADC Calibration verification # ADC Calibration verification
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
......
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