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']
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']
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']
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']
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']
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']
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']
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']
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']
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']