make sure we aren't out-of-range when doing unipolar postgain offset
This commit is contained in:
parent
7af1cc7f5e
commit
53a43ff0a7
3 changed files with 62 additions and 0 deletions
|
@ -51,6 +51,13 @@ void generic_do_linearity( calibration_setup_t *setup,
|
|||
sc_push_caldac( saved_cal, setup->caldacs[ caldac ] );
|
||||
}
|
||||
|
||||
void generic_peg( calibration_setup_t *setup,
|
||||
comedi_calibration_setting_t *saved_cal, int observable, int caldac, int maximize )
|
||||
{
|
||||
if( caldac < 0 || observable < 0 ) return;
|
||||
peg_binary( setup, observable, caldac, maximize );
|
||||
}
|
||||
|
||||
void generic_prep_adc_caldacs( calibration_setup_t *setup,
|
||||
const generic_layout_t *layout, unsigned int channel, unsigned int range )
|
||||
{
|
||||
|
@ -172,6 +179,14 @@ static void generic_do_adc_postgain_offset( calibration_setup_t *setup, const ge
|
|||
{
|
||||
lowgain = get_unipolar_lowgain( setup->dev, setup->ad_subdev );
|
||||
highgain = get_unipolar_highgain( setup->dev, setup->ad_subdev );
|
||||
|
||||
reset_caldac( setup, layout->adc_postgain_offset( channel ) );
|
||||
/* need to make sure we aren't stuck on zero for unipolar,
|
||||
* by setting pregain offset to maximum */
|
||||
generic_peg( setup, current_cal, layout->adc_ground_observable( setup, channel, lowgain ),
|
||||
layout->adc_offset( channel ), 1 );
|
||||
generic_peg( setup, current_cal, layout->adc_ground_observable( setup, channel, lowgain ),
|
||||
layout->adc_offset_fine( channel ), 1 );
|
||||
}else
|
||||
{
|
||||
lowgain = get_bipolar_lowgain( setup->dev, setup->ad_subdev );
|
||||
|
|
|
@ -121,6 +121,7 @@ void cal_binary( calibration_setup_t *setup, int obs, int dac);
|
|||
void cal_postgain_binary( calibration_setup_t *setup, int obs1, int obs2, int dac);
|
||||
void cal_relative_binary( calibration_setup_t *setup, int obs1, int obs2, int dac);
|
||||
void cal_linearity_binary( calibration_setup_t *setup, int obs1, int obs2, int obs3, int dac);
|
||||
void peg_binary( calibration_setup_t *setup, int obs, int dac, int maximize );
|
||||
|
||||
/* misc and temp */
|
||||
|
||||
|
|
|
@ -531,6 +531,52 @@ void cal1_fine( calibration_setup_t *setup, int obs, int dac )
|
|||
}
|
||||
}
|
||||
|
||||
void peg_binary( calibration_setup_t *setup, int obs, int dac, int maximize )
|
||||
{
|
||||
int x0, x1, x;
|
||||
double y0, y1;
|
||||
new_sv_t sv;
|
||||
unsigned int chanspec = setup->observables[obs].observe_insn.chanspec;
|
||||
int polarity;
|
||||
|
||||
DPRINT(0,"binary peg: %s\n", setup->observables[obs].name);
|
||||
preobserve( setup, obs);
|
||||
|
||||
comedi_set_global_oor_behavior( COMEDI_OOR_NUMBER );
|
||||
|
||||
my_sv_init(&sv, setup, setup->ad_subdev, chanspec);
|
||||
|
||||
x0 = setup->caldacs[dac].maxdata;
|
||||
update_caldac( setup, dac, x0 );
|
||||
usleep(caldac_settle_usec);
|
||||
new_sv_measure( setup->dev, &sv);
|
||||
y0 = sv.average;
|
||||
|
||||
x1 = 0;
|
||||
update_caldac( setup, dac, x1 );
|
||||
usleep(caldac_settle_usec);
|
||||
new_sv_measure( setup->dev, &sv);
|
||||
y1 = sv.average;
|
||||
|
||||
if( (y0 - y1) > 0.0 ) polarity = 1;
|
||||
else polarity = -1;
|
||||
|
||||
if( maximize )
|
||||
{
|
||||
if( polarity > 0 ) x = x0;
|
||||
else x = x1;
|
||||
}else
|
||||
{
|
||||
if( polarity > 0 ) x = x1;
|
||||
else x = x0;
|
||||
}
|
||||
update_caldac( setup, dac, x );
|
||||
DPRINT(0,"caldac[%d] set to %d\n",dac,x);
|
||||
if(verbose>=3){
|
||||
measure_observable( setup, obs);
|
||||
}
|
||||
}
|
||||
|
||||
void cal_binary( calibration_setup_t *setup, int obs, int dac)
|
||||
{
|
||||
int x0, x1, x2, x;
|
||||
|
|
Loading…
Add table
Reference in a new issue