Actually, there are two ways to do this, if your card supports Digital Change Detection timing. Unfortunately the PCI-6250 does not, but the following cards do: PCI-6509, PXI-6509, PCI-6510, PCI-6511, PXI-6511, PCI-6514, PXI-6514, PXI-6514, PCI-6515, PXI-6515, PCI-6518, PCI-6519, PCI-6527, PXI-6527, PCI-6528, PXI-6528, PXI-6533, PCI-6533, PXI-6534, PCI-6534, and perhaps others.
In any case, if you do have one of these cards with hardware support for Digital Change Detection timing, then you can do one of the following:
a) Create a DI channel on your task, and then configure digital change detection timing using CNiDAQmxTiming::ConfigureChangeDetection(). Then perform either synchronous or asynchronous single-sample reads; when one of the digital lines of interest changes, then the blocking synchronous read will finish or the asynchronous read will call your callback. This is demonstrated with the Digital \ Read Values \ ReadDigChan_ChangeDetection example.
b) Create a DI channel on your task, configure digital change detection timing, and then set up a Digital Change Detection event on the task. This is demonstrated with the Digital \ Read Values \ ReadDigChan_ChangeDetection_Events example, although (a) is the preferred method.
Since the PCI-6250 doesn't support hardware digital change detection, what you have to do instead is to continuously read the status of the digital lines, and check to see if the lines went high programmatically. If you do not explicitly configure the timing for the acquisition, then the timing mode will be on-demand and the data will be read as fast as possible. You also have the option of calling CNiDAQmxTiming::ConfigureSampleClock() to configure the clock rate based off of another signal, such as PFI7. Here's a sample:
try
{
CNiDAQmxTask t("");
t.DIChannels.CreateChannel("6250/port0/line7:0", "", DAQmxOneChannelForAllLines);
t.Timing.ConfigureSampleClock("/6250/PFI7", 0,
DAQmxSampleClockActiveEdgeRising,
DAQmxSampleQuantityModeContinuousSamples, 1);
CNiDAQmxDigitalSingleChannelReader reader(t.Stream);
bool stopLoop = false;
while (!stopLoop)
{
CNiBoolVector data;
reader.ReadSingleSampleMultiLine(data);
for (unsigned int i = 0; i < data.GetSize(); i++)
{
if (data[i])
{
MessageBox("Went high.");
stopLoop = true;
break;
}
}
}
}
catch (CNiDAQmxException* ex)
{
ex->ReportError();
ex->Delete();
}
Hope this helps,
Hexar Anderson
Measurement Studio Software Engineer
National Instruments
Hexar Anderson
Measurement Studio Staff Software Engineer
National Instruments