05-01-2014 12:37 PM
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();
}
Solved! Go to Solution.
05-01-2014 04:25 PM
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):
Best Regards,
05-02-2014 12:16 PM
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();
}
05-02-2014 12:40 PM
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,