Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Reference Trigger

I am using Microsoft Visual Studios 2008, PCI 6602 Counter/Timer board, and NI-DAQmx driver version 9.5.1. 

 

I am trying to set up a timer that will count upon the initiation of the program, and stop counting on when a connected power supply reachs a minimum voltage threshold. 

 

To get started with this, I am using two NI examples.  I am using the Continuous Digital Pulse Train to generate the pulse (on counter 1) and this pulse is sent to counter 0, which is being utilized by the Pulse Width Measurement example.  My solution was to add the trigger configuration to the pulse width C++ file, but I am encountering errors with this.

 

The Pulse Generation function has not been changed, so I assume it is correct, but here are the mian functions I use in the Pulse Width program:

 

      /*********************************************/

      // DAQmx Configure Code

      /*********************************************/

      DAQmxErrChk (DAQmxCreateTask("PulseWidth",&taskHandle));

 

      DAQmxErrChk (DAQmxCreateCIPulseWidthChan(taskHandle,"Dev3/ctr0","",0.000000100,10.0000000,DAQmx_Val_Seconds,DAQmx_Val_Rising,""));

 

      //DAQmxErrChk (DAQmxCfgAnlgEdgeRefTrig (taskHandle1, "Dev3/APFI28", DAQmx_Val_RisingSlope , 5.00000, 0));

 

      /*********************************************/

      // DAQmx Start Code

      /*********************************************/

      DAQmxErrChk (DAQmxStartTask(taskHandle));

 

      /*********************************************/

      // DAQmx Read Code

      /*********************************************/

 

 

      while (x != 100){

      DAQmxErrChk (DAQmxReadCounterScalarF64(taskHandle,10.0,&data[x],0));

    printf("%d: %.9f sec\n", x, data[x]);

 

      x++;

      }

 

I receive Status Code: -200474, Error: Specified operation did not complete, because the specified timeout expired.

Any idea how to fix this error? 

Once the base level programs are executing (generating and reading continuous pulses only), I need to add the trigger.  If you notice, it is commented out in my program because it was giving me all sorts of problems.  How do I establish the channel to read the trigger pulse (from a DC power supply)?

 

Thanks in advance for any help.

0 Kudos
Message 1 of 3
(5,526 Views)

I have solved the first problem with getting the programs to be functional on a basic level.  All I needed to do was implicitly configure the sample clock.  The code now looks as follows:

      /*********************************************/

      // DAQmx Configure Code

      /*********************************************/

      DAQmxErrChk (DAQmxCreateTask("PulseWidth",&taskHandle));

 

      DAQmxErrChk (DAQmxCreateCIPulseWidthChan(taskHandle,"Dev3/ctr0","",0.000000100,10.0000000,DAQmx_Val_Seconds,DAQmx_Val_Rising,""));

      DAQmxErrChk (DAQmxCfgImplicitTiming( taskHandle, DAQmx_Val_ContSamps , 1000));                             //new line

 

 

      //DAQmxErrChk (DAQmxCfgAnlgEdgeRefTrig (taskHandle1, "Dev3/APFI28", DAQmx_Val_RisingSlope , 5.00000, 0));

 

      /*********************************************/

      // DAQmx Start Code

      /*********************************************/

      DAQmxErrChk (DAQmxStartTask(taskHandle));

 

      /*********************************************/

      // DAQmx Read Code

      /*********************************************/

 

 

      while (x != 100){

      DAQmxErrChk (DAQmxReadCounterScalarF64(taskHandle,10.0,&data[x],0));

    printf("%d: %.9f sec\n", x, data[x]);

 

      x++;

      }

 

Now, any help configuring the trigger?  Do I need to establish an analog voltage input channel and new task before configuring the trigger, and how do I link the trigger to the input counter?

0 Kudos
Message 2 of 3
(5,523 Views)

Hello Zach,

 

There is a Reference Help for NI-DAQmx C environment.

 

You can find it in 'National Instruments >> NI-DAQ >> Text Based Code Support >> NI-DAQmx C Reference Help'.

 

There are different trigger types that you can use depending of your needs.

 

In the 'taskHandle' you set the counter, and in the 'triggerSource' you set the analog source that you want to use as a trigger.

 

The help file I am referring you is very helpful to understand how the commands work.

 

Mr.O
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(5,511 Views)