basic calibration of pci-das6025 works now, added 4020 calibration code
This commit is contained in:
parent
137fdba988
commit
a999ccefbc
4 changed files with 195 additions and 18 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
#define N_CALDACS 64
|
||||
#define N_OBSERVABLES 32
|
||||
#define PREOBSERVE_DATA_LEN 10
|
||||
|
||||
typedef struct{
|
||||
int subdev;
|
||||
|
@ -35,7 +36,7 @@ typedef struct{
|
|||
char *name;
|
||||
|
||||
comedi_insn preobserve_insn;
|
||||
lsampl_t preobserve_data;
|
||||
lsampl_t preobserve_data[ PREOBSERVE_DATA_LEN ];
|
||||
|
||||
comedi_insn observe_insn;
|
||||
|
||||
|
@ -78,7 +79,7 @@ extern int do_output;
|
|||
/* high level */
|
||||
|
||||
void observe( calibration_setup_t *setup );
|
||||
void preobserve( calibration_setup_t *setup, int obs);
|
||||
int preobserve( calibration_setup_t *setup, int obs);
|
||||
void observable_dependence( calibration_setup_t *setup, int obs);
|
||||
void measure_observable( calibration_setup_t *setup, int obs);
|
||||
void reset_caldacs( calibration_setup_t *setup);
|
||||
|
@ -113,7 +114,6 @@ void set_ao(comedi_t *dev,int subdev,int chan,int range,double value);
|
|||
void check_gain(int ad_chan,int range);
|
||||
double check_gain_chan(int ad_chan,int range,int cdac);
|
||||
|
||||
void (*do_cal)(void);
|
||||
void cal_ni_results(void);
|
||||
|
||||
/* helper functions */
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/*
|
||||
TODO:
|
||||
read calibration voltage targets from eeprom
|
||||
calibrate all possible ranges and save to file
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
|
@ -90,6 +95,7 @@ int cb_setup( calibration_setup_t *setup, const char *device_name )
|
|||
{
|
||||
if( !strcmp( devicename, boards[i].name ) )
|
||||
{
|
||||
setup->status = boards[i].status;
|
||||
return boards[i].setup( setup );
|
||||
break;
|
||||
}
|
||||
|
@ -140,14 +146,11 @@ int init_observables_60xx( calibration_setup_t *setup )
|
|||
comedi_insn tmpl, po_tmpl;
|
||||
observable *o;
|
||||
static const int ai_subdev = 0;
|
||||
lsampl_t cal_src_data[2];
|
||||
|
||||
memset( &po_tmpl, 0, sizeof(po_tmpl) );
|
||||
po_tmpl.insn = INSN_CONFIG;
|
||||
po_tmpl.n = 2;
|
||||
po_tmpl.subdev = ai_subdev;
|
||||
po_tmpl.data = cal_src_data;
|
||||
cal_src_data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
|
||||
memset( &tmpl, 0, sizeof(tmpl) );
|
||||
tmpl.insn = INSN_READ;
|
||||
|
@ -155,19 +158,23 @@ int init_observables_60xx( calibration_setup_t *setup )
|
|||
tmpl.subdev = ai_subdev;
|
||||
|
||||
o = setup->observables + 0;
|
||||
o->name = "ground calibration source, 10V bipolar range, ground reference";
|
||||
o->name = "ground calibration source, 10V bipolar range, differential referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 0;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK_FLAGS( 0, 0, AREF_GROUND, CR_ALT_SOURCE);
|
||||
o->observe_insn.chanspec = CR_PACK( 0, 0, AREF_DIFF);
|
||||
o->target = 0.0;
|
||||
|
||||
o = setup->observables + 1;
|
||||
o->name = "5V calibration source, 10V bipolar range, ground reference";
|
||||
o->name = "5V calibration source, 10V bipolar range, differential referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 2;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK_FLAGS( 0, 0, AREF_GROUND, CR_ALT_SOURCE);
|
||||
o->observe_insn.chanspec = CR_PACK( 0, 0, AREF_DIFF);
|
||||
o->target = 5.0;
|
||||
|
||||
setup->n_observables = 2;
|
||||
|
@ -177,6 +184,102 @@ int init_observables_60xx( calibration_setup_t *setup )
|
|||
|
||||
int init_observables_4020( calibration_setup_t *setup )
|
||||
{
|
||||
comedi_insn tmpl, po_tmpl;
|
||||
observable *o;
|
||||
static const int ai_subdev = 0;
|
||||
|
||||
memset( &po_tmpl, 0, sizeof(po_tmpl) );
|
||||
po_tmpl.insn = INSN_CONFIG;
|
||||
po_tmpl.n = 2;
|
||||
po_tmpl.subdev = ai_subdev;
|
||||
|
||||
memset( &tmpl, 0, sizeof(tmpl) );
|
||||
tmpl.insn = INSN_READ;
|
||||
tmpl.n = 1;
|
||||
tmpl.subdev = ai_subdev;
|
||||
|
||||
o = setup->observables + 0;
|
||||
o->name = "ground calibration source, ch 0, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 7;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 0, 0, AREF_GROUND);
|
||||
o->target = 0.0;
|
||||
|
||||
o = setup->observables + 1;
|
||||
o->name = "ground calibration source, ch 1, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 7;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 1, 0, AREF_GROUND);
|
||||
o->target = 0.0;
|
||||
|
||||
o = setup->observables + 2;
|
||||
o->name = "ground calibration source, ch 2, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 7;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 2, 0, AREF_GROUND);
|
||||
o->target = 0.0;
|
||||
|
||||
o = setup->observables + 3;
|
||||
o->name = "ground calibration source, ch 3, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 7;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 3, 0, AREF_GROUND);
|
||||
o->target = 0.0;
|
||||
|
||||
o = setup->observables + 4;
|
||||
o->name = "4.375V calibration source, ch 0, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 5;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 0, 0, AREF_GROUND);
|
||||
o->target = 4.375;
|
||||
|
||||
o = setup->observables + 5;
|
||||
o->name = "4.375V calibration source, ch 1, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 5;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 1, 0, AREF_GROUND);
|
||||
o->target = 4.375;
|
||||
|
||||
o = setup->observables + 6;
|
||||
o->name = "4.375V calibration source, ch 2, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 5;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 2, 0, AREF_GROUND);
|
||||
o->target = 4.375;
|
||||
|
||||
o = setup->observables + 7;
|
||||
o->name = "4.375V calibration source, ch 3, 5V bipolar range, ground referenced";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
|
||||
o->preobserve_insn.data[1] = 5;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec = CR_PACK( 3, 0, AREF_GROUND);
|
||||
o->target = 4.375;
|
||||
|
||||
setup->n_observables = 8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -187,11 +290,71 @@ int cal_cb_pci_64xx( calibration_setup_t *setup )
|
|||
|
||||
int cal_cb_pci_60xx( calibration_setup_t *setup )
|
||||
{
|
||||
enum caldacs_60xx
|
||||
{
|
||||
DAC0_OFFSET = 0,
|
||||
DAC0_GAIN,
|
||||
DAC1_OFFSET,
|
||||
DAC1_GAIN,
|
||||
ADC_OFFSET_FINE,
|
||||
ADC_OFFSET_COARSE,
|
||||
ADC_GAIN_COARSE,
|
||||
ADC_GAIN_FINE,
|
||||
};
|
||||
|
||||
cal1( setup, 0, ADC_OFFSET_COARSE );
|
||||
cal1_fine( setup, 0, ADC_OFFSET_COARSE );
|
||||
|
||||
cal1( setup, 0, ADC_OFFSET_FINE );
|
||||
cal1_fine( setup, 0, ADC_OFFSET_FINE );
|
||||
|
||||
cal1( setup, 1, ADC_GAIN_COARSE );
|
||||
cal1_fine( setup, 1, ADC_GAIN_COARSE );
|
||||
|
||||
cal1( setup, 1, ADC_GAIN_FINE );
|
||||
cal1_fine( setup, 1, ADC_GAIN_FINE );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cal_cb_pci_4020( calibration_setup_t *setup )
|
||||
{
|
||||
enum caldacs_4020
|
||||
{
|
||||
ADC0_OFFSET = 0,
|
||||
ADC1_OFFSET,
|
||||
ADC2_OFFSET,
|
||||
ADC3_OFFSET,
|
||||
ADC0_GAIN,
|
||||
ADC1_GAIN,
|
||||
ADC2_GAIN,
|
||||
ADC3_GAIN,
|
||||
};
|
||||
|
||||
cal1( setup, 0, ADC0_OFFSET );
|
||||
cal1_fine( setup, 0, ADC0_OFFSET );
|
||||
|
||||
cal1( setup, 1, ADC1_OFFSET );
|
||||
cal1_fine( setup, 1, ADC1_OFFSET );
|
||||
|
||||
cal1( setup, 2, ADC2_OFFSET );
|
||||
cal1_fine( setup, 2, ADC2_OFFSET );
|
||||
|
||||
cal1( setup, 3, ADC3_OFFSET );
|
||||
cal1_fine( setup, 3, ADC3_OFFSET );
|
||||
|
||||
cal1( setup, 4, ADC0_GAIN );
|
||||
cal1_fine( setup, 4, ADC0_GAIN );
|
||||
|
||||
cal1( setup, 5, ADC1_GAIN );
|
||||
cal1_fine( setup, 5, ADC1_GAIN );
|
||||
|
||||
cal1( setup, 6, ADC2_GAIN );
|
||||
cal1_fine( setup, 6, ADC2_GAIN );
|
||||
|
||||
cal1( setup, 7, ADC3_GAIN );
|
||||
cal1_fine( setup, 7, ADC3_GAIN );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ ok:
|
|||
|
||||
if(do_reset)reset_caldacs( &setup );
|
||||
if(do_dump) observe( &setup );
|
||||
if(do_calibrate && do_cal) setup.do_cal( &setup );
|
||||
if(do_calibrate && setup.do_cal) setup.do_cal( &setup );
|
||||
if(do_results) observe( &setup );
|
||||
|
||||
return 0;
|
||||
|
@ -216,7 +216,7 @@ void set_target( calibration_setup_t *setup, int obs,double target)
|
|||
|
||||
data = comedi_from_phys(target,range,maxdata);
|
||||
|
||||
setup->observables[obs].preobserve_data = data;
|
||||
setup->observables[obs].preobserve_data[0] = data;
|
||||
setup->observables[obs].target = comedi_to_phys(data,range,maxdata);
|
||||
}
|
||||
|
||||
|
@ -235,11 +235,17 @@ void observe( calibration_setup_t *setup )
|
|||
|
||||
}
|
||||
|
||||
void preobserve( calibration_setup_t *setup, int obs)
|
||||
int preobserve( calibration_setup_t *setup, int obs)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if( setup->observables[obs].preobserve_insn.n != 0){
|
||||
comedi_do_insn( setup->dev, &setup->observables[obs].preobserve_insn);
|
||||
retval = comedi_do_insn( setup->dev, &setup->observables[obs].preobserve_insn);
|
||||
}
|
||||
if( retval < 0 )
|
||||
perror("preobserve()");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void measure_observable( calibration_setup_t *setup, int obs)
|
||||
|
@ -812,6 +818,14 @@ int new_sv_measure( comedi_t *dev, new_sv_t *sv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
ret = comedi_data_read_hint(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
|
||||
sv->aref);
|
||||
if(ret<0){
|
||||
printf("hint barf\n");
|
||||
goto out;
|
||||
}
|
||||
usleep( 1000 );
|
||||
|
||||
ret = comedi_data_read_n(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
|
||||
sv->aref, data, n);
|
||||
if(ret<0){
|
||||
|
|
|
@ -218,7 +218,7 @@ void ni_setup_observables( calibration_setup_t *setup )
|
|||
o->name = "ao 0, zero offset, low gain";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.chanspec = CR_PACK(0,0,0);
|
||||
o->preobserve_insn.data = &o->preobserve_data;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec =
|
||||
CR_PACK(2,bipolar_lowgain,AREF_OTHER);
|
||||
|
@ -229,7 +229,7 @@ void ni_setup_observables( calibration_setup_t *setup )
|
|||
o->name = "ao 0, reference voltage, low gain";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.chanspec = CR_PACK(0,0,0);
|
||||
o->preobserve_insn.data = &o->preobserve_data;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec =
|
||||
CR_PACK(6,bipolar_lowgain,AREF_OTHER);
|
||||
|
@ -241,7 +241,7 @@ void ni_setup_observables( calibration_setup_t *setup )
|
|||
o->name = "ao 1, zero offset, low gain";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.chanspec = CR_PACK(1,0,0);
|
||||
o->preobserve_insn.data = &o->preobserve_data;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec =
|
||||
CR_PACK(3,bipolar_lowgain,AREF_OTHER);
|
||||
|
@ -252,7 +252,7 @@ void ni_setup_observables( calibration_setup_t *setup )
|
|||
o->name = "ao 1, reference voltage, low gain";
|
||||
o->preobserve_insn = po_tmpl;
|
||||
o->preobserve_insn.chanspec = CR_PACK(1,0,0);
|
||||
o->preobserve_insn.data = &o->preobserve_data;
|
||||
o->preobserve_insn.data = o->preobserve_data;
|
||||
o->observe_insn = tmpl;
|
||||
o->observe_insn.chanspec =
|
||||
CR_PACK(7,bipolar_lowgain,AREF_OTHER);
|
||||
|
|
Loading…
Add table
Reference in a new issue