Multifunction DAQ

取消
显示结果 
搜索替代 
您的意思是: 

two edge separation using a digital output

已解决!
转到解答

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 项奖励
1 条消息(共 4 条)
4,502 次查看

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 项奖励
2 条消息(共 4 条)
4,491 次查看

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 项奖励
3 条消息(共 4 条)
4,466 次查看
解答
已被主题作者 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
4 条消息(共 4 条)
4,464 次查看