Ejemplo n.º 1
0
def default_set(default):
    """Reset to default."""
    print TEXT['green'], default_set.__doc__, TEXT['default']
    settings = [0.0, default, None]
    eeprom_m24c02.read_memory_content()
    ioxp_adp5589.gpo_set_ac([""])
    return settings
Ejemplo 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()
Ejemplo 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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
def __calibrate_adc_vin0_offset_poz():
    """SETUP: Connect M1K GND on the calibration board GND."""
    print TEXT['green'], \
        __calibrate_adc_vin0_offset_poz.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['EN_1V2__1'])
    check_adc_csa(0, 1, 1)
    request_factor('Enter offset hexa value (e.g: 757): ', 0x70, '{:<3}', 3)
    display_eeprom_content()
Ejemplo n.º 6
0
def source_0v8(args, text):
    """SOURCE CHA/B 0v8.

    Connect channel A or B at 1 Mega load and enable ADC external reference
    Set channel A or B to source reference voltage and get samples
    Set again channel A or B to source reference voltage
    and measure sourced voltage with external ADC
    Optional is possible to generate plot images and display debug messages
    Compare voltage difference between measurement and reference
    to be in reference range then print PASS or FAIL message
    """
    if args['restart_verification'] == 0:
        ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_3__1', 'EN_1V2__1'])
    if args['restart_verification'] == 1:
        ioxp_adp5589.gpo_set_ac(['GPIO_7__1', 'GPIO_3__1', 'EN_1V2__1'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['srs_0v8_setpoint'], global_.Mode.HI_Z,
                       args['device'])
    control_m1k.get_samples_find_average(args['device'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['srs_0v8_setpoint'], global_.Mode.HI_Z,
                       args['device'])
    adc_meas = adc_ad7091r5.voltage_input(2, args['calibration_factors_vin2'],
                                          args['adc_samples'])
    if args['brake_script']:
        debug.add_break_point(text['orange'] +
                              'Measure sourced 0v8 with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    if args['create_plots']:
        debug.plot(str(args['device_id'] + '/Performance'),
                   '5__P__CH_' + args['channel_name'] + '_source_0V8',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print '\n', 'ADC measurement', adc_meas, \
            'tolerance', args['tolerance_voltage']
    if abs(adc_meas[0] - args['srs_0v8_setpoint']) <= \
            args['tolerance_voltage']:
        debug_message = text['green'] + 'Source  ' + \
            '{0:+.4f}'.format(args['srs_0v8_setpoint']) + \
            ' [V] CH_' + args['channel_name'] + ' PASS' + text['default']
        args['status'].append(True)
        args['status_values'].append('{0:.4f}'.format(adc_meas[0]))
    else:
        debug_message = text['red'] + 'Source  ' + \
            '{0:+.4f}'.format(args['srs_0v8_setpoint']) + \
            ' [V] CH_' + args['channel_name'] + ' FAIL' + text['default']
        args['status'].append(False)
        args['status_values'].append('{0:.4f}'.format(adc_meas[0]))
        if not args['enable_debug_mode']:
            print debug_message
            exit(1)
    if args['view_short_debug_messages']:
        print debug_message
    return args['status']
Ejemplo n.º 7
0
def positive_current_measurement(args, text):
    """MEASURE POSITIVE CURRENT CHA/B.

    Connect channel A or B at Load and enable ADC external reference
    Set channel A or B to source voltage setpoint and get samples
    Set again channel A or B to source voltage setpoint
    and measure resulted current with external ADC and CSA
    Optional is possible to generate plot images and display debug messages
    Compare current difference between measurement and reference
    to be in reference range then print PASS or FAIL message
    """
    if args['restart_verification'] == 0:
        ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    if args['restart_verification'] == 1:
        ioxp_adp5589.gpo_set_ac(['GPIO_7__1', 'GPIO_1__1', 'EN_1V2__1'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['svmi_setpoint_poz'], global_.Mode.HI_Z,
                       args['device'])
    control_m1k.get_samples_find_average(args['device'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['svmi_setpoint_poz'], global_.Mode.HI_Z,
                       args['device'])
    adc_meas = adc_ad7091r5.current_value(args['adc_offset_poz'],
                                          args['adc_gain_poz'],
                                          args['i_gain_poz'],
                                          args['adc_samples'])[0]
    if args['create_plots']:
        debug.plot(
            str(args['device_id'] + '/Performance'),
            '8__P__CH_' + args['channel_name'] + '_measure_positive_current',
            global_.CHX_V_I[4], str(args['channel_index'] * 2 + 1))
    if args['view_debug_messages']:
        print '\n', global_.CHX_V_I[args['channel_index'] * 2 + 1], '-', \
            adc_meas, '=> abs():', \
            abs(global_.CHX_V_I[args['channel_index'] * 2 + 1] - adc_meas), \
            'should be <=', abs(adc_meas * args['tolerance_current'])
    if abs(global_.CHX_V_I[args['channel_index'] * 2 + 1] - adc_meas) <= \
            abs(adc_meas * args['tolerance_current']):
        debug_message = text['green'] + 'Measure ' + \
            '{0:+.4f}'.format(adc_meas) + ' [A] CH_' + \
            args['channel_name'] + ' PASS' + text['default']
        args['status'].append(True)
        args['status_values'].append('{0:+.4f}'.format(adc_meas))
    else:
        debug_message = text['red'] + 'Measure ' + \
            '{0:+.4f}'.format(adc_meas) + ' [A] CH_' + \
            args['channel_name'] + ' FAIL' + text['default']
        args['status'].append(False)
        args['status_values'].append('{0:+.4f}'.format(adc_meas))
        if not args['enable_debug_mode']:
            print debug_message
            exit(1)
    if args['view_short_debug_messages']:
        print debug_message
    return args['status']
Ejemplo n.º 8
0
def __calculate_voltage_drop_1v25():
    """Measure switch voltage drop.

    SETUP: Connect M1K on the calibration board.
    Measure voltage value on connector and R8 on the M1K.
    """
    print TEXT['green'], __calculate_voltage_drop_1v25.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_7__1', 'GPIO_1__1'])
    request_factor('Enter voltage drop value (e.g: -0.0260): ', 0x68, '{:<7}',
                   7)
    display_eeprom_content()
Ejemplo n.º 9
0
def __calculate_resistance_sink():
    """Calculate resistance when sink.

    SETUP: Measure voltage across channel A and M1K 2V5 reference.
    Measure current between M1K and calibration board channel A pins.
    """
    print TEXT['green'], __calculate_resistance_sink.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    predetermine_resistance('neg')
    request_factor('Enter sink resistance value (e.g: 13.3485): ', 0x19,
                   '{:<7}', 7)
    display_eeprom_content()
Ejemplo n.º 10
0
def measure_chx_external_2v5(args, text):
    """MEASURE CHA/B EXTERNAL 2V5.

    Disconnect channels from GND and 2V5 using internal M1K switches
    Connect channel A or B at external reference
    Set both channels to HI_Z mode and get samples
    Get voltage mean value for current channel
    Display FAIL or PASS message, if FAIL exit
    Optional is possible to generate plot images and display debug messages
    """
    control_m1k.set_switches_chs_2v5_gnd('open', 'open', 'open', 'open',
                                         args['device'])
    if args['restart_calibration'] == 0:
        ioxp_adp5589.gpo_set_ac(['GPIO_0__1', 'GPIO_8__1'])
    if args['restart_calibration'] == 1:
        ioxp_adp5589.gpo_set_ac(['GPIO_0__1', 'GPIO_7__1'])
    control_m1k.channels_in_hi_z()
    control_m1k.get_external_2v5_samples(args['device'])
    if args['brake_script']:
        debug.add_break_point(text['orange'] +
                              'Measure external 2V5 with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    args['chx_2v5_ex_ref_raw'][args['channel_index']] = \
        global_.CHX_2V5_EX_REF[args['channel_index'] * 2]
    if 2.4 > global_.CHX_2V5_EX_REF[args['channel_index'] * 2] < 2.6:
        print text['red'] + 'FAIL measure external 2.5V channel ' + \
            args['channel_name'] + ':\t' + \
            str(global_.CHX_2V5_EX_REF[args['channel_index'] * 2]) + \
            text['default']
        exit(1)
    else:
        print text['green'] + 'PASS measure reference channel ' + \
            args['channel_name'] + ': ' + \
            str('{0:.4f}'.format(
                global_.CHX_2V5_EX_REF[args['channel_index'] * 2])) + \
            text['default']
    if args['create_plots']:
        debug.plot(str(args['device_id'] + '/Calibration'),
                   '1__CH_' + args['channel_name'] + '_measure_External_2V5',
                   global_.CHX_2V5_EX_REF[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print 'ST_0.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_2v5_ex_ref_raw']
    calibration_file.write_in_log(
        args['log_name'], 'a+', 'Measure external 2V5 with channel ' +
        args['channel_name'] + ' -> [chx_2v5_ex_ref_raw]')
    calibration_file.write_in_log(args['log_name'], 'a+',
                                  args['chx_2v5_ex_ref_raw'], '\n')
    return args['chx_2v5_ex_ref_raw']
Ejemplo n.º 11
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)
Ejemplo n.º 12
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()
Ejemplo n.º 13
0
def voltage_measurement_2v5(args, text):
    """MEASURE CHA/B EXTERNAL REFERENCE 2V5.

    Disconnect channels from GND and 2V5 using internal M1K switches
    Connect channel A or B at 2V5 external reference
    Set both channels to high impedance mode and get samples
    Optional is possible to generate plot images and display debug messages
    Compare voltage difference between measurement and reference
    to be in reference range then print PASS or FAIL message
    """
    control_m1k.set_switches_chs_2v5_gnd('open', 'open', 'open', 'open',
                                         args['device'])
    if args['restart_verification'] == 0:
        ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_0__1', 'EN_1V2__1'])
    if args['restart_verification'] == 1:
        ioxp_adp5589.gpo_set_ac(['GPIO_7__1', 'GPIO_0__1', 'EN_1V2__1'])
    control_m1k.channels_in_hi_z()
    control_m1k.get_samples_find_average(args['device'])
    adc_meas = \
        adc_ad7091r5.voltage_input(
            2, args['calibration_factors_vin2'],
            args['adc_samples'])[0]
    if args['create_plots']:
        debug.plot(str(args['device_id'] + '/Performance'),
                   '1__P__CH_' + args['channel_name'] + '_measure_2V5',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print '\n', global_.CHX_V_I[args['channel_index'] * 2], '-', \
            adc_meas, '=> abs():', \
            abs(global_.CHX_V_I[args['channel_index'] * 2] - adc_meas), \
            'should be <=', adc_meas * args['tolerance_voltage']
    if abs(global_.CHX_V_I[args['channel_index'] * 2] - adc_meas) <= \
            adc_meas * args['tolerance_voltage']:
        debug_message = text['green'] + 'Measure ' + \
            '{0:+.4f}'.format(adc_meas) + ' [V] CH_' + \
            args['channel_name'] + ' PASS' + text['default']
        args['status'].append(True)
        args['status_values'].append('{0:.4f}'.format(adc_meas))
    else:
        debug_message = text['red'] + 'Measure ' + \
            '{0:+.4f}'.format(adc_meas) + ' [V] CH_' + \
            args['channel_name'] + ' FAIL' + text['default']
        args['status'].append(False)
        args['status_values'].append('{0:.4f}'.format(adc_meas))
        if not args['enable_debug_mode']:
            print debug_message
            exit(1)
    if args['view_short_debug_messages']:
        print debug_message
    return args['status']
Ejemplo n.º 14
0
def source_chx_0a_current(args, text):
    """SOURCE CHA/B 0A CURRENT.

    Connect channel A or B at Load, keep M1K powered on, enable REF ADC
    Source 0 A current and get samples
    Measure resulted voltage using channel in HI_Z mode
    Get voltage and current mean value for current channel
    Optional is possible to generate plot images and display debug messages
    """
    if args['restart_calibration'] == 6:
        ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    if args['restart_calibration'] == 7:
        ioxp_adp5589.gpo_set_ac(['GPIO_7__1', 'GPIO_1__1', 'EN_1V2__1'])
    control_m1k.source(args['channel_index'], global_.Mode.SIMV, 0.0,
                       global_.Mode.HI_Z, args['device'])
    control_m1k.get_samples_find_average(args['device'])
    if args['brake_script']:
        control_m1k.source(args['channel_index'], global_.Mode.SIMV, 0.0,
                           global_.Mode.HI_Z, args['device'])
        debug.add_break_point(text['orange'] + 'Source 0A with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    if args['restart_calibration'] == 6:
        args['m1k_2v5'][args['channel_index'] * 5 + 2] = global_.CHX_V_I[2]
    if args['restart_calibration'] == 7:
        args['m1k_2v5'][args['channel_index'] * 5 + 2] = global_.CHX_V_I[0]
    args['chx_s0a_raw'][args['channel_index'] *
                        2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_s0a_raw'][args['channel_index'] * 2 +
                        1] = global_.CHX_V_I[args['channel_index'] * 2 + 1]
    if args['create_plots']:
        debug.plot(str(args['device_id'] + '/Calibration'),
                   '7__CH_' + args['channel_name'] + '_measure_0A_current',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2 + 1))
    if args['view_debug_messages']:
        print 'ST_7.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_s0a_raw'], '\n\t' + \
            text['purple'] + 'M1K_2V5' + text['default'], \
            args['m1k_2v5']
    calibration_file.write_in_log(
        args['log_name'], 'a+', 'Source 0A with channel ' +
        args['channel_name'] + ' -> [chx_s0a_raw] [m1k_2v5]')
    calibration_file.write_in_log(args['log_name'], 'a+', args['chx_s0a_raw'])
    calibration_file.write_in_log(args['log_name'], 'a+', args['m1k_2v5'],
                                  '\n')
    return args['chx_s0a_raw'], args['m1k_2v5']
Ejemplo n.º 15
0
def __measure_external_2v5_1v2():
    """Measure external references.

    SETUP: Connect M1K on the calibration board.
    Measure 2.5 V reference value on R38 on the M1K.
    Measure 1.2 V reference value on calibration
    board referenced on the ADC GND.
    """
    print TEXT['green'], __measure_external_2v5_1v2.__doc__, TEXT['default']
    ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_0__1', 'EN_1V2__1'])
    request_factor('Enter 2.5 V reference value (e.g: 2.4990): ', 0x00,
                   '{:<6}', 6)
    display_eeprom_content()
    request_factor('Enter 1.2 V reference value (e.g: 1.2009): ', 0x08,
                   '{:<6}', 6)
    display_eeprom_content()
Ejemplo n.º 16
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()
Ejemplo n.º 17
0
def measure_chx_gnd(args, text):
    """MEASURE CHA/B GND.

    Disconnect M1K from calibration board
    Connect channels at GND using internal M1K switches
    Set both channels to high impedance mode and get samples
    Get voltage and current mean value for current channel
    Optional is possible to generate plot images and display debug messages
    """
    ioxp_adp5589.gpo_set_ac([''])
    control_m1k.set_switches_chs_2v5_gnd('open', 'close', 'open', 'close',
                                         args['device'])
    control_m1k.channels_in_hi_z()
    control_m1k.get_samples_find_average(args['device'])
    if args['brake_script']:
        debug.add_break_point(text['orange'] +
                              'Measure GND value with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    args['chx_v_i_gnd_raw'][args['channel_index'] *
                            2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_v_i_gnd_raw'][args['channel_index'] * 2 +
                            1] = global_.CHX_V_I[args['channel_index'] * 2 + 1]
    if args['create_plots']:
        debug.plot(str(args['device_id'] + '/Calibration'),
                   '2__CH_' + args['channel_name'] + '_measure_GND',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print 'ST_1.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_v_i_gnd_raw']
    calibration_file.write_in_log(
        args['log_name'], 'a+', 'Measure GND value with channel ' +
        args['channel_name'] + ' -> [chx_v_i_gnd_raw]')
    calibration_file.write_in_log(args['log_name'], 'a+',
                                  args['chx_v_i_gnd_raw'], '\n')
    return args['chx_v_i_gnd_raw']
Ejemplo n.º 18
0
        # Grab the first device from the session.
        DEV = SESSION.devices[0]

        # Set both channels to source voltage, measure current mode.
        CHAN_A = DEV.channels['A']
        CHAN_B = DEV.channels['B']
        CHAN_A.mode = Mode.HI_Z
        CHAN_B.mode = Mode.HI_Z

        # Start a continuous session.
        SESSION.start(0)
        NUM_SAMPLES = SESSION.queue_size + 1

        READY = False
        COUNTER = 0
        ioxp_adp5589.gpo_set_ac([""])
        adc_ad7091r5.init()
        dac_ad5647r.init()
        menu()
        while True:
            CH_A_VOLTAGE, CH_A_CURRENT, CH_B_VOLTAGE, CH_B_CURRENT = \
                [0.0], [0.0], [0.0], [0.0]
            SETTINGS_M1K = check_input(
                TEXT['purple'] + 'Step: ' + TEXT['default'], 1, Mode.HI_Z,
                COUNTER)
            if SETTINGS_M1K is not None:
                COUNTER = SETTINGS_M1K[len(SETTINGS_M1K) - 1]
                VALID_SETPOINT = SETTINGS_M1K
                set_channel_a_mode(SETTINGS_M1K[1], VALID_SETPOINT[0])
                request_info(COUNTER, COMMANDS)
Ejemplo n.º 19
0
def measure_chx_negative_current(args, text):
    """MEASURE CHA/B NEGATIVE CURRENT.

    Connect channel A or B at Load, keep M1K powered on, enable REF ADC
    Source a voltage to result a negative current and get samples
    Measure 2V5 reference using channel in SVMI mode
    Source a voltage to result same negative current and get samples
    Measure sourced voltage using channel in HI_Z mode
    Get voltage and current mean value for current channel
    Optional is possible to generate plot images and display debug messages
    """
    if args['restart_calibration'] == 4:
        ioxp_adp5589.gpo_set_ac(['GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    if args['restart_calibration'] == 5:
        ioxp_adp5589.gpo_set_ac(['GPIO_7__1', 'GPIO_1__1', 'EN_1V2__1'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['svmi_setpoint_neg'], global_.Mode.HI_Z,
                       args['device'])
    control_m1k.get_samples_find_average(args['device'])
    if args['brake_script']:
        control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                           args['svmi_setpoint_neg'], global_.Mode.HI_Z,
                           args['device'])
        debug.add_break_point(
            text['orange'] +
            'Measure negative current and M1K 2V5 with channel ' +
            args['channel_name'] + ' ... Press ENTER to continue... ' +
            text['default'])
    if args['restart_calibration'] == 4:
        args['m1k_2v5'][args['channel_index'] * 5 + 1] = global_.CHX_V_I[2]
    if args['restart_calibration'] == 5:
        args['m1k_2v5'][args['channel_index'] * 5 + 1] = global_.CHX_V_I[0]
    ioxp_adp5589.gpo_set_ac(
        ['GPIO_7__1', 'GPIO_8__1', 'GPIO_1__1', 'EN_1V2__1'])
    control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                       args['svmi_setpoint_neg'], global_.Mode.HI_Z,
                       args['device'], args['do_not_get_m1k_2v5_val'])
    control_m1k.get_samples_find_average(args['device'])
    if args['brake_script']:
        control_m1k.source(args['channel_index'], global_.Mode.SVMI,
                           args['svmi_setpoint_neg'], global_.Mode.HI_Z,
                           args['device'], args['do_not_get_m1k_2v5_val'])
        debug.add_break_point(
            text['orange'] +
            'Measure negative current and M1K CHX with channel ' +
            args['channel_name'] + ' ... Press ENTER to continue... ' +
            text['default'])
    if args['restart_calibration'] == 4:
        args['m1k_hi_z_chx'][args['channel_index'] * 2 +
                             1] = global_.CHX_V_I[2] + args['comp_neg']
    if args['restart_calibration'] == 5:
        args['m1k_hi_z_chx'][args['channel_index'] * 2 +
                             1] = global_.CHX_V_I[0] + args['comp_neg']
    args['chx_s0v_raw'][args['channel_index'] *
                        2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_s0v_raw'][args['channel_index'] * 2 +
                        1] = global_.CHX_V_I[args['channel_index'] * 2 + 1]
    if args['create_plots']:
        debug.plot(
            str(args['device_id'] + '/Calibration'),
            '6__CH_' + args['channel_name'] + '_measure_negative_current',
            global_.CHX_V_I[4], str(args['channel_index'] * 2 + 1))
    if args['view_debug_messages']:
        print 'ST_6.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_s0v_raw'], '\n\t' + \
            text['purple'] + 'M1K_2V5' + \
            text['default'], args['m1k_2v5'], '\n\t' + \
            text['orange'] + 'M1K_HI_Z_CHX' + text['default'], \
            args['m1k_hi_z_chx']
    calibration_file.write_in_log(
        args['log_name'], 'a+',
        'Measure negative current and M1K CHX with channel ' +
        args['channel_name'] + ' -> [chx_s0v_raw] [m1k_hi_z_chx] [m1k_2v5]')
    calibration_file.write_in_log(args['log_name'], 'a+', args['chx_s0v_raw'])
    calibration_file.write_in_log(args['log_name'], 'a+', args['m1k_hi_z_chx'])
    calibration_file.write_in_log(args['log_name'], 'a+', args['m1k_2v5'],
                                  '\n')
    return args['chx_s0v_raw'], args['m1k_hi_z_chx'], args['m1k_2v5']