示例#1
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']
示例#2
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']
示例#3
0
def source_chx_negative_current(args, text):
    """SOURCE CHA/B NEGATIVE CURRENT.

    Connect channel A or B at Load, keep M1K powered on, enable REF ADC
    Source a negative 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
    """
    control_m1k.source(args['channel_index'], global_.Mode.SIMV,
                       args['srs_i_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.SIMV,
                           args['srs_i_setpoint_neg'], global_.Mode.HI_Z,
                           args['device'])
        debug.add_break_point(text['orange'] +
                              'Source negative current with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    if args['restart_calibration'] == 6:
        args['m1k_2v5'][args['channel_index'] * 5 + 4] = global_.CHX_V_I[2]
    if args['restart_calibration'] == 7:
        args['m1k_2v5'][args['channel_index'] * 5 + 4] = global_.CHX_V_I[0]
    args['chx_s_neg_raw'][args['channel_index'] *
                          2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_s_neg_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'),
            '9__CH_' + args['channel_name'] + '_source_negative_current',
            global_.CHX_V_I[4], str(args['channel_index'] * 2 + 1))
    if args['view_debug_messages']:
        print 'ST_9.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_s_neg_raw'], '\n\t' + \
            text['purple'] + 'M1K_2V5' + text['default'], \
            args['m1k_2v5']
    calibration_file.write_in_log(
        args['log_name'], 'a+', 'Source negative current with channel ' +
        args['channel_name'] + ' -> [chx_s_neg_raw] [m1k_2v5]')
    calibration_file.write_in_log(args['log_name'], 'a+',
                                  args['chx_s_neg_raw'])
    calibration_file.write_in_log(args['log_name'], 'a+', args['m1k_2v5'],
                                  '\n')
    return args['chx_s_neg_raw'], args['m1k_2v5']
示例#4
0
def negative_current_source(args, text):
    """SOURCE NEGATIVE CURRENT CHA/B.

    Set channel A or B to source reference current and get samples
    Set again channel A or B to source reference current
    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
    """
    control_m1k.source(args['channel_index'], global_.Mode.SIMV,
                       args['srs_i_setpoint_neg'], global_.Mode.HI_Z,
                       args['device'])
    control_m1k.get_samples_find_average(args['device'])
    control_m1k.source(args['channel_index'], global_.Mode.SIMV,
                       args['srs_i_setpoint_neg'], global_.Mode.HI_Z,
                       args['device'])
    adc_meas = adc_ad7091r5.current_value(args['adc_offset_neg'],
                                          args['adc_gain_neg'],
                                          args['i_gain_neg'],
                                          args['adc_samples'])[0]
    if args['create_plots']:
        debug.plot(
            str(args['device_id'] + '/Performance'),
            '11__P__CH_' + args['channel_name'] + '_source_negative_current',
            global_.CHX_V_I[4], str(args['channel_index'] * 2 + 1))
    if args['view_debug_messages']:
        print '\n', 'adc_meas', adc_meas
    if abs(adc_meas - args['srs_i_setpoint_neg']) <= \
            abs(adc_meas * args['tolerance_current']):
        debug_message = text['green'] + 'Source  ' + \
            '{0:+.4f}'.format(args['srs_i_setpoint_neg']) + \
            ' [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'] + 'Source  ' + \
            '{0:+.4f}'.format(args['srs_i_setpoint_neg']) + \
            ' [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']
示例#5
0
def source_chx_2v5_without_load(args, text):
    """SOURCE CHA/B 2V5 WITHOUT LOAD.

    Source 2V5 using channel A or B without measuring M1K 2V5 and get samples
    Get voltage and current mean value for current channel
    Optional is possible to generate plot images and display debug messages
    """
    control_m1k.source(args['channel_index'], global_.Mode.SVMI, 2.5,
                       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, 2.5,
                           global_.Mode.HI_Z, args['device'],
                           args['do_not_get_m1k_2v5_val'])
        debug.add_break_point(text['orange'] + 'Source 2V5 with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    args['chx_f2v5_raw'][args['channel_index'] *
                         2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_f2v5_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'),
                   '4__CH_' + args['channel_name'] + '_source_2V5',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print 'ST_4.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_f2v5_raw']
    calibration_file.write_in_log(
        args['log_name'], 'a+', 'Source 2V5 with channel ' +
        args['channel_name'] + ' -> [chx_f2v5_raw]')
    calibration_file.write_in_log(args['log_name'], 'a+', args['chx_f2v5_raw'],
                                  '\n')
    return args['chx_f2v5_raw']
示例#6
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']