Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Porting strategy - NIDAQ application to NIDAQmx



I am having an application, with a large code base, that uses NIDAQ driver APIs. I want to make my application supported in Windows Vista. I came to know that NI does not support NIDAQ under Windows Vista. So in Vista NIDAQmx driver should be used. This application uses around 20 functions of NIDAQ driver APIs.


My idea is to create a new DLL with name nidaq32.dll and export NIDAQ functions which are used by the application. From within the exported functions corresponding NIDAQmx functions will be called to implement the functionality.


Is this method practical? Is it possible, using this method, to implement functions of NIDAQ using NIDAQmx driver?


Some of the functions used are DAQ_Op, DIG_In_Line, DIG_Line_Config, DIG_Prt_Config, GPCTR_Control, GPCTR_Change_Parameter, GPCTR_Config_Buffer, GPCTR_Read_Buffer, GPCTR_Set_Application, GPCTR_Watch, Init_DA_Brds, Select_Signal etc




Message Edited by on 05-02-2008 07:20 AM
0 Kudos
Message 1 of 22
Hi Praveenda,

We did something similar with the Traditional DAQ compatibility VIs - we bascially replaced all the Traditional DAQ function calls in LabVIEW with DAQmx code within the subVIs. This worked in some situations for some customers, but has proven pretty hard to maintain. They were really created to help developers transition to DAQmx rather than be a long term solution. I would recommend just rewriting your code in DAQmx - it may not be as hard as you think. There are several shipping example programs that cover most of the functionality of our MIO boards so some of it would be cut and paste with changes in paremeters. I think long term this would be the most maintainable solution.

As far as possible, it seems like it should work as long as you can create a good .dll and header file. Just realize that either way you'll need to learn DAQmx.

We are more than happy to help you convert your lagacy code to DAQmx. It is not an easy process (others will probably chime in about their experience) but in the end will give you functioning program and will open up the possiblity to use newer HW.

Andrew S
0 Kudos
Message 2 of 22


1. While porting an application using NI-DAQ APIs to NI-DAQmx APIs, I found it difficult to find an equivalent function(s) in NI-DAQmx for DIG_Prt_Config(). Is there any function in NI-DAQmx, which can be used to replace DIG_Prt_Config?

2. I am overriding NIDAQ functions. From this overridden functions corresponding NIDAQmx functions are called to do the exact functionality. I am facing several unknowns in my path. One of it is the mapping between NIDAQ and NIDAQmx return values.

How can I translate NIDAQ return values to NIDAQmx return values?




0 Kudos
Message 3 of 22


1. Dig_Prt_Config performs a lot of different actions for a lot of different devices. For several of these operations you need to use multiple functions from DAQmx. What HW are you using, and what are you trying to do with it?

2. By return values, are you referring to the error code and values passed back by all functions? Again, this will depend a lot on the function calls...

Let me just say, there is not a 1 to 1 mapping of Traditional DAQ and DAQmx functions. When the driver was redesigned, the API was redesigned as well. In some cases things are very similar but in others they differ greatly. I have ported a lot of code from Traditional to DAQmx, and find that it is easier for me to figure out what the Traditional DAQ code is doing, then port that concept over to DAQmx. I don't worry about matching up function calls. As long as you know that a piece of code in Traditional DAQ uses two counters to perform a frequency measurement then it does not matter what Traditional DAQ functions were used (there are usually several ways to do the same thing in both APIs) because you know how to achieve the same thing in DAQmx.

I realize this may not sound as easy as just replacing the functions with DAQmx code, but I think you're just beginning to see the complexity of matching up DAQmx code with legacy functionality. There are a couple resources out there, this one is good for C:

Transitioning from Traditional NI-DAQ (Legacy) to NI-DAQmx Using ANSI C and NI LabWindows™/CVI

It has a good overview of the differences and porting code, though I'm afraid it will be missing some of the specifics that you're looking for. Hopefully it will remove some of the unknowns.

Hope this helps,

Andrew S 

Message Edited by stilly32 on 05-05-2008 05:39 PM
0 Kudos
Message 4 of 22


The above said application uses NI 6013 PCI. I dont know what exactly the application does.

