Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you generate finite trigger?

Using C++, how do you generate a finite trigger for an analog input, on the rising slope of the signal?
 
I am using a NI PCI-6251 card.
 
I would like a DoneEvent to execute when the first rising slope occurs.
 
Thanks,
Kevin
0 Kudos
Message 1 of 5
(4,440 Views)
Hi Kevin,

I hope you're doing well.  It sounds like you would like to have an analog acquisition of finite points, but only have it begin when this analog signal crosses a configurable threshold with a rising slope.  I am assuming you are using Microsoft Visual C++, but don't have our Measurement Studio package.  In this case, you would be using the C API provided in the NI-DAQmx driver.  The following KnowledgeBase discusses details of these examples.  There is a programming example that ships with the driver that does this task that you should reference.  If you have the C API support installed for the NI-DAQmx driver, then you will find the example in the following directory: C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Voltage\Acq-Int Clk-Anlg Start .  This application lets you specify the number of points you want to acquire as well as other acquisition settings. There are parameters for the threshold that your signal must cross to trigger the acquisition and whether you are looking for a rising or falling edge.  Take a look at this example and let us know if you have any follow up questions.  Also, if my assumptions were incorrect, please steer me in the right direction with more information and I will be glad to help.  Have a great day!

Thaison V
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(4,432 Views)
Hi Thaison,
 
I have modified the example program Acq-Int Clk-Anlg Start so that two points are acquired.
 
DAQmxCfgSampClkTiming(taskHandle,"", 100000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2);
DAQmxCfgAnlgEdgeStartTrig(taskHandle, "APFI0", DAQmx_Val_RisingSlope, 3.0);
DAQmxStartTask(taskHandle);
while(1)
{
 DAQmxReadAnalogF64(taskHandle, -1 ,-1,DAQmx_Val_GroupByScanNumber,data,1000,&read,NULL);
 DAQmxStopTask(taskHandle);
 // send a time stamp to output file.
 DAQmxCfgAnlgEdgeStartTrig(taskHandle, "APFI0", DAQmx_Val_RisingSlope, 3.0);
 DAQmxStartTask(taskHandle);
}
 
The problem is that that this program only triggers 4 times per second.  The input signal that I am using has a freq of 10 kHz.  The card I am using is a NI PCI-6251.
 
Why am I not getting more samples per second?
 
Kevin
 
0 Kudos
Message 3 of 5
(4,335 Views)

Hi Kevin,

Modifying an existing example is a great way to start an application. It sounds like you are trying to use an analog trigger to retrigger an analog input operation. Would it be possible for you to either:

- use a digital trigger? This way you could use the digital trigger to retrigger a counter output operation and use the counter as the sample clock.

- continuously acquire your data and filter out unwanted data in post processing?

Regards,
Hal L.

0 Kudos
Message 4 of 5
(4,320 Views)

Before I try another approach I would like to understand the existing code.

The problem is that that this program only triggers 4 times per second.

Why am I not getting more samples per second?
 
DAQmxCfgSampClkTiming(taskHandle,"", 100000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2);
DAQmxCfgAnlgEdgeStartTrig(taskHandle, "APFI0", DAQmx_Val_RisingSlope, 3.0);
DAQmxStartTask(taskHandle);
while(1)
{
 DAQmxReadAnalogF64(taskHandle, -1 ,-1,DAQmx_Val_GroupByScanNumber,data,1000,&read,NULL);
 DAQmxStopTask(taskHandle);
 // send a time stamp to output file.
 DAQmxCfgAnlgEdgeStartTrig(taskHandle, "APFI0", DAQmx_Val_RisingSlope, 3.0);
 DAQmxStartTask(taskHandle);
}
0 Kudos
Message 5 of 5
(4,307 Views)