Esempio n. 1
0
        private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs)
        {
            float  EngUnits;
            double HighResEngUnits;

            MccDaq.ErrorInfo ULStat;
            System.UInt16    DataValue;
            System.UInt32    DataValue32;
            int Chan;
            int Options = 0;

            tmrConvert.Stop();

            //  Collect the data by calling AIn member function of MccBoard object
            //   Parameters:
            //     Chan       :the input channel number
            //     Range      :the Range for the board.
            //     DataValue  :the name for the value collected

            //  set input channel
            bool ValidChan = int.TryParse(txtNumChan.Text, out Chan);

            if (ValidChan)
            {
                if (Chan > HighChan)
                {
                    Chan = HighChan;
                }
                txtNumChan.Text = Chan.ToString();
            }

            if (ADResolution > 16)
            {
                ULStat = DaqBoard.AIn32(Chan, Range, out DataValue32, Options);
                //  Convert raw data to Volts by calling ToEngUnits
                //  (member function of MccBoard class)
                ULStat = DaqBoard.ToEngUnits32(Range, DataValue32, out HighResEngUnits);

                lblShowData.Text  = DataValue32.ToString();                    //  print the counts
                lblShowVolts.Text = HighResEngUnits.ToString("F5") + " Volts"; //  print the voltage
            }
            else
            {
                ULStat = DaqBoard.AIn(Chan, Range, out DataValue);

                //  Convert raw data to Volts by calling ToEngUnits
                //  (member function of MccBoard class)
                ULStat = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits);

                lblShowData.Text  = DataValue.ToString();               //  print the counts
                lblShowVolts.Text = EngUnits.ToString("F4") + " Volts"; //  print the voltage
            }

            tmrConvert.Start();
        }
Esempio n. 2
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            int i;

            MccDaq.ErrorInfo   ULStat;
            MccDaq.Range       Range;
            MccDaq.ScanOptions Options;
            int Rate;
            int Count;
            int Chan;

            StrainConfig StrainConfiguration = StrainConfig.QuarterBridgeI;

            double InitialVoltage         = 0.0; //Bridge output voltage in the unloaded condition. This value is subtracted from any measurements before scaling equations are applied.
            double VInitial               = 0.0;
            double OffsetAdjustmentFactor = 0.0;
            double GainAdjustmentFactor   = 0.0;
            double Total        = 0.0;
            double VOffset      = 0.0;
            double RShunt       = 100000;               // Resistance of Shunt Resistor
            double RGage        = 350;                  // Gage Resistance
            double VExcitation  = 2.5;                  // Excitation voltage
            double GageFactor   = 2;
            double PoissonRatio = 0;
            double VActualBridge;                       // Actual bridge voltage
            double REffective;                          // Effective resistance
            double VSimulatedBridge;                    // Simulated bridge voltage
            double MeasuredStrain;
            double SimulatedStrain;

            cmdStart.Enabled = false;

            // Calculate the offset adjusment factor on a resting gage in software

            //  Collect the values by calling MccDaq.MccBoard.AInScan function
            //  Parameters:
            //    LowChan    :the first channel of the scan
            //    HighChan   :the last channel of the scan
            //    Count      :the total number of A/D samples to collect
            //    Rate       :sample rate
            //    Range      :the range for the board
            //    MemHandle  :Handle for Windows buffer to store data in
            //    Options    :data collection options

            Chan = int.Parse(txtChan.Text); // channel to acquire
            if ((Chan > 3))
            {
                Chan = 3;
            }
            txtChan.Text = Chan.ToString();

            VInitial = InitialVoltage / VExcitation;

            Count = NumPoints;  //  total number of data points to collect
            Rate  = 1000;       //  per channel sampling rate ((samples per second) per channel)

            //  return scaled data
            Options = MccDaq.ScanOptions.ScaleData;
            Range   = MccDaq.Range.NotUsed;   // set the range

            ULStat = DaqBoard.AInScan(Chan, Chan, Count, ref Rate, Range, MemHandle, Options);

            //  Transfer the data from the memory buffer set up by Windows to an array
            ULStat = MccDaq.MccService.ScaledWinBufToArray(MemHandle, ADData, FirstPoint, Count);

            for (i = 0; i < NumPoints; i++)
            {
                Total = Total + ADData [i];
            }

            VOffset = Total / Count;

            VOffset = VOffset - VInitial;

            OffsetAdjustmentFactor = CalculateStrain(StrainConfiguration, VOffset, GageFactor, PoissonRatio);

            lblOffsetMeasStrain.Text = OffsetAdjustmentFactor.ToString("F9");

            //	Enable Shunt Calibration Circuit and Collect the values and
            //  Calculate the Actual Bridge Voltage

            Options = MccDaq.ScanOptions.ScaleData | MccDaq.ScanOptions.ShuntCal;
            ULStat  = DaqBoard.AInScan(Chan, Chan, Count, ref Rate, Range, MemHandle, Options);

            //  Transfer the data from the memory buffer set up by Windows to an array
            ULStat = MccDaq.MccService.ScaledWinBufToArray(MemHandle, ADData, FirstPoint, Count);

            Total = 0.0;

            for (i = 0; i < Count; i++)
            {
                Total = Total + ADData [i];
            }

            VActualBridge = Total / Count;

            VActualBridge = VActualBridge - VInitial;

            MeasuredStrain = CalculateStrain(StrainConfiguration, VActualBridge, GageFactor, PoissonRatio);

            lblGainMeasStrain.Text = MeasuredStrain.ToString("F9");

            // Calculate the Simulated Bridge Strain with a shunt resistor

            REffective = (RGage * RShunt) / (RGage + RShunt);

            VSimulatedBridge = (REffective / (REffective + RGage) - 0.5);

            SimulatedStrain = CalculateStrain(StrainConfiguration, VSimulatedBridge, GageFactor, PoissonRatio);

            lblGainSimStrain.Text = SimulatedStrain.ToString("F9");

            GainAdjustmentFactor = SimulatedStrain / (MeasuredStrain - OffsetAdjustmentFactor);

            lblGainAdjustmentFactor.Text = GainAdjustmentFactor.ToString("F9");

            cmdStart.Enabled = true;
        }