LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NI DAQ mX migration in CVI

Hello,
I have serious problems to migrate from traditional to mX NI-DAQ drivers using LabWindows CVI. Unfortunately NI presses much more on LabView than on CVI, and I found only tutorials dealing with LabView (maybe I am wrong !).
Nevertheless, please find attached a piece of code which you will define "old style programming", but that actually is the only one I am able to deal with 🙂
I would so much appreciate if some of you experts around can translate that code using NI-DAQ mX functions rather than Traditional primitives. This will be of real help for me to begin walking inside this new driver.
Thanks in advance,
Marco Sartore
0 Kudos
Message 1 of 4
(3,385 Views)
Your program is doing a simple period measurement. You can essentially replace your program with four DAQmx function calls:
DAQmxCreateTask
DAQmxCreateCIPeriodChan
DAQmxReadCounterScalarF64
DAQmxClearTask

The first two DAQmx functions take the place of your first six GPCTR functions. Then, you just call DAQmxReadCounterScalarF64 once (not in a loop) and it will block until your reading is available (this replaces your two GPCTR_Watch calls). Then call DAQmxClearTask to clear the task.

I'm sure you'll find that counter operations are so much easier with DAQmx. Good luck to you.

Joe
Message 2 of 4
(3,364 Views)
Here are a couple of other suggestions: make use of the DAQ Assistant + Code generation, as well as the DAQmx C example programs, when getting up to speed with DAQmx.

Joe
0 Kudos
Message 3 of 4
(3,358 Views)
Many thanks for your help !
The Joe's step-by-step translation of my code was really helpful to me.
Let me try to go one step further: merely translating my code was a great thing and will work but does not generate optimized code, I mean not so optimized as DAQmx allow to do. Is it true ?
In fact, I believe that DAQmx allow to acquire multiple sample (i.e. multiple counter scalars) without the need of a formal acquisition loop (my "old" for). In this case I suppose that I can leave an acquisition task running freely, while another task only plots the acquired data. Should I use DAQmxReadCounterF64 function ? Where should I put my plotting instructions, maybe in an asynchronous timer callback routine, polling a data array and plotting the last fresh acquired samples ?
Many thanks again and best wishes,
Marco
0 Kudos
Message 4 of 4
(3,325 Views)