public void SelectRange(Int32 ComboBoxIndex) { switch (ComboBoxIndex) { case 0: Range = MccDaq.Range.Bip10Volts; analogMeter1.Minimum = -10; analogMeter1.Maximum = 10; break; case 1: Range = MccDaq.Range.Bip5Volts; analogMeter1.Minimum = -5; analogMeter1.Maximum = 5; break; case 2: Range = MccDaq.Range.Bip2Volts; analogMeter1.Minimum = -5; analogMeter1.Maximum = 5; break; case 3: Range = MccDaq.Range.Bip1Volts; analogMeter1.Minimum = -5; analogMeter1.Maximum = 5; break; } }
private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs) /* Handles tmrConvert.Tick */ { tmrConvert.Stop(); // 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 int LowChan = 0; // first channel to acquire HighChan = int.Parse(txtHighChan.Text); // last channel to acquire if (HighChan > 7) { HighChan = 7; } txtHighChan.Text = HighChan.ToString(); int Count = NumPoints; // total number of data points to collect int Rate = 100; // sampling rate is ignored MccDaq.Range Range = MccDaq.Range.Bip5Volts; // set the range MccDaq.ScanOptions Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.ExtClock; MccDaq.ErrorInfo ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options); // Transfer the data from the memory buffer set up by Windows to an array if (HighResAD) { ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, Count); for (int i = 0; i <= HighChan; ++i) { lblADData[i].Text = ADData32[i].ToString("0"); } } else { ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, Count); for (int i = 0; i <= HighChan; ++i) { lblADData[i].Text = ADData[i].ToString("0"); } } for (int j = HighChan + 1; j <= 7; ++j) { lblADData[j].Text = (""); } tmrConvert.Start(); }
private ushort GetTrigCounts(MccDaq.Range range, float EngUnits) { float fCounts; int iFSCounts; MccDaq.ErrorInfo ULStat; int FSCounts; float FSEngUnits; // check if range is bipolar or unipolar FSCounts = 0; FSEngUnits = 0.0F; ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts), out FSEngUnits); if (FSEngUnits < 0) { // range is bipolar // check bitness FSCounts = 0XFFF; // max 12-bit value ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts), out FSEngUnits); if (FSEngUnits < 0) { // must be 16-bit A/D FSCounts = 65535; iFSCounts = 0XFFFF; ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(iFSCounts), out FSEngUnits); } fCounts = (float)((FSCounts / 2.0F) * (1.0F + EngUnits / FSEngUnits)); } else { // range is unipolar // check bitness FSCounts = 0XFFF; // max 12-bit value ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts), out FSEngUnits); ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts + 0X1000), out fCounts); if (fCounts >= 2.0F * FSEngUnits) { // must be 16-bit A/D FSCounts = 65535; iFSCounts = 0XFFFF; ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(iFSCounts), out FSEngUnits); } fCounts = FSCounts * EngUnits / FSEngUnits; } if (fCounts > FSCounts) { fCounts = FSCounts; } if (fCounts < 0) { fCounts = 0; } return(Convert.ToUInt16(fCounts)); }
public float GetRangeVolts(MccDaq.Range Range) { string RangeString; float RangeVolts; GetRangeInfo(Range, out RangeString, out RangeVolts); return(RangeVolts); }
private bool TestOutputRanges(out MccDaq.Range DefaultRange) { short dataValue = 0; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; int configVal; string ConnectionConflict; ConnectionConflict = "This network device is in use by another process or user." + System.Environment.NewLine + System.Environment.NewLine + "Check for other users on the network and close any applications " + System.Environment.NewLine + "(such as Instacal) that may be accessing the network device."; DefaultRange = MccDaq.Range.NotUsed; TestRange = (MccDaq.Range)(-5); ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { ULStat = TestBoard.GetConfig(2, 0, 114, out configVal); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultRange = (MccDaq.Range)configVal; RangeFound = true; } } else { TestRange = MccDaq.Range.NotUsed; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } RangeFound = true; break; } else { if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) || (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse)) { System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use"); break; } } } } return(RangeFound); }
private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs) /* Handles tmrConvert.Tick */ { tmrConvert.Stop(); // Collect the values with MccDaq.MccBoard.AInScan() // 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 (determined by // Set Mode option buttons in this program) int LowChan = 0; // first channel to acquire HighChan = int.Parse(txtHighChan.Text); // last channel to acquire if (HighChan > 7) { HighChan = 7; } txtHighChan.Text = HighChan.ToString(); int Count = NumPoints; // total number of data points to collect int Rate = 290; // per channel sampling rate ((samples per second) per channel) MccDaq.Range Range = MccDaq.Range.Bip5Volts; // set the range MccDaq.ErrorInfo ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.FreeRunning) { // Turn off library error handling for subsequent calls ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.StopAll); } // Transfer the data from the memory buffer set up by Windows to an array if (HighResAD) { ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, Count); for (int i = 0; i <= HighChan; ++i) { lblADData[i].Text = ADData32[i].ToString("0"); } } else { ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, Count); for (int i = 0; i <= HighChan; ++i) { lblADData[i].Text = ADData[i].ToString("0"); } } tmrConvert.Start(); }
private bool TestInputRanges(out MccDaq.Range DefaultRange) { short dataValue; int dataHRValue, Options, index; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; string ConnectionConflict; ConnectionConflict = "This network device is in use by another process or user." + System.Environment.NewLine + System.Environment.NewLine + "Check for other users on the network and close any applications " + System.Environment.NewLine + "(such as Instacal) that may be accessing the network device."; ValidRanges = new MccDaq.Range[49]; DefaultRange = MccDaq.Range.NotUsed; TestRange = MccDaq.Range.NotUsed; Options = 0; index = 0; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; if (ADRes > 16) { ULStat = TestBoard.AIn32(0, TestRange, out dataHRValue, Options); } else { ULStat = TestBoard.AIn(0, TestRange, out dataValue); } if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } ValidRanges.SetValue(TestRange, index); index = index + 1; RangeFound = true; } else { if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) || (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse)) { System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use"); break; } } } Array.Resize(ref ValidRanges, index); return(RangeFound); }
//constuctor for the dyno public Dyno() { isDynCon = false; //Initialize Error Handling ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll); //Create an object for board 0 DaqBoard = new MccDaq.MccBoard(0); //Set the range Range = MccDaq.Range.Bip10Volts; // return scaled data Options = MccDaq.ScanOptions.ScaleData; // creating and defining the objects for the moving average filterLength = 5; averager = new MovingAverage(filterLength); XForce = 0; YForce = 0; ZForceDyno = 0; TForce = 0; VAngle = 0; XYForce = 0; XYForceAverage = 0; // Try to initialize the dyno control port and catch any errors try { //Set up port for controlling the dyno DynoControlPort = new SerialPort(); DynoControlPort.PortName = "COM3"; DynoControlPort.BaudRate = 4800; DynoControlPort.Parity = Parity.None; DynoControlPort.StopBits = StopBits.One; DynoControlPort.DataBits = 8; DynoControlPort.Open(); } catch (System.IO.IOException e) { //MessageBox.Show("Open device manager in windows and the 'Setup Serial Ports' section of the C# code and check the serial port names and settings are correct\n\n" + e.ToString(), "Serial Port Error"); //Process.GetCurrentProcess().Kill(); } catch (System.UnauthorizedAccessException e) { //MessageBox.Show("Something is wrong? maybe try to restart computer?\n\nHere is some error message stuff...\n\n" + e.ToString(), "Serial Port Error"); //Process.GetCurrentProcess().Kill(); } }
public double[] ReadDyno() { //establish all the varables for the data double[] reading = new double[7]; //sampleing from all 8 channels, DAQ has a max sampling rate of 10,000Hz so for sampleing 8 channels the rate=10,000/8=1,250 int LowChan = 0, HighChan = 7, Rate = 1250, Count = 8;//JNEW //IntPtr MemHandle = IntPtr.Zero;//JNEW //dont think this is needed here int NumPoints = 8; // Number of data points to collect //JNEW int FirstPoint = 0; // set first element in buffer to transfer to array //JNEW ushort[] ADData = new ushort[NumPoints]; //JNEW IntPtr MemHandle = MccDaq.MccService.ScaledWinBufAllocEx(NumPoints); //JNEW // return scaled data (dont know exactly what this means) Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.SingleIo; //Options = MccDaq.ScanOptions.ScaleData; Range = MccDaq.Range.Bip5Volts; // set the range ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange) { Console.WriteLine("Change the Range argument to one supported by this board."); } // Transfer the data from the memory buffer set up by Windows to an array ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, Count); //calibration variables (probably from kistler) //Copy into local variables XForce = 487.33 * Count2Volt(ADData[0]); YForce = 479.85 * Count2Volt(ADData[1]); ZForceDyno = 2032.52 * Count2Volt(ADData[2]); TForce = 18.91 * Count2Volt(ADData[3]); VAngle = Count2Volt(ADData[7]); XYForce = Math.Sqrt(XForce * XForce + YForce * YForce); XYForceAverage = averager.calculateAverage(XYForce); reading[0] = XForce; reading[1] = YForce; reading[2] = ZForceDyno; reading[3] = TForce; reading[4] = VAngle; reading[5] = XYForce; reading[6] = XYForceAverage; return(reading); }
private ushort GetTrigCounts(MccDaq.Range range, float EngUnits) { float fCounts; MccDaq.ErrorInfo ULStat; int FSCounts; float FSEngUnits; bool RangeIsBipolar = false; // check if range is bipolar or unipolar FSCounts = 0; FSEngUnits = 0.0F; ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts), out FSEngUnits); if (FSEngUnits < 0) { RangeIsBipolar = true; } FSCounts = (int)Math.Pow(2, ADResolution) - 1; ULStat = DaqBoard.ToEngUnits(range, System.Convert.ToUInt16(FSCounts), out FSEngUnits); if (RangeIsBipolar) { fCounts = (float)((FSCounts / 2.0F) * (1.0F + EngUnits / FSEngUnits)); } else { fCounts = FSCounts * EngUnits / FSEngUnits; } if (fCounts > FSCounts) { fCounts = FSCounts; } if (fCounts < 0) { fCounts = 0; } return(Convert.ToUInt16(fCounts)); }
private bool TestOutputRanges(out MccDaq.Range DefaultRange) { short dataValue = 0; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; int configVal; DefaultRange = MccDaq.Range.NotUsed; TestRange = (MccDaq.Range)(-5); ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { ULStat = TestBoard.GetConfig(2, 0, 114, out configVal); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultRange = (MccDaq.Range)configVal; RangeFound = true; } } else { TestRange = MccDaq.Range.NotUsed; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } RangeFound = true; break; } } } return(RangeFound); }
private bool TestInputRanges(out MccDaq.Range DefaultRange) { short dataValue; int dataHRValue, Options, index; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; ValidRanges = new MccDaq.Range[49]; DefaultRange = MccDaq.Range.NotUsed; TestRange = MccDaq.Range.NotUsed; Options = 0; index = 0; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; if (ADRes > 16) { ULStat = TestBoard.AIn32(0, TestRange, out dataHRValue, Options); } else { ULStat = TestBoard.AIn(0, TestRange, out dataValue); } if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } ValidRanges.SetValue(TestRange, index); index = index + 1; RangeFound = true; } } Array.Resize(ref ValidRanges, index); return(RangeFound); }
private void cmdSendData_Click(object eventSender, System.EventArgs eventArgs) /* Handles cmdSendData.Click */ { // Parameters: // LowChan :the lower channel of the scan // HighChan :the upper channel of the scan // Count :the number of D/A values to send // Rate :per channel sampling rate ((samples per second) per channel) // DAData :array of values to send to the scanned channels // Options :data send options FirstPoint = 0; int LowChan = 0; // First analog output channel int HighChan = 1; // Last analog output channel int Rate = 100; // Rate of data update (ignored if board does not support timed analog output) MccDaq.Range Gain = MccDaq.Range.Bip5Volts; // Ignored if gain is not programmable MccDaq.ScanOptions Options = MccDaq.ScanOptions.Default; // foreground mode scan MccDaq.ErrorInfo ULStat = DaqBoard.AOutScan(LowChan, HighChan, Count, ref Rate, Gain, MemHandle, Options); for (int i = 0; i <= NumPoints - 1; ++i) { lblAOutData[i].Text = DAData[i].ToString("0"); } }
public void SelectRange(Int32 ComboBoxIndex) { switch (ComboBoxIndex) { case 0: Range = MccDaq.Range.Bip20Volts; break; case 1: Range = MccDaq.Range.Bip10Volts; break; case 2: Range = MccDaq.Range.Bip5Volts; break; case 3: Range = MccDaq.Range.Bip4Volts; break; case 4: Range = MccDaq.Range.Bip2Pt5Volts; break; case 5: Range = MccDaq.Range.Bip2Volts; break; case 6: Range = MccDaq.Range.Bip1Pt25Volts; break; case 7: Range = MccDaq.Range.Bip1Volts; break; } }
private void cmdStart_Click(object eventSender, System.EventArgs eventArgs) /* Handles cmdStart.Click */ { cmdStart.Enabled = false; // Select the trigger source using Mccdaq.MccBoard.SetTrigger() // Parameters: // TrigType :the type of triggering based on external trigger source // LowThreshold :Low threshold when the trigger input is analog // HighThreshold :High threshold when the trigger input is analog float highVal = 1.0F; MccDaq.Range Range = MccDaq.Range.Bip10Volts; // analog trigger range ushort HighThreshold = 0; MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, highVal, out HighThreshold); float lowVal = 0.1F; ushort LowThreshold = 0; ULStat = DaqBoard.FromEngUnits(Range, lowVal, out LowThreshold); MccDaq.TriggerType TrigType = MccDaq.TriggerType.TrigAbove; ULStat = DaqBoard.SetTrigger(TrigType, LowThreshold, HighThreshold); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { // Collect the values with MccDaq.MccBoard.AInScan() // 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 int LowChan = 0; // first channel to acquire HighChan = int.Parse(txtHighChan.Text); // last channel to acquire if (HighChan > 7) { HighChan = 7; } txtHighChan.Text = HighChan.ToString(); int Count = NumPoints; // total number of data points to collect int Rate = 390; // per channel sampling rate ((samples per second) per channel) Range = MccDaq.Range.Bip5Volts; // set the range MccDaq.ScanOptions Options = MccDaq.ScanOptions.ConvertData // return data as 12-bit values | MccDaq.ScanOptions.ExtTrigger; ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange) { MessageBox.Show("Change the Range argument to one supported by this board.", "Unsupported Range", 0); } // Transfer the data from the memory buffer set up by Windows to an array ULStat = MccDaq.MccService.WinBufToArray(MemHandle, out ADData[0], FirstPoint, Count); for (int i = 0; i <= HighChan; ++i) { lblADData[i].Text = ADData[i].ToString("0"); } for (int j = HighChan + 1; j <= 7; ++j) { lblADData[j].Text = ""; } } cmdStart.Enabled = true; }
private void cmbRange_SelectedIndexChanged(object sender, System.EventArgs e) { RangeSelected = (MccDaq.Range)(cmbRange.SelectedItem); }
private void cmbRange_SelectedIndexChanged(object sender, System.EventArgs e) { RangeSelected = (MccDaq.Range)(cmbRange.SelectedItem); }
/// <summary> /// Function that check the luminosity /// </summary> /// <returns></returns> public Boolean IsDay() { float Voltage; // [] car array System.UInt16 DataValue; // Collect the data by calling AIn memeber function of MccBoard object // Parameters: // Chan :the input channel number // Range :the Range for the board. // DataValue :the name for the value collected Range = Range.Bip10Volts; // selectionne un range de 10 V ULStat = DaqBoard.AIn(4, Range.Bip10Volts, out DataValue); // on vérifie si le range est bon if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange) { MessageBox.Show("Range not upported by the card.", "Unsupported Range", MessageBoxButtons.OK); Application.Exit(); } ULStat = DaqBoard.ToEngUnits(Range, DataValue, out Voltage);// converting to voltage Program.MainForm.LightConfProgress.Value = Convert.ToInt16(Voltage * 100/5); if (Voltage >= 0.5 + 0.2 * Program.MainForm.ScrollSensibility.Value/5) return false; else return true; }
private void cmdStartAcq_Click(object eventSender, System.EventArgs eventArgs) /* Handles cmdStartAcq.Click */ { cmdStartAcq.Enabled = false; cmdStartAcq.Visible = false; cmdStopConvert.Enabled = true; cmdStopConvert.Visible = true; // Parameters: // LowChan :first A/D channel of the scan // HighChan :last A/D channel of the scan // Count :the total number of A/D samples to collect // Rate :per channel sampling rate ((samples per second) per channel) // Range :the gain for the board // FileName :the filename for the collected data values // Options :data collection options int Count = NumPoints; string FileName = txtFileName.Text; // a full path may be required here int Rate = 50000; int LowChan = 0; int HighChan = 1; MccDaq.ScanOptions Options = MccDaq.ScanOptions.Default; MccDaq.Range Range = MccDaq.Range.Bip5Volts; // set the range string DataCount = NumPoints.ToString("0"); lblAcqStat.Text = "Collecting " + DataCount + " data points"; lblShowRate.Text = Rate.ToString("0"); lblShowLoChan.Text = LowChan.ToString("0"); lblShowHiChan.Text = HighChan.ToString("0"); lblShowOptions.Text = Options.ToString(); lblShowGain.Text = Range.ToString(); lblShowFile.Text = FileName; lblShowCount.Text = Count.ToString("0"); lblShowPreTrig.Text = "Not Applicable"; Application.DoEvents(); // Collect the values with Collect the values by calling MccDaq.MccBoard.FileAInScan() MccDaq.ErrorInfo ULStat = DaqBoard.FileAInScan(LowChan, HighChan, Count, ref Rate, Range, FileName, Options); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadFileName) { MessageBox.Show("Enter the name of the file to create in text box.", "Bad File Name", 0); cmdStopConvert.Enabled = false; cmdStopConvert.Visible = false; cmdStartAcq.Enabled = true; cmdStartAcq.Visible = true; txtFileName.Focus(); return; } // show how many data points were collected short FileLowChan; short FileHighChan; int TotalCount; int PretrigCount; ULStat = MccDaq.MccService.FileGetInfo(FileName, out FileLowChan, out FileHighChan, out PretrigCount, out TotalCount, out Rate, out Range); lblReadRate.Text = Rate.ToString("0"); lblReadLoChan.Text = FileLowChan.ToString("0"); lblReadHiChan.Text = FileHighChan.ToString("0"); lblReadOptions.Text = Options.ToString(); lblReadGain.Text = Range.ToString(); lblReadFile.Text = FileName; lblReadTotal.Text = TotalCount.ToString("0"); lblReadPreTrig.Text = PretrigCount.ToString("0"); }
public int FindAnalogChansOfType(MccDaq.MccBoard DaqBoard, int AnalogType, out int Resolution, out MccDaq.Range DefaultRange, out int DefaultChan, out MccDaq.TriggerType DefaultTrig) { int ChansFound, IOType; MccDaq.ErrorInfo ULStat; bool CheckPretrig, CheckATrig = false; MccDaq.Range TestRange; bool RangeFound; // check supported features by trial // and error with error handling disabled ULStat = MccDaq.MccService.ErrHandling (MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop); TestBoard = DaqBoard; ATrigRes = 0; DefaultChan = 0; DefaultTrig = TriggerType.TrigPosEdge; DefaultRange = Range.NotUsed; Resolution = 0; IOType = (AnalogType & 3); switch (IOType) { case ANALOGINPUT: // Get the number of A/D channels ULStat = DaqBoard.BoardConfig.GetNumAdChans(out ChansFound); if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)) { clsErrorDefs.DisplayError(ULStat); return(ChansFound); } if (ChansFound > 0) { // Get the resolution of A/D ULStat = DaqBoard.BoardConfig.GetAdResolution(out ADRes); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { Resolution = ADRes; } // check ranges for a valid default RangeFound = TestInputRanges(out TestRange); if (RangeFound) { DefaultRange = TestRange; } } break; default: // Get the number of D/A channels ULStat = DaqBoard.BoardConfig.GetNumDaChans(out ChansFound); if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)) { clsErrorDefs.DisplayError(ULStat); return(ChansFound); } if (ChansFound > 0) { ULStat = TestBoard.GetConfig(2, 0, 292, out DARes); Resolution = DARes; RangeFound = TestOutputRanges(out TestRange); if (RangeFound) { DefaultRange = TestRange; } } break; } CheckATrig = ((AnalogType & ATRIGIN) == ATRIGIN); if ((ChansFound > 0) & CheckATrig) { ULStat = DaqBoard.SetTrigger(MccDaq.TriggerType.TrigAbove, 0, 0); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultTrig = MccDaq.TriggerType.TrigAbove; GetTrigResolution(); } else { ChansFound = 0; } } CheckPretrig = ((AnalogType & PRETRIGIN) == PRETRIGIN); if ((ChansFound > 0) & CheckPretrig) { // if DaqSetTrigger supported, trigger type is analog ULStat = DaqBoard.DaqSetTrigger(MccDaq.TriggerSource.TrigImmediate, MccDaq.TriggerSensitivity.AboveLevel, 0, MccDaq.ChannelType.Analog, DefaultRange, 0.0F, 0.1F, MccDaq.TriggerEvent.Start); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultTrig = MccDaq.TriggerType.TrigAbove; } else { ULStat = DaqBoard.SetTrigger(MccDaq.TriggerType.TrigPosEdge, 0, 0); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultTrig = MccDaq.TriggerType.TrigPosEdge; } else { ChansFound = 0; } } } ULStat = MccDaq.MccService.ErrHandling (clsErrorDefs.ReportError, clsErrorDefs.HandleError); return(ChansFound); }
// *----------------------------------------------------------------* // * Functions to take values * // *----------------------------------------------------------------* /// <summary> /// read the temperature and send it to the model /// </summary> public void ReadTemp() { float[] EngUnits; // [] car array System.UInt16 DataValue; // Collect the data by calling AIn memeber function of MccBoard object // Parameters: // Chan :the input channel number // Range :the Range for the board. // DataValue :the name for the value collected Range = Range.Bip10Volts; // selectionne un range de 10 V // on définit la taille de engunit EngUnits = new float[4]; // taking the values from the card for (int i = 0; i <= 3; i++) { ULStat = DaqBoard.AIn(i, Range, out DataValue); // on vérifie si le range est bon if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange) { MessageBox.Show("Range not upported by the card.", "Unsupported Range", MessageBoxButtons.OK); Application.Exit(); } ULStat = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits[i]);// converting to voltage float Value = (EngUnits[i] * 100F / 11F); Functions.SaveTemperature(i, Value); } }
private void GetRangeInfo(MccDaq.Range Range, out string RangeString, out float RangeVolts) { switch (Range) { case MccDaq.Range.NotUsed: RangeString = "NOTUSED"; RangeVolts = 0; break; case MccDaq.Range.Bip60Volts: RangeString = "BIP60VOLTS"; RangeVolts = 120; break; case MccDaq.Range.Bip30Volts: RangeString = "BIP30VOLTS"; RangeVolts = 60; break; case MccDaq.Range.Bip20Volts: RangeString = "BIP20VOLTS"; RangeVolts = 40; break; case MccDaq.Range.Bip15Volts: RangeString = "BIP15VOLTS"; RangeVolts = 30; break; case Range.Bip10Volts: RangeString = "BIP10VOLTS"; RangeVolts = 20; break; case Range.Bip5Volts: RangeString = "BIP5VOLTS"; RangeVolts = 10; break; case MccDaq.Range.Bip4Volts: RangeString = "BIP4VOLTS"; RangeVolts = 8; break; case Range.Bip2Pt5Volts: RangeString = "BIP2PT5VOLTS"; RangeVolts = 5; break; case MccDaq.Range.Bip2Volts: RangeString = "BIP2VOLTS"; RangeVolts = 4; break; case Range.Bip1Pt25Volts: RangeString = "BIP1PT25VOLTS"; RangeVolts = 2.5F; break; case Range.Bip1Volts: RangeString = "BIP1VOLTS"; RangeVolts = 2; break; case Range.BipPt625Volts: RangeString = "BIPPT625VOLTS"; RangeVolts = 1.25F; break; case Range.BipPt5Volts: RangeString = "BIPPT5VOLTS"; RangeVolts = 1; break; case Range.BipPt1Volts: RangeString = "BIPPT1VOLTS"; RangeVolts = 0.2F; break; case Range.BipPt05Volts: RangeString = "BIPPT05VOLTS"; RangeVolts = 0.1F; break; case MccDaq.Range.BipPt312Volts: RangeString = "BIPPT312VOLTS"; RangeVolts = 0.624F; break; case MccDaq.Range.BipPt25Volts: RangeString = "BIPPT25VOLTS"; RangeVolts = 0.5F; break; case MccDaq.Range.BipPt2Volts: RangeString = "BIPPT2VOLTS"; RangeVolts = 0.4F; break; case MccDaq.Range.BipPt156Volts: RangeString = "BIPPT156VOLTS"; RangeVolts = 0.3125F; break; case MccDaq.Range.BipPt125Volts: RangeString = "BIPPT125VOLTS"; RangeVolts = 0.25F; break; case MccDaq.Range.BipPt078Volts: RangeString = "BIPPT078VOLTS"; RangeVolts = 0.15625F; break; case Range.BipPt01Volts: RangeString = "BIPPT01VOLTS"; RangeVolts = 0.02F; break; case Range.BipPt005Volts: RangeString = "BIPPT005VOLTS"; RangeVolts = 0.01F; break; case Range.Bip1Pt67Volts: RangeString = "BIP1PT67VOLTS"; RangeVolts = 3.34F; break; case Range.Uni10Volts: RangeString = "UNI10VOLTS"; RangeVolts = 10; break; case Range.Uni5Volts: RangeString = "UNI5VOLTS"; RangeVolts = 5; break; case MccDaq.Range.Uni4Volts: RangeString = "UNI4VOLTS"; RangeVolts = 4.096F; break; case Range.Uni2Pt5Volts: RangeString = "UNI2PT5VOLTS"; RangeVolts = 2.5F; break; case Range.Uni2Volts: RangeString = "UNI2VOLTS"; RangeVolts = 2; break; case Range.Uni1Pt25Volts: RangeString = "UNI1PT25VOLTS"; RangeVolts = 1.25F; break; case Range.Uni1Volts: RangeString = "UNI1VOLTS"; RangeVolts = 1; break; case MccDaq.Range.UniPt25Volts: RangeString = "UNIPT25VOLTS"; RangeVolts = 0.25F; break; case MccDaq.Range.UniPt2Volts: RangeString = "UNIPT2VOLTS"; RangeVolts = 0.2F; break; case Range.UniPt1Volts: RangeString = "UNIPT1VOLTS"; RangeVolts = 0.1F; break; case MccDaq.Range.UniPt05Volts: RangeString = "UNIPT05VOLTS"; RangeVolts = 0.05F; break; case Range.UniPt01Volts: RangeString = "UNIPT01VOLTS"; RangeVolts = 0.01F; break; case Range.UniPt02Volts: RangeString = "UNIPT02VOLTS"; RangeVolts = 0.02F; break; case Range.Uni1Pt67Volts: RangeString = "UNI1PT67VOLTS"; RangeVolts = 1.67F; break; case Range.Ma4To20: RangeString = "MA4TO20"; RangeVolts = 16; break; case Range.Ma2To10: RangeString = "MA2to10"; RangeVolts = 8; break; case Range.Ma1To5: RangeString = "MA1TO5"; RangeVolts = 4; break; case Range.MaPt5To2Pt5: RangeString = "MAPT5TO2PT5"; RangeVolts = 2; break; case MccDaq.Range.Ma0To20: RangeString = "MA0TO20"; RangeVolts = 20; break; case MccDaq.Range.BipPt025Amps: RangeString = "BIPPT025A"; RangeVolts = 0.05F; break; case MccDaq.Range.BipPt025VoltsPerVolt: RangeString = "BIPPT025VPERV"; RangeVolts = 0.05F; break; default: RangeString = "NOTUSED"; RangeVolts = 0; break; } }