Discussion:
How do you start and stop a counter in matlab using nidaqmx? (Porting code from legacy)
(too old to reply)
jbert
2008-07-17 23:40:09 UTC
Permalink
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
Brooks_C
2008-07-18 22:40:07 UTC
Permalink
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&nbsp;article:&nbsp; <a href="http://digital.ni.com/public.nsf/allkb/FB26BDA52FFFD4EE86257124005C36C3?OpenDocument" target="_blank">Location of ANSI C NI-DAQmx Shipping Examples and DAQmx Library File for Windows</a>
&nbsp;
I hope this helps and have a great weekend!

Loading...