private double CalculateStrain(StrainConfig StrainCfg, double U, double GageFactor, double PoissonRatio) { double starin = 0; switch (StrainCfg) { case StrainConfig.FullBridgeI: starin = (-U) / GageFactor; break; case StrainConfig.FullBridgeII: starin = (-2 * U) / (GageFactor * (1 + PoissonRatio)); break; case StrainConfig.FullBridgeIII: starin = (-2 * U) / (GageFactor * ((PoissonRatio + 1) - (U * (PoissonRatio - 1)))); break; case StrainConfig.HalfBridgeI: starin = (-4 * U) / (GageFactor * ((PoissonRatio + 1) - 2 * U * (PoissonRatio - 1))); break; case StrainConfig.HalfBridgeII: starin = (-2 * U) / GageFactor; break; case StrainConfig.QuarterBridgeI: case StrainConfig.QuarterBridgeII: starin = (-4 * U) / (GageFactor * ((1 + 2 * U))); break; } return(starin); }
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; }