예제 #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 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']
예제 #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 source_chx_0v_without_load(args, text):
    """SOURCE CHA/B 0V WITHOUT LOAD.

    Disconnect channels from GND and 2V5 using internal M1K switches
    Source 0V using channel A or B 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.set_switches_chs_2v5_gnd('open', 'open', 'open', 'open',
                                         args['device'])
    control_m1k.source_0v(args['channel_index'], global_.Mode.SVMI, 0.0,
                          global_.Mode.HI_Z, args['device'])
    control_m1k.get_samples_find_average(args['device'])
    if args['brake_script']:
        control_m1k.source_0v(args['channel_index'], global_.Mode.SVMI, 0.0,
                              global_.Mode.HI_Z, args['device'])
        debug.add_break_point(text['orange'] + 'Source 0V with channel ' +
                              args['channel_name'] +
                              ' ... Press ENTER to continue... ' +
                              text['default'])
    args['chx_f0v_raw'][args['channel_index'] *
                        2] = global_.CHX_V_I[args['channel_index'] * 2]
    args['chx_f0v_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'),
                   '3__CH_' + args['channel_name'] + '_source_0V',
                   global_.CHX_V_I[4], str(args['channel_index'] * 2))
    if args['view_debug_messages']:
        print 'ST_3.', args['channel_name'], \
            text['turquoise'] + 'Mean of buffer data:' + text['default'], \
            args['chx_f0v_raw']
    calibration_file.write_in_log(
        args['log_name'], 'a+',
        'Source 0V with channel ' + args['channel_name'] + ' -> [chx_f0v_raw]')
    calibration_file.write_in_log(args['log_name'], 'a+', args['chx_f0v_raw'],
                                  '\n')
    return args['chx_f0v_raw']
예제 #5
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']
예제 #6
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']
예제 #7
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']