public double Meas2EdgeSeparation(string lines, double min, double max, CITwoEdgeSeparationFirstEdge firstEdge, CITwoEdgeSeparationSecondEdge secondEdge, int Timeout) { // This example uses the default source (or gate) terminal for // the counter of your device. To determine what the default // counter pins for your device are or to set a different source // (or gate) pin, refer to the Connecting Counter Signals topic // in the NI-DAQmx Help (search for "Connecting Counter Signals"). // Uses default PFI 9/P2.1 as the pulse input. double pulseGap = 0; Task myTask = null; NationalInstruments.DAQmx.CounterReader myCounterReader; try { myTask = new Task(); myTask.Stream.Timeout = Timeout; myTask.CIChannels.CreateTwoEdgeSeparationChannel( lines, "", min, max, firstEdge, secondEdge, CITwoEdgeSeparationUnits.Seconds); myCounterReader = new CounterReader(myTask.Stream); pulseGap = myCounterReader.ReadSingleSampleDouble(); } catch (DaqException exception) { mstr_Error = exception.Message; pulseGap = 0; } finally { if (myTask != null) { myTask.Dispose(); } } return(pulseGap); }
//Measures the separation of two PW on PFI 9(P2_1) and PFI10(P2_2) public double Meas2EdgeSeparation(string lines, CITwoEdgeSeparationFirstEdge firstEdge, CITwoEdgeSeparationSecondEdge secondEdge) { double PW = 0; int i_Timeout = 2000; //unit:ms double minPW_InSeconds = 0.00000010; double maxPW_InSeconds = 0.838860750; PW = Meas2EdgeSeparation(lines, minPW_InSeconds, maxPW_InSeconds, firstEdge, secondEdge, i_Timeout); return(PW); }