use bipolar range when pegging pregain offset before unipolar postgain
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 13 Jun 2003 21:49:27 +0000 (21:49 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 13 Jun 2003 21:49:27 +0000 (21:49 +0000)
calibration

comedi_calibrate/cal_common.c
comedi_calibrate/cb.c

index 8db2c1c77b53d5d687f4f174ab8751e83fcd7d21..18739c30646c9133adec05e566224d5dffff126e 100644 (file)
@@ -71,6 +71,7 @@ void generic_prep_adc_caldacs( calibration_setup_t *setup,
                reset_caldac( setup, layout->adc_gain( channel ) );
                reset_caldac( setup, layout->adc_offset_fine( channel ) );
                reset_caldac( setup, layout->adc_gain_fine( channel ) );
+               reset_caldac( setup, layout->adc_postgain_offset( channel ) );
        }else
        {
                retval = comedi_apply_parsed_calibration( setup->dev, setup->ad_subdev,
@@ -82,6 +83,7 @@ void generic_prep_adc_caldacs( calibration_setup_t *setup,
                        reset_caldac( setup, layout->adc_gain( channel ) );
                        reset_caldac( setup, layout->adc_offset_fine( channel ) );
                        reset_caldac( setup, layout->adc_gain_fine( channel ) );
+                       reset_caldac( setup, layout->adc_postgain_offset( channel ) );
                }
        }
 }
@@ -174,25 +176,27 @@ static void generic_do_adc_postgain_offset( calibration_setup_t *setup, const ge
        comedi_calibration_setting_t *current_cal, unsigned int channel, int unipolar )
 {
        int lowgain, highgain;
+       int bip_lowgain;
 
+       bip_lowgain = get_bipolar_lowgain( setup->dev, setup->ad_subdev );
        if( unipolar )
        {
                lowgain = get_unipolar_lowgain( setup->dev, setup->ad_subdev );
                highgain = get_unipolar_highgain( setup->dev, setup->ad_subdev );
        }else
        {
-               lowgain = get_bipolar_lowgain( setup->dev, setup->ad_subdev );
+               lowgain = bip_lowgain;
                highgain = get_bipolar_highgain( setup->dev, setup->ad_subdev );
        }
        generic_prep_adc_caldacs( setup, layout, channel, highgain );
        if( unipolar )
        {
-               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, layout->adc_ground_observable( setup, channel, lowgain ),
+               /* Need to make sure we aren't stuck on zero for unipolar,
+                * by setting pregain offset to maximum.  Use bipolar lowgain
+                * for pegs to make sure we aren't out-of-range. */
+               generic_peg( setup, layout->adc_ground_observable( setup, channel, bip_lowgain ),
                        layout->adc_offset( channel ), 1 );
-               generic_peg( setup, layout->adc_ground_observable( setup, channel, lowgain ),
+               generic_peg( setup, layout->adc_ground_observable( setup, channel, bip_lowgain ),
                        layout->adc_offset_fine( channel ), 1 );
        }
        generic_do_relative( setup, current_cal, layout->adc_ground_observable( setup, channel, lowgain ),
index 10939662483a8d3a1face301cd302e693da26a0f..034e3664b8f65798aa8dfafeb5b4a63ff65bfd5b 100644 (file)
@@ -573,6 +573,6 @@ int cb_actual_source_voltage( comedi_t *dev, unsigned int subdevice, unsigned in
                return -1;
        }
 
-       DPRINT(0, "eeprom ch 0x%x gives calibration source of %gV\n", eeprom_channel, *voltage);
+       DPRINT(1, "eeprom ch 0x%x gives calibration source of %gV\n", eeprom_channel, *voltage);
        return 0;
 }