Exemplo n.º 1
0
def __calibrate_adc_vin3_2v5():
    """Calibrate ADC VIN3.

    SETUP: Connect M1K GND on the calibration board GND.
    For offset measurement connect calibration board 2v5 pin on GND.

    For scale determination connect calibration board 2v5 pin on CHA pin.
    On the M1K connector measure voltage value between 2V5 pin and GND.
    Measure voltage on R21 on the calibration board.
    Determine the report between these two voltages.

    For gain determination observe current voltage value measured by ADC.
    On the M1K connector measure voltage value between 2V5 pin and GND.
    Determine the report between these two voltages.
    """
    print TEXT['green'], __calibrate_adc_vin3_2v5.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['EN_1V2__1'])
    ex_1v2_ref = eeprom_m24c02.read_write(0x08, '', 8, 'float')
    check_adc(3, ex_1v2_ref, 1, 1, 1)
    request_factor('Enter offset value (e.g: 3): ', 0x50, '{:<2}', 2)
    adc_offset_vin3 = int(eeprom_m24c02.read_write(0x50, '', 2, 'float'))
    check_adc(3, ex_1v2_ref, adc_offset_vin3, 1, 1)
    display_eeprom_content()

    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_0__1', 'EN_1V2__1'])
    request_factor('Enter scale value (e.g: 4.2411): ', 0x53, '{:<6}', 6)
    adc_scale_vin3 = eeprom_m24c02.read_write(0x53, '', 6, 'float')
    check_adc(3, ex_1v2_ref, adc_offset_vin3, adc_scale_vin3, 1)
    display_eeprom_content()

    request_factor('Enter gain value (e.g: 0.9996): ', 0x5A, '{:<6}', 6)
    adc_gain_vin3 = eeprom_m24c02.read_write(0x5A, '', 6, 'float')
    check_adc(3, ex_1v2_ref, adc_offset_vin3, adc_scale_vin3, adc_gain_vin3)
    display_eeprom_content()
Exemplo n.º 2
0
def __calibrate_adc_vin2_scale_gain():
    """SETUP: Connect M1K GND on the calibration board GND.

    For scale determination connect M1K board on the calibration board.
    Measure voltage value on R38 on the M1K.
    Measure voltage on R17 on the calibration board.
    Determine the report between these two voltages.

    For gain determination observe current voltage value measured by ADC.
    Measure voltage value on R38 on the M1K.
    Determine the report between these two voltages.
    """
    print TEXT['green'], \
        __calibrate_adc_vin2_scale_gain.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'EN_1V2__1'])
    ex_1v2_ref = eeprom_m24c02.read_write(0x08, '', 8, 'float')
    adc_offset_vin2 = int(eeprom_m24c02.read_write(0x40, '', 2, 'float'))
    check_adc(2, ex_1v2_ref, adc_offset_vin2, 1, 1)
    request_factor('Enter scale value (e.g: 4.2340): ', 0x43, '{:<6}', 6)
    adc_scale_vin2 = eeprom_m24c02.read_write(0x43, '', 6, 'float')
    check_adc(2, ex_1v2_ref, adc_offset_vin2, adc_scale_vin2, 1)
    display_eeprom_content()

    request_factor('Enter gain value (e.g: 1.0015): ', 0x4A, '{:<6}', 6)
    adc_gain_vin2 = eeprom_m24c02.read_write(0x4A, '', 6, 'float')
    check_adc(2, ex_1v2_ref, adc_offset_vin2, adc_scale_vin2, adc_gain_vin2)
    display_eeprom_content()
