comedi_range *range;
lsampl_t maxdata, data;
- range = comedi_get_range(setup->dev, setup->observables[obs].preobserve_insn.subdev,
+ range = comedi_get_range(setup->dev,
+ setup->observables[obs].preobserve_insn.subdev,
CR_CHAN( setup->observables[obs].preobserve_insn.chanspec ),
CR_RANGE( setup->observables[obs].preobserve_insn.chanspec ));
- maxdata = comedi_get_maxdata( setup->dev, setup->observables[obs].preobserve_insn.subdev,
+ maxdata = comedi_get_maxdata( setup->dev,
+ setup->observables[obs].preobserve_insn.subdev,
CR_CHAN(setup->observables[obs].preobserve_insn.chanspec));
data = comedi_from_phys(target,range,maxdata);
new_sv_init(&sv, setup->dev,
setup->observables[obs].observe_insn.subdev,
- CR_CHAN( setup->observables[obs].observe_insn.chanspec),
- CR_RANGE( setup->observables[obs].observe_insn.chanspec),
- CR_AREF( setup->observables[obs].observe_insn.chanspec));
+ setup->observables[obs].observe_insn.chanspec);
sv.order=7;
// read internal calibration source and turn on dithering
- sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER;
n = new_sv_measure(setup->dev, &sv);
sci_sprint_alt(s,sv.average,sv.error);
orig = setup->caldacs[cdac].current;
- new_sv_init(&sv, setup->dev,0,
- CR_CHAN(ad_chanspec),
- CR_RANGE(ad_chanspec),
- CR_AREF(ad_chanspec));
+ new_sv_init(&sv, setup->dev,0,ad_chanspec);
// read internal calibration source and turn on dithering
- sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER;
setup->caldacs[cdac].current=0;
update_caldac( setup, cdac );
orig = setup->caldacs[cdac].current;
- new_sv_init(&sv, setup->dev,0,
- CR_CHAN(ad_chanspec),
- CR_RANGE(ad_chanspec),
- CR_AREF(ad_chanspec));
+ new_sv_init(&sv, setup->dev,0,ad_chanspec);
// read internal calibration source and turn on dithering
- sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER | CR_ALT_SOURCE;
+ //sv.cr_flags = CR_ALT_FILTER;
setup->caldacs[cdac].current=0;
update_caldac( setup, cdac );
new_sv_t sv;
char str[20];
- new_sv_init(&sv, setup->dev, 0,adc,range,AREF_OTHER);
+ new_sv_init(&sv, setup->dev, 0,CR_PACK(adc,range,AREF_OTHER));
sv.order=7;
- sv.cr_flags = CR_ALT_FILTER;
+ //sv.cr_flags = CR_ALT_FILTER;
n=new_sv_measure( setup->dev, &sv);
int n;
new_sv_t sv;
- new_sv_init(&sv, setup->dev,0,adc,range,AREF_OTHER);
+ new_sv_init(&sv, setup->dev,0,CR_PACK(adc,range,AREF_OTHER));
sv.order=7;
// turn on dithering
- sv.cr_flags = CR_ALT_FILTER;
+ //sv.cr_flags = CR_ALT_FILTER;
n=new_sv_measure( setup->dev, &sv);
#endif
-int new_sv_init(new_sv_t *sv,comedi_t *dev,int subdev,int chan,int range,int aref)
+int new_sv_init(new_sv_t *sv,comedi_t *dev,int subdev,unsigned int chanspec)
{
memset(sv,0,sizeof(*sv));
sv->subd=subdev;
//sv->t.flags=TRIG_DITHER;
- sv->chan=chan;
- sv->range=range;
- sv->aref=aref;
+ sv->chanspec = chanspec;
//sv->chanlist[0]=CR_PACK(chan,range,aref);
- sv->maxdata=comedi_get_maxdata(dev,subdev,chan);
- sv->rng=comedi_get_range(dev,subdev,chan,range);
+ sv->maxdata=comedi_get_maxdata(dev,subdev,CR_CHAN(chanspec));
+ sv->rng=comedi_get_range(dev,subdev,
+ CR_CHAN(chanspec), CR_RANGE(chanspec));
sv->order=7;
exit(1);
}
- ret = comedi_data_read_hint(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
- sv->aref);
+ ret = comedi_data_read_hint(dev, sv->subd, sv->chanspec, 0, 0);
if(ret<0){
printf("hint barf\n");
goto out;
}
- usleep( 1000 );
+ comedi_nanodelay(dev, 1000*99);
+ //usleep( 1000 );
- ret = comedi_data_read_n(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
- sv->aref, data, n);
+ ret = comedi_data_read_n(dev, sv->subd, sv->chanspec, 0, 0, data, n);
if(ret<0){
printf("barf\n");
goto out;
exit(1);
}
- ret = comedi_data_read_n(dev, sv->subd, sv->chan | sv->cr_flags, sv->range,
- sv->aref, data, n);
+ ret = comedi_data_read_n(dev, sv->subd, sv->chanspec, 0, 0, data, n);
if(ret<0){
printf("barf order\n");
goto out;
return sprintf(s,"%0.*f(%2.0f)e%d",sigfigs-1,mantissa,error,maxsig);
}
+
void ni_setup_observables( calibration_setup_t *setup )
{
comedi_insn tmpl;
+ comedi_insn po_tmpl2;
int bipolar_lowgain;
int bipolar_highgain;
int unipolar_lowgain;
tmpl.n = 1;
tmpl.subdev = ad_subdev;
+ memset(&po_tmpl2,0,sizeof(tmpl));
+ po_tmpl2.insn = INSN_CONFIG;
+ po_tmpl2.n = 2;
+ po_tmpl2.subdev = ad_subdev;
+
/* 0 offset, low gain */
o = setup->observables + ni_zero_offset_low;
o->name = "ai, bipolar zero offset, low gain";
+ o->preobserve_insn = po_tmpl2;
+ o->preobserve_insn.data = o->preobserve_data;
+ o->preobserve_insn.data[0] = INSN_CONFIG_ALT_SOURCE;
+ o->preobserve_insn.data[1] = CR_PACK(0,0,0);
o->observe_insn = tmpl;
- o->observe_insn.chanspec = CR_PACK(0,bipolar_lowgain,AREF_OTHER);
+ o->observe_insn.chanspec = CR_ALT_SOURCE;
o->target = 0;
/* 0 offset, high gain */
o->preobserve_insn.chanspec = CR_PACK(0,0,0);
o->preobserve_insn.data = o->preobserve_data;
o->observe_insn = tmpl;
- o->observe_insn.chanspec =
+ o->observe_insn.chanspec =
CR_PACK(6,bipolar_lowgain,AREF_OTHER);
set_target( setup, ni_ao0_reference,5.0);
o->target -= voltage_reference;