Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you start and stop a counter in matlab using nidaqmx? (Porting code from legacy)

I am trying to convert C legacy nidaq functions to nidaq mx  for use in Matlab.  I didn't write the code and am note familar with either Nidaq or Nidaqmx functions or syntax, so I've been having a lot of difficulty with something that should be simple.

Here is the legacy code for starting a counter on the board.

  errcheck(GPCTR_Control(device, ND_COUNTER_0, ND_RESET));
  errcheck(GPCTR_Set_Application(device, ND_COUNTER_0, ND_PULSE_TRAIN_GNR));
  errcheck(Select_Signal(device, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT, 
              ND_LOW_TO_HIGH));
  errcheck(GPCTR_Change_Parameter(device, ND_COUNTER_0, ND_COUNT_1, ncounts));
  errcheck(GPCTR_Change_Parameter(device, ND_COUNTER_0, ND_COUNT_2, ncounts));
  errcheck(GPCTR_Control(device, ND_COUNTER_0, ND_PROGRAM));

Here is the legacy code to stop the counter.

  errcheck(GPCTR_Control(device, ND_COUNTER_0, ND_RESET));
  errcheck(Select_Signal(device, ND_GPCTR0_OUTPUT, ND_NONE,
             ND_DONT_CARE));

Any help in converting this would be much appreciated.

Thanks,

Julie
0 Kudos
Message 1 of 2
(3,091 Views)
Hello Jbert,
 
The Traditional NI-DAQ (legacy) driver and the NI-DAQmx drivers are fairly different--there aren't exactly equivalent functions for every traditional function.  I think it would be best for you to look at the text based examples NI-DAQmx counter's in ANSI C.  If you installed C support for the NI-DAQmx Driver these examples should be located in this directory for the current version of DAQmx:  C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter.
 
For specific paths for all example folders please see this KnowledgeBase article:  Location of ANSI C NI-DAQmx Shipping Examples and DAQmx Library File for Windows
 
I hope this helps and have a great weekend!
Brooks
0 Kudos
Message 2 of 2
(3,074 Views)