Exemplo n.º 3
0
def __calibrate_adc_vin1_5v0():
    """Calibrate ADC VIN1.

    SETUP: Connect M1K GND on the calibration board GND.
    For offset measurement connect calibration board 5V0 pin on GND.

    For scale determination connect calibration board 5V0 pin on CHA pin.
    On the M1K connector measure voltage value between 5V0 pin and GND.
    Measure voltage on R20 on the calibration board.
    Determine the report between these two voltages.

    For gain determination observe current voltage value measured by ADC.
    On the M1K connector measure voltage value between 5V0 pin and GND.
    Determine the report between these two voltages.
    """
    print TEXT['green'], __calibrate_adc_vin1_5v0.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['EN_1V2__1'])
    ex_1v2_ref = eeprom_m24c02.read_write(0x08, '', 8, 'float')
    check_adc(1, ex_1v2_ref, 1, 1, 1)
    request_factor('Enter offset value (e.g: 4): ', 0x30, '{:<2}', 2)
    adc_offset_vin1 = int(eeprom_m24c02.read_write(0x30, '', 2, 'float'))
    check_adc(1, ex_1v2_ref, adc_offset_vin1, 1, 1)
    display_eeprom_content()

    request_factor('Enter scale value (e.g: 4.2347): ', 0x33, '{:<6}', 6)
    adc_scale_vin1 = eeprom_m24c02.read_write(0x33, '', 6, 'float')
    check_adc(1, ex_1v2_ref, adc_offset_vin1, adc_scale_vin1, 1)
    display_eeprom_content()

    request_factor('Enter gain value (e.g: 1.0001): ', 0x3A, '{:<6}', 6)
    adc_gain_vin1 = eeprom_m24c02.read_write(0x3A, '', 6, 'float')
    check_adc(1, ex_1v2_ref, adc_offset_vin1, adc_scale_vin1, adc_gain_vin1)
    display_eeprom_content()
Exemplo n.º 4
0
def write_in_eeprom(flag, memmory_address, memmory_data):
    """Write data in EEPROM."""
    while True:
        key_2 = wait_key('\r\tWrite in EEPROM? <y/n>: ', 1)
        if key_2 == 'y':
            eeprom_m24c02.read_write(memmory_address, memmory_data)
            break
        if key_2 == 'n':
            break
        flag = True
    return flag
Exemplo n.º 5
0
def __calibrate_adc_vin2_offset():
    """Calibrate ADC VIN2.

    SETUP: Connect M1K GND on the calibration board GND.
    For offset measurement connect calibration board CHA pin on GND.
    """
    print TEXT['green'], __calibrate_adc_vin2_offset.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'EN_1V2__1'])
    ex_1v2_ref = eeprom_m24c02.read_write(0x08, '', 8, 'float')
    check_adc(2, ex_1v2_ref, 1, 1, 1)
    request_factor('Enter offset value (e.g: 9): ', 0x40, '{:<2}', 2)
    adc_offset_vin2 = int(eeprom_m24c02.read_write(0x40, '', 2, 'float'))
    check_adc(2, ex_1v2_ref, adc_offset_vin2, 1, 1)
    display_eeprom_content()
Exemplo n.º 6
0
def __set_dac_for_3v75():
    """DAC setup.

    SETUP: Connect M1K on the calibration board.
    Measure voltage value on R38 on the M1K.
    """
    print TEXT['green'], __set_dac_for_3v75.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_2__1', 'EN_1V2__1'])
    request_factor('Enter DAC command value (e.g: 9278): ', 0x25, '{:<4}', 4)
    msb_dac_srs_3v75 = int(eeprom_m24c02.read_write(0x25, '', 2, 'hex'), 16)
    lsb_dac_srs_3v75 = int(eeprom_m24c02.read_write(0x27, '', 2, 'hex'), 16)
    display_eeprom_content()
    dac_srs_3v75_cmd = [msb_dac_srs_3v75, lsb_dac_srs_3v75]
    dac_ad5647r.set_output(dac_srs_3v75_cmd)
