From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

C/C++ triggered voltage capture

I am trying to use the APFI0 input to capture on 4 voltage channels.  No matter what I do, I get the error -200284 on my call to ReadAnalogF64.  I am using a NI-USB-6259 with mass termination.  I have two BNC-2110s plugged in and I have tried the APFI0 line on both 2110s.  I have also tried the APFI1 line in the code.  I get the same result.  I have also tried to perform the same triggered function with the NI measurement and automation application.  It never triggeres here either.  Finally, I verified that the voltage going to the APFI0 line is changing as expected.  It is a saw-tooth waveform with a period of 50 mS ranging from 0 to 10 volts.  Can someone please look at my code below and make some suggestions.  Thank you. 
 
Joe Wilbur
 
void DAQ_CaptureVoltageSamples(double* volt_buff, int32 N)
{
  TaskHandle task = NULL;
  int32      spc;
  int32      ret;
 
  DAQmxCreateTask("task_in", &task);
  DAQmxCreateAIVoltageChan(task, "Dev1/ai0:3", "Inchan", -1, -0.2, 0.2, DAQmx_Val_Volts, NULL);
  ret = DAQmxCfgSampClkTiming(task, NULL, SAMPLE_RATE/4, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, N);
  ret = DAQmxCfgAnlgEdgeStartTrig(task, "apfi0", DAQmx_Val_FallingSlope, 2.5);
  ret = DAQmxReadAnalogF64(task, N, 2.0, DAQmx_Val_GroupByChannel, volt_buff, 4*N, &spc, NULL);

 
  DAQmxStopTask(task);
  DAQmxClearTask(task);
}
0 Kudos
Message 1 of 3
(2,546 Views)

Hi JWilber,

The error you are receiving indicates that the program times out. I believe this is because there is not DAQmxStartTask in your code. This should be put in between the StartTrig and ReadAnalog64. There are many helpful example programs that install with DAQmx which can be located under C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C or C:\Program Files\National Instruments for MS2003, 2005. If you are still having problems after this, please post what program you are using for development.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 2 of 3
(2,534 Views)

Thank you for your reply.

I have it working now.  The error was that I am using a BNC-2110 box and it doesn not break out the APFI0 signal.  I was actually using the PFI0 connection.  In other words, I was configuring my code for an analog trigger and plugging my signal into a digital trigger input.  My solution was to put my 10 volt signal through a simple voltage divider to bring it down to digital IO levels and simply use the digital trigger.

I'm triggering fine now.

Thank you again for taking the time to read and reply to my question.

-Joe Wilbur

0 Kudos
Message 3 of 3
(2,530 Views)