Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

two edge separation using a digital output

Solved!
Go to solution

I am using a PXI-6229 DAQ card and programming in C# .net.

 

I am asserting a falling edge on PFI12 used as a digital output, and I need to measure the time between that edge and a second rising edge on PFI8 used as a digital input.  I have set up the code using some examples I have found.  I do not know when to to assert the signal on PFI12 in order to be read at the correct time.  The read needs to be set up before the signal is asserted but I do not know how to set it it up correctly.

Here is the code I have so far:

 

public void MeasureAcquisitionTime()
        {
            DigitalSingleInputTask = new Task();
            CIChannel counterSetup;
            firstEdge = CITwoEdgeSeparationFirstEdge.Falling;
            secondEdge = CITwoEdgeSeparationSecondEdge.Rising;
            double minTime = 10e-3;
            double maxTime = 60e-3;
            string auxCounterInput = "/" + CardName + "/PFI12";
            string gateCounterInput = "/" + CardName + "/PFI8";
            
            counterSetup = DigitalSingleInputTask.CIChannels.CreateTwoEdgeSeparationChannel(
                CardName + "/ctr1", "counter",
                minTime,
                maxTime,
                firstEdge, secondEdge, CITwoEdgeSeparationUnits.Seconds);
            counterSetup.TwoEdgeSeparationFirstTerminal = auxCounterInput;
            counterSetup.TwoEdgeSeparationSecondTerminal = gateCounterInput;
            DigitalSingleInputTask.Control(TaskAction.Verify);
            runningDigitalTask = DigitalSingleInputTask;
            counterInReader = new CounterReader(DigitalSingleInputTask.Stream);
            double data = counterInReader.ReadSingleSampleDouble();
        }

 

 

0 Kudos
Message 1 of 4
(3,943 Views)

The problem with using "on demand" timing in this case is that the read itself initiates the measurement, but it also blocks until the measurement has completed making it difficult to programmatically issue the initial pulse at the right time. 

 

One solution would be to split the read call and the digital output into two separate threads, but I prefer to do this instead (don't have the .NET API installed at the moment so can't give the exact syntax):

 

    1. configure finite implicit timing on the counter input task (2 samples is the minimum, that's OK)
    2. start the task (with implicit timing configured the start of the task will initiate the measurement)
    3. issue your pulse on the digital output task
    4. read 1 sample from your counter task

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 4
(3,932 Views)

Thanks John.  It is now working.  Is there a way to do a two edge separation measurement using analog inputs on the PXI-6229?  Here is my solution for the two edge separation using a digital output:

 

public void MeasureAcquisitionTime()
        {
            DigitalSingleInputTask = new Task();
            CIChannel counterSetup;
            firstEdge = CITwoEdgeSeparationFirstEdge.Falling;
            secondEdge = CITwoEdgeSeparationSecondEdge.Rising;
            double minTime = 10e-3;
            double maxTime = 60e-3;
            string auxCounterInput = "/" + CardName + "/PFI12";
            string gateCounterInput = "/" + CardName + "/PFI8";
           
            counterSetup = DigitalSingleInputTask.CIChannels.CreateTwoEdgeSeparationChannel(
                CardName + "/ctr1", "counter",
                minTime,
                maxTime,
                firstEdge, secondEdge, CITwoEdgeSeparationUnits.Seconds);
            
            DigitalSingleInputTask.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples, 2);


            counterSetup.TwoEdgeSeparationFirstTerminal = auxCounterInput;
            counterSetup.TwoEdgeSeparationSecondTerminal = gateCounterInput;
           
            DigitalSingleInputTask.Control(TaskAction.Verify);
            runningDigitalTask = DigitalSingleInputTask;
          
            counterInReader = new CounterReader(DigitalSingleInputTask.Stream);
           
            DigitalSingleInputTask.Start();
            TurnPowerRelay_On(true);  //Asserting the digital output
            
            double data = counterInReader.ReadSingleSampleDouble();
          
        }

0 Kudos
Message 3 of 4
(3,907 Views)
Solution
Accepted by topic author paofthree

Glad to hear it.


@paofthree wrote:

 Is there a way to do a two edge separation measurement using analog inputs on the PXI-6229?  


The only way would be to continuously acquire the analog input voltage and calculate the two edge separation in software.

 

 

Best Regards,

John Passiak
Message 4 of 4
(3,905 Views)