Exemplo n.º 7
0
def __calibrate_adc_vin0_gain_neg():
    """Calibrate ADC VIN0.

    SETUP: Connect between M1K and calibration board
    channel A pins a DMM to measure current.
    """
    print TEXT['green'], __calibrate_adc_vin0_gain_neg.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    adc_offset_neg = int(eeprom_m24c02.read_write(0x80, '', 3, 'hex'), 16)
    check_adc_csa(adc_offset_neg, 1, 1)
    request_factor('Enter adc current hexa value (e.g: 41A): ', 0x85, '{:<3}',
                   3)
    display_eeprom_content()
    request_factor('Enter current value (e.g: -.10000)', 0x89, '{:<6}', 7)
    adc_gain_neg = int(eeprom_m24c02.read_write(0x85, '', 3, 'hex'), 16)
    i_gain_neg = eeprom_m24c02.read_write(0x89, '', 7, 'float')
    check_adc_csa(adc_offset_neg, adc_gain_neg, i_gain_neg)
    display_eeprom_content()
Exemplo n.º 8
0
def predetermine_resistance(polarity):
    """Calculate resistance besed on ADC measurements after calibration."""
    ex_1v2_ref = eeprom_m24c02.read_write(0x08, '', 8, 'float')

    adc_offset_vin3 = int(eeprom_m24c02.read_write(0x50, '', 2, 'float'))
    adc_scale_vin3 = eeprom_m24c02.read_write(0x53, '', 6, 'float')
    adc_gain_vin3 = eeprom_m24c02.read_write(0x5A, '', 6, 'float')
    adc_params_3 = [ex_1v2_ref, adc_offset_vin3, adc_scale_vin3, adc_gain_vin3]

    adc_offset_vin2 = int(eeprom_m24c02.read_write(0x40, '', 2, 'float'))
    adc_scale_vin2 = eeprom_m24c02.read_write(0x43, '', 6, 'float')
    adc_gain_vin2 = eeprom_m24c02.read_write(0x4A, '', 6, 'float')
    adc_params_2 = [ex_1v2_ref, adc_offset_vin2, adc_scale_vin2, adc_gain_vin2]

    adc_offset_poz = int(eeprom_m24c02.read_write(0x70, '', 3, 'hex'), 16)
    adc_gain_poz = int(eeprom_m24c02.read_write(0x75, '', 3, 'hex'), 16)
    i_gain_poz = eeprom_m24c02.read_write(0x7A, '', 6, 'float')

    adc_offset_neg = int(eeprom_m24c02.read_write(0x80, '', 3, 'hex'), 16)
    adc_gain_neg = int(eeprom_m24c02.read_write(0x85, '', 3, 'hex'), 16)
    i_gain_neg = eeprom_m24c02.read_write(0x89, '', 7, 'float')

    if polarity == 'poz':
        ref_2v5_srs = adc_ad7091r5.voltage_input(3, adc_params_3, 1000)[0]
        chx_voltage_srs = adc_ad7091r5.voltage_input(2, adc_params_2, 1000)[0]
        current_chx_poz = adc_ad7091r5.current_value(adc_offset_poz,
                                                     adc_gain_poz, i_gain_poz,
                                                     1000)[0]
        voltage = chx_voltage_srs + 0.022 - ref_2v5_srs
        resistance_srs = voltage / current_chx_poz
        print(resistance_srs)

    if polarity == 'neg':
        ref_2v5_snc = adc_ad7091r5.voltage_input(3, adc_params_3, 1000)[0]
        chx_voltage_snc = adc_ad7091r5.voltage_input(2, adc_params_2, 1000)[0]
        current_chx_neg = adc_ad7091r5.current_value(adc_offset_neg,
                                                     adc_gain_neg, i_gain_neg,
                                                     1000)[0]
        voltage = chx_voltage_snc - 0.027 - ref_2v5_snc
        resistance_snc = voltage / current_chx_neg
        print(resistance_snc)
Exemplo n.º 9
0
# Switch configuration between calibration and verification steps
RESTART_VERIFICATION = 0

