예제 #1
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']
예제 #2
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']
예제 #3
0
def voltage_measurement_3v75(args, text):
    """MEASURE CHA/B EXTERNAL 3V75.

    Set DAC to generate reference voltage
    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
    """
    dac_ad5647r.set_output(args['dac_srs_3v75_cmd'])
    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'),
                   '4__P__CH_' + args['channel_name'] + '_measure_3V75',
                   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']
예제 #4
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']