From fbbb3e297e60cfa4b93797a6361c758b4a8d4bbe Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 26 Apr 2003 16:23:04 +0000 Subject: [PATCH] fixed catching of unknown board name with NI drivers, fixed board name of daqcard-6062E, added dummy daqcard-6064E, changed some cb boards to use my favorite cal_binary(). --- comedi_calibrate/cb.c | 38 +++++++++++------------------ comedi_calibrate/cb64.c | 4 +-- comedi_calibrate/comedi_calibrate.c | 6 ++--- comedi_calibrate/ni.c | 9 ++++--- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/comedi_calibrate/cb.c b/comedi_calibrate/cb.c index 48bfd85..faa81df 100644 --- a/comedi_calibrate/cb.c +++ b/comedi_calibrate/cb.c @@ -700,7 +700,7 @@ static int cal_cb_pci_1xxx( calibration_setup_t *setup ) current_cal++; } - if( setup->da_subdev >= 0 ) + if( setup->da_subdev >= 0 && setup->do_output) { for( range = 0; range < num_ao_ranges; range++ ) { @@ -752,24 +752,19 @@ static int cal_cb_pci_1001( calibration_setup_t *setup ) ADC_GAIN, }; - cal1( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_COARSE ); - cal1_fine( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_COARSE ); - - cal1( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_FINE ); - cal1_fine( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_FINE ); - - cal1( setup, OBS_7V_RANGE_10V_BIP_1XXX, ADC_GAIN ); - cal1_fine( setup, OBS_7V_RANGE_10V_BIP_1XXX, ADC_GAIN ); + cal_binary( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_COARSE ); + cal_binary( setup, OBS_0V_RANGE_10V_BIP_1XXX, ADC_OFFSET_FINE ); + cal_binary( setup, OBS_7V_RANGE_10V_BIP_1XXX, ADC_GAIN ); - if( setup->da_subdev >= 0 ) + if( setup->da_subdev >= 0 && setup->do_output ) { - cal1( setup, OBS_DAC0_GROUND_1XXX, DAC0_OFFSET ); - cal1( setup, OBS_DAC0_HIGH_1XXX, DAC0_GAIN_COARSE ); - cal1( setup, OBS_DAC0_HIGH_1XXX, DAC0_GAIN_FINE ); + cal_binary( setup, OBS_DAC0_GROUND_1XXX, DAC0_OFFSET ); + cal_binary( setup, OBS_DAC0_HIGH_1XXX, DAC0_GAIN_COARSE ); + cal_binary( setup, OBS_DAC0_HIGH_1XXX, DAC0_GAIN_FINE ); - cal1( setup, OBS_DAC1_GROUND_1XXX, DAC1_OFFSET ); - cal1( setup, OBS_DAC1_HIGH_1XXX, DAC1_GAIN_COARSE ); - cal1( setup, OBS_DAC1_HIGH_1XXX, DAC1_GAIN_FINE ); + cal_binary( setup, OBS_DAC1_GROUND_1XXX, DAC1_OFFSET ); + cal_binary( setup, OBS_DAC1_HIGH_1XXX, DAC1_GAIN_COARSE ); + cal_binary( setup, OBS_DAC1_HIGH_1XXX, DAC1_GAIN_FINE ); } return 0; @@ -792,14 +787,9 @@ static int cal_cb_pci_1602_16( calibration_setup_t *setup ) ADC_PREGAIN_OFFSET, }; - cal1( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_PREGAIN_OFFSET ); - cal1_fine( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_PREGAIN_OFFSET ); - - cal1( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_POSTGAIN_OFFSET ); - cal1_fine( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_POSTGAIN_OFFSET ); - - cal1( setup, OBS_7V_RANGE_10V_BIP_1602_16, ADC_GAIN ); - cal1_fine( setup, OBS_7V_RANGE_10V_BIP_1602_16, ADC_GAIN ); + cal_binary( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_PREGAIN_OFFSET ); + cal_binary( setup, OBS_0V_RANGE_10V_BIP_1602_16, ADC_POSTGAIN_OFFSET ); + cal_binary( setup, OBS_7V_RANGE_10V_BIP_1602_16, ADC_GAIN ); return 0; } diff --git a/comedi_calibrate/cb64.c b/comedi_calibrate/cb64.c index b741dfa..d7948f7 100644 --- a/comedi_calibrate/cb64.c +++ b/comedi_calibrate/cb64.c @@ -834,7 +834,7 @@ static int cal_cb_pci_64xx( calibration_setup_t *setup ) update_caldac( setup, ADC_OFFSET_64XX, adc_offset_for_ao ); update_caldac( setup, ADC_GAIN_64XX, adc_gain_for_ao ); - for( i = 0; i < num_ao_ranges ; i++ ) + for( i = 0; i < num_ao_ranges && setup->do_output; i++ ) { prep_dac_caldacs_64xx( setup, 0, i ); @@ -999,7 +999,7 @@ static int cal_cb_pci_60xx( calibration_setup_t *setup ) update_caldac( setup, ADC_OFFSET_COARSE_60XX, adc_offset_coarse_for_ao ); update_caldac( setup, ADC_GAIN_FINE_60XX, adc_gain_fine_for_ao ); update_caldac( setup, ADC_GAIN_COARSE_60XX, adc_gain_coarse_for_ao ); - for( i = 0; i < num_ao_ranges ; i++ ) + for( i = 0; i < num_ao_ranges && setup->do_output; i++ ) { prep_dac_caldacs_60xx( setup, 0, i ); diff --git a/comedi_calibrate/comedi_calibrate.c b/comedi_calibrate/comedi_calibrate.c index 2612b60..db651ff 100644 --- a/comedi_calibrate/comedi_calibrate.c +++ b/comedi_calibrate/comedi_calibrate.c @@ -2,9 +2,6 @@ A little auto-calibration utility, for boards that support it. - Right now, it only supports NI E series boards, - but it should be easily portable. - A few things need improvement here: - current system gets "close", but doesn't do any fine-tuning @@ -267,10 +264,11 @@ void set_target( calibration_setup_t *setup, int obs,double target) setup->observables[obs].preobserve_insn.subdev, CR_CHAN( setup->observables[obs].preobserve_insn.chanspec ), CR_RANGE( setup->observables[obs].preobserve_insn.chanspec )); + assert( range ); maxdata = comedi_get_maxdata( setup->dev, setup->observables[obs].preobserve_insn.subdev, CR_CHAN(setup->observables[obs].preobserve_insn.chanspec)); - + assert( maxdata > 0 ); data = comedi_from_phys(target,range,maxdata); setup->observables[obs].preobserve_data[0] = data; diff --git a/comedi_calibrate/ni.c b/comedi_calibrate/ni.c index 55082ce..0f72586 100644 --- a/comedi_calibrate/ni.c +++ b/comedi_calibrate/ni.c @@ -103,7 +103,8 @@ static struct board_struct boards[]={ { "DAQCard-ai-16e-4", STATUS_DONE, cal_ni_daqcard_ai_16e_4, ni_setup_observables }, { "pci-6110", STATUS_DONE, cal_ni_pci_611x, ni_setup_observables_611x }, { "pci-6111", STATUS_DONE, cal_ni_pci_611x, ni_setup_observables_611x }, - { "DAQCard-6062e", STATUS_SOME, cal_ni_daqcard_6062e, ni_setup_observables }, + { "DAQCard-6062E", STATUS_SOME, cal_ni_daqcard_6062e, ni_setup_observables }, + { "DAQCard-6024E", STATUS_UNKNOWN, NULL, ni_setup_observables }, #if 0 // { "at-mio-16de-10", cal_ni_unknown }, { "at-mio-64e-3", cal_ni_16e_1 }, @@ -120,7 +121,6 @@ static struct board_struct boards[]={ // { "pci-6713", cal_ni_unknown }, // { "pxi-6070e", cal_ni_unknown }, // { "pxi-6052e", cal_ni_unknown }, -// { "DAQCard-6024e", cal_ni_unknown }, #endif }; #define n_boards (sizeof(boards)/sizeof(boards[0])) @@ -162,7 +162,10 @@ enum reference_sources { int ni_setup( calibration_setup_t *setup , const char *device_name ) { - ni_setup_board( setup, device_name ); + int retval; + + retval = ni_setup_board( setup, device_name ); + if( retval < 0 ) return retval; setup_caldacs( setup, setup->caldac_subdev ); return 0; -- 2.26.2