# Verification status list for each step
# If each element of this list has 'True' value
# the M1K LED will be green else red
STATUS = []
STATUS_VALUES = []

# Stop script execution until user press ENTER
BRAKE_SCRIPT = False

# Read from EEPROM parameters used to
# calibrate current measurement using CSA and ADC
ADC_OFFSET_POZ = int(eeprom_m24c02.read_write(0x70, '', 3, 'hex'), 16)
ADC_GAIN_POZ = int(eeprom_m24c02.read_write(0x75, '', 3, 'hex'), 16)
I_GAIN_POZ = eeprom_m24c02.read_write(0x7A, '', 6, 'float')

ADC_OFFSET_NEG = int(eeprom_m24c02.read_write(0x80, '', 3, 'hex'), 16)
ADC_GAIN_NEG = int(eeprom_m24c02.read_write(0x85, '', 3, 'hex'), 16)
I_GAIN_NEG = eeprom_m24c02.read_write(0x89, '', 7, 'float')

# Tolerance values for all measurement
TOLERANCE_VOLTAGE = 0.011
TOLERANCE_CURRENT = 0.004

# Read from EEPROM External 2V5 and 1V2 references value
EX_2V5_REF = eeprom_m24c02.read_write(0x00, '', 6, 'float')
EX_1V2_REF = eeprom_m24c02.read_write(0x08, '', 8, 'float')
Exemplo n.º 10
0
DO_NOT_GET_M1K_2V5_VAL = False

# Flags to perform calibration step by step by next ORDER_INDEX:
# Measure voltage, Source voltage, Measure current and then Source current
FIRST_STAGE = False
SECOND_STAGE = False
THIRD_STAGE = True
FOURTH_STAGE = False

# Stop script execution until user press ENTER
BRAKE_SCRIPT = False

# PARAMETERS_USED_TO_CHECK_MEASURE_CURRENT_PERFORMANCES_AFTER_CALIBRATION___
# Read from EEPROM resistor value when channel A or B
# source or sink current
R_CH_SRS = eeprom_m24c02.read_write(0x10, '', 8, 'float')
R_CH_SNK = eeprom_m24c02.read_write(0x18, '', 8, 'float')
# Voltage setpoints for positive and
# negative current when M1K is in SVMI mode
SVMI_SETPOINT_POZ = 3.85
SVMI_SETPOINT_NEG = 1.15
# Voltage offsets between CHA and CHB
# caused by the voltage drop on the connector
COMP_POZ = eeprom_m24c02.read_write(0x61, '', 6, 'float')
COMP_NEG = eeprom_m24c02.read_write(0x68, '', 7, 'float')

USB = LED(12)
if __name__ == '__main__':
    USB.off()
    sleep(2)
    USB.on()
Exemplo n.º 11
0
# If list has 4 elements this represents [CH_A_V, CH_A_I, CH_B_V, CH_B_I]
CHX_2V5_EX_REF_RAW = [None] * 2
CHX_V_I_GND_RAW = [None] * 4

# Flags to perform calibration step by step by next ORDER_INDEX:
# Measure voltage, Source voltage, Measure current and then Source current
FIRST_STAGE = True
SECOND_STAGE = False
THIRD_STAGE = False
FOURTH_STAGE = False

# Stop script execution until user press ENTER
BRAKE_SCRIPT = False

# Read from EEPROM External 2V5 and 1V2 references value
EX_2V5_REF = eeprom_m24c02.read_write(0x00, '', 6, 'float')
EX_1V2_REF = eeprom_m24c02.read_write(0x08, '', 8, 'float')

USB = LED(12)
if __name__ == '__main__':
    USB.on()
    sleep(2)

    if VIEW_DEBUG_MESSAGES:
        print eeprom_m24c02.read_memory_content()

    control_m1k.upload_firmware(sys.argv[1], 6, TEXT)

    USB.off()
    sleep(2)
    USB.on()