I am trying to develop an adapter DLL which will recieve the NI-DAQ function calls and implements the functionality by using NI-DAQmx APIs. That is why I am trying to map functions in NI-DAQ with NI-DAQmx. Is this method feasible?



0 Kudos
Message 5 of 22


It is feasible if you have an understanding of Traditional DAQ and DAQmx. In order to do this, you would need to figure out what the Traditional DAQ function call was setting up in HW and translate that to a DAQmx function call. Since it is not a 1 to 1 mapping, you would need to build up some code to acount for different situations.

Looking at Dig_Prt_Config, let's look at two cases. ***

Dig_Prt_Config(1, 0, 0) means that device 1, port 0 will be configured for input. In DAQmx, you would use

DAQmxCreateTask("", taskHandle);     //create task

DAQmxCreateDIChannel(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);     //create input channel for port 0


Dig_Prt_Config(1, 0 , 1) means that device 1, port 0 will be configured for output. In DAQmx, you would use

DAQmxCreateTask("", taskHandle);     //create task

DAQmxCreateDOChannel(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);     //create input channel for port 0

This is just taking into account changing one parameter. Other parameters will require different function calls and settings dependent on the use cases... for a limited set of functions this may not be that hard, but you will need to spend some time with the C function help for both DAQmx and Traditional DAQ to translate things. However, creating this wrapper may prove more work than just replacing the code - instead of creating a function that looks at each TDAQ parameter and uses that to make decisions on how each DAQmx function call is used and how it may be easier to just rewrite your Traditional DAQ code on case by case basis. If you stick with writing a wrapper, you're going to need to figure out how to maintain different DAQmx Tasks among the different calls, and the way buffers and events are handled may not map directly.  

As a broad generalization, I think it is easier to write new code than to create a wrapper.


Andrew S


*** I don't code in C that often so my code may be off a bit but you should get the idea.

Message Edited by stilly32 on 05-07-2008 11:32 AM
0 Kudos
Message 6 of 22
Andrew, thank you very much.
I understood the difficulty in the srategy, but I have no other option, since the application was in VB 6.0 and me a beginer in VB!
My plan is to develop the adapter dll in C/C++ with minimum functionality, which is required by the application.
Some more issues listed below.
Two other functions used in the application are
1. DIG_In_Line
2. DIG_Out_Line
From other threads I came to understood that DIG_In_Line can be replaced with DAQmxReadDigitalLines and DIG_Out_Line can be replaced with DAQmxWriteDigitalLines.
But using this DAQmx functions how can I read or write a single bit (Line)?
for example
DIG_Out_Line(DAQ_Board_No, Port%, 1, 0)
DIG_In_Line(DAQ_Board_No, Port%, BitNo%, BitVal%)
0 Kudos
Message 7 of 22


How can I translate NI-DAQ Select_Signal() to NI-DAQmx? (NI 6013 PCI)

Two scenario of select signal used are;

Select_Signal(DAQ_Board_No, ND_PFI_2, ND_IN_CONVERT, ND_HIGH_TO_LOW)



0 Kudos
Message 8 of 22


For reading/writing digital lines, check out the "Write Dig Chan" and "Read Dig Chan" shipping examples. In XP you can find them here - C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\

The documentation in the examples is probably your best resource.

For the Select_Signals, again you'll have to figure out what these are doing and translate this to DAQmx. For:

Select_Signal(DAQ_Board_No, ND_PFI_2, ND_IN_CONVERT, ND_HIGH_TO_LOW)

If you check the Traditional DAQ C function reference Help (under Start>>All Programs>>National Instruments>>NI-DAQ if you haven't found it yet) you'll see that that function is just connecting ND_IN_CONVERT to PFI_2. In DAQmx you can do this with DAQmxExportSignal() - check the DAQmx C Reference Help on how to use it. 

0 Kudos
Message 9 of 22

Thank you very much.

One more usage of Select_Signal is


What the above function call will perform?

Can I use DAQmxExportSignal() to translate the above call to DAQmx?

Does the DAQmxConnectTerms() can be used instead of DAQmxExportSignal()?

thanks in advance


0 Kudos
Message 10 of 22