Discussion:
Porting strategy - NIDAQ application to NIDAQmx
(too old to reply)
praveenda@gmail.com
2008-05-02 12:40:11 UTC
Permalink
Hello

 

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

 

Regards

PraveendaMessage Edited by ***@gmail.com on 05-02-2008 07:20 AM
stilly32
2008-05-02 16:10:09 UTC
Permalink
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. cheers, Andrew S
praveenda@gmail.com
2008-05-05 04:40:05 UTC
Permalink
Hello
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.ffice<img src="/i/smilies/16x16_smiley-surprised.gif" width="16" height="16" border="0">ffice" prefix="o" />


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

&nbsp;

regards

Praveen.DA
stilly32
2008-05-05 22:40:07 UTC
Permalink
Hi,
1. Dig_Prt_Config&nbsp;performs a lot of different actions&nbsp;for a lot of different devices.&nbsp;For&nbsp;several of these operations you need to use&nbsp;multiple functions from DAQmx. What HW are you&nbsp;using, and what are you trying to do with it?
2.&nbsp;By&nbsp;return values, are you&nbsp;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&nbsp;but in others they differ greatly.&nbsp;I have&nbsp;ported a lot of code from Traditional to DAQmx, and find&nbsp;that it is easier for me to figure out what the Traditional DAQ code is doing, then port&nbsp;that concept over to DAQmx. I don't worry about matching up function calls. As long as you know that&nbsp;a piece of code in Traditional DAQ uses two counters to perform a&nbsp;frequency measurement then it does not matter what&nbsp;Traditional DAQ&nbsp;functions were used (there are usually several ways to do the same thing in both APIs) because you know how to achieve the same&nbsp;thing in DAQmx.
I realize this may not sound as easy as just replacing the functions with DAQmx code, but&nbsp;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:
<a href="http://zone.ni.com/devzone/cda/tut/p/id/5957" target="_blank">Transitioning from Traditional NI-DAQ (Legacy) to NI-DAQmx Using ANSI C and NI LabWindows?/CVI</a>
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&nbsp;Message Edited by stilly32 on 05-05-2008 05:39 PM
praveenda@gmail.com
2008-05-07 08:40:09 UTC
Permalink
Hello
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.&nbsp;That is why I am trying to map functions in NI-DAQ with NI-DAQmx.&nbsp;Is this method feasible?
regards
Praveenda
stilly32
2008-05-07 16:40:17 UTC
Permalink
Praveenda,
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);&nbsp;&nbsp;&nbsp;&nbsp; //create task
DAQmxCreateDIChannel(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);&nbsp;&nbsp;&nbsp;&nbsp; //create input channel for port 0
&nbsp;
Dig_Prt_Config(1, 0 , 1 ) means that device 1, port 0 will be configured for output. In DAQmx, you would use
DAQmxCreateTask("", taskHandle);&nbsp;&nbsp;&nbsp;&nbsp; //create task
DAQmxCreateDOChannel(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);&nbsp;&nbsp;&nbsp;&nbsp; //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&nbsp;events are handled may not map directly. &nbsp;
As a broad generalization, I think it is easier to write new code than to create a wrapper.
cheers,
Andrew S
&nbsp;
*** 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
praveenda@gmail.com
2008-05-13 07:10:06 UTC
Permalink
Andrew, thank you very much.
&nbsp;
I understood the difficulty in the srategy, but I have no other option, since the application was in VB 6.0 and&nbsp;me a&nbsp;beginer in VB!
My plan is to develop the adapter dll in C/C++ with minimum functionality, which is required by&nbsp;the application.
&nbsp;
Some more issues listed below.
&nbsp;
Two other functions used in the application are
1. DIG_In_Line
2. DIG_Out_Line
&nbsp;
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.
&nbsp;
But using this DAQmx functions how can I read or write a single bit (Line)?
&nbsp;
for example
DIG_Out_Line(DAQ_Board_No, Port%, 1, 0)
DIG_In_Line(DAQ_Board_No, Port%, BitNo%, BitVal%)
&nbsp;
regards
PraveenDA
&nbsp;
praveenda@gmail.com
2008-05-14 06:10:06 UTC
Permalink
Hello
How can I&nbsp;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)Select_Signal(DAQ_Board_No, ND_SCANCLK_LINE, ND_SCANCLK, ND_LOW_TO_HIGH)
regards
Praveenda
stilly32
2008-05-14 16:40:09 UTC
Permalink
Praveenda,
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&gt;&gt;All Programs&gt;&gt;National Instruments&gt;&gt;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.&nbsp;
praveenda@gmail.com
2008-05-23 10:10:08 UTC
Permalink
Thank you very much.
One more usage of Select_Signal is
Select_Signal(NIDAQBoardNo, ND_SCANCLK_LINE, ND_SCANCLK, ND_LOW_TO_HIGH)
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
Praveenda
BrowningG
2008-05-28 00:40:11 UTC
Permalink
Hello Praveenda,

The Traditioanl DAQ C Reference help that Andrew mentioned has some great information on all of the parameters for this particular function.&nbsp; This instance of the signal connects ND_SCANCLK_LINE to ND_SCANCLK in the same manner as the pins are connected in the above post.&nbsp; So you can use the DAQmxExportSignal() to route these signals as well.&nbsp;

The DAQmxExportSignal() is used to route signals based on a task.&nbsp; If you connect two particular pins in a task using the DAQmxExportSignal(), this connection will be undone when the task is cleared.&nbsp; This is good so that you do not accidently try to connect signals that could damage your device or cause unexpected results.&nbsp; The DAQmxConnectTerms() uses immediate routing and is not task based.&nbsp; As a result it is pretty similar to Select_Signal().&nbsp; You can see more information about it in the DAQmx C Reference Help.&nbsp; One thing to note is that much of the routing needed from Traditional DAQ is done implicitly by DAQmx so you might not need all of these functions depending on the hardware configuration.&nbsp; This <a href="http://digital.ni.com/public.nsf/allkb/DBADA18949DA4BDB86256C10006EA66F?OpenDocument" target="_blank">knowledgebase</a> provides some more information on these pins exactly so you can see what you are routing. &nbsp;
praveenda@gmail.com
2008-05-29 05:10:06 UTC
Permalink
Thank you very much.
While creating a channel (voltage) a maximum and minimum value is needed. How it can be calculated/understand from legacy source (which uses NI-DAQ driver).
My legacy source is using following listed functions (NI-6013 PCI)DAQ_CheckDAQ_ClearDAQ_OpDAQ_RateDAQ_StartDIG_In_LineDIG_Line_ConfigDIG_Out_LineDIG_Out_PrtDIG_Prt_ConfigSelect_Signal
regardsPraveenda
Dennis Knutson
2008-05-29 13:40:11 UTC
Permalink
You don't create an analog channel for a digital task. You would be using DAQmxCreateDIChan or DAQmxCreateDOChan.
&nbsp;
These functions have already been mentioned by Andrew as the replacements for your old digital functions.Message Edited by Dennis Knutson on 05-29-2008 07:26 AM
praveenda@gmail.com
2008-05-30 04:40:07 UTC
Permalink
Sorry, in the legacy code both analog and digital channels are used. I am trying to port DAQ_Op function. My understanding is, DAQ_Op function is an analog, synchronous&nbsp;data read function.
For that,
1.&nbsp;Created a task using DAQmxCreateTask()
2. Created a AI channel using DAQmxCreateAIVoltageChan()
3. Set clock timing using DAQmxCfgSampClkTiming()
4. Started the task using DAQmxStartTask()
5. Read the data using DAQmxReadAnalogF64()
6. Clean up task.
Am I doing right in porting DAQ_Op function?
In step 2, minimum and maximum value of the signal is needed. Can this be found from any parameter (like sampleRate) of DAQ_Op function or any other function?
In the legacy code analog functions used are DAQ_Rate, DAQ_Start, DAQ_Check, DAQ_Clear and DAQ_Op.
thanks and regards
Praveen.da
Dennis Knutson
2008-05-30 15:10:14 UTC
Permalink
Sorry, missed the reference to DAQ_Op. With DAQmx, you specify an input voltage range and the driver automatically sets the correct gain of the device. While it is simple to get the supported voltage ranges of a device in DAQmx, i'm not sure how that corresponds to a gain setting.
BrowningG
2008-05-30 20:40:07 UTC
Permalink
Hello Praveenda,

The steps you have enumerated above are how you would create a hardware timed task using DAQmx.&nbsp; When you create a voltage channel you must set the maximum and minimum voltage values you expect to read.&nbsp; DAQmx then uses this information to set the appropriate gain settings for your device.&nbsp; You can use the specifications sheet for your hardware to determine the available hardware voltage levels.&nbsp; For instance a <a href="http://digital.ni.com/manuals.nsf/websearch/210C73CBF91128B9862572FF0076BE85" target="_blank">PCI-6251</a> has several different hardware ranges available (±10 V, ±5 V, ±2 V, ±1 V, ±0.5 V, ±0.2 V, ±0.1 V). &nbsp; DAQmx will pick the best hardware range that includes your software limits (this will get you the best resolution).&nbsp; As a result, DAQmx will set the gain automatically for you in the background.&nbsp; To find the maximum available values for any setting in your DAQmx task, consult your device?s specifications sheet.&nbsp; This will provide the maximum voltage range, sample rate, etc.&nbsp;
martyneccles
2008-07-26 19:10:06 UTC
Permalink
Hi
I am doing a fairly simple port, converting software originally written for a NI6601 in Legacy NIDAQ&nbsp;to a USB 6210 in NIDAQmx. I am using the TwoEdgeSeparation task but I am having a problem finding an alternative tp the GPCTR_Watch which I originally used to display progress to the operator. So originally I could tell from the counter contents if the counter had started (start pulse has arrived) . Detecting the arrival of the stop&nbsp; or timeout seems easy enough by checking that the task has finished.It's detecting the start pulse ( which can be too short to detect by a simple digital read) which is giving me a problem. Any ideas?
&nbsp;
Regards
&nbsp;
Martyn EcclesMessage Edited by martyneccles on 07-26-2008 02:04 PM
BrowningG
2008-07-28 21:40:08 UTC
Permalink
This post might be inappropriate. Click to display it.
martyneccles
2008-07-30 19:40:13 UTC
Permalink
Dear BrowningG,
Thanks for your helpful advice but I'm still not out of the woods. Briefly, I am trying to do the following using a USB-6210 under mx using C++ Builder. Previously I have done exactly the same successfully using a pci 6601 under legacy Nidaq.
I have 4 TTL input lines called start1,stop1,start2,stop2. These are coming from sensors measuring the passage of a projectile launched at a test target (for the purposes of assessing the strenght of the target material). So, I want to measure the Time interval between start1, stop1&nbsp; and between Start2 and stop2. On the USB 6210 I planned to use PFI0,PFI1 on one counter and PFI2,PFI3 on the second counter and program them each to to perform TwoEdgeSepChan measurements. The way it needs to work is that the system is armed and then some unknown time later (mabe a few seconds but possibly up to half an hour) the projectile is fired, the times recorded and then the system automatically re arms. When things are working well I could just enter an indefinite Read and wait for things to happen but in real life there will be a missing signal sometimes. Normally it is easy to monitor the counter behaviour to see if it has started counting (a start must have occurred) and then if the count is in an expected range (stop was received) or has overflowed ( stop didnt happen). This is important information for the user who would probably ajdust the sensitivity of the detectors etc to correct the problem. Previously I used GPCTR_Watch to read the counter progress ( 0 = no start, etc etc) and
The pulses on the PFI lines are quite short so I cant rely on reading the Digital inputs directly. I could put latches on the inputs but this would&nbsp; negate most the benefits of using the USB6210 and it would be easier to put&nbsp; a pci6601 into an external PC card connected expansion box (for Laptop use).
I have looked at your suggestion of using events , the obvious one being a DAQmxCfgChangeDetectionTiming&nbsp; after creating a DIChan. I tried to use the MX example&nbsp; ReadDigChan-ChangeDetectionEvent.c but (after adjusting it for 4 input lines)&nbsp; an error is reported saying that DAQmx_Val_ChangeDetection is not a valid property status code -200077. I interpret this to mean that the change detection event is not available to the USB-6210&nbsp;. Is tha right? Incidentally, is there a definition somewhere of what facilities are available for particular hardware?
Can you see an alternative approach to this&nbsp; or is there another event that I could use?
&nbsp;
Best Regards
Martyn
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
BrowningG
2008-08-01 02:10:09 UTC
Permalink
Hello Martyn,

From your post I believe that I understand your application some.&nbsp; It looks like you would like to perform two two-edge separation tasks that could occur at any time and that you would like to know if the counter has received the first pulse, but not the second.&nbsp; Now it looks like you only need to know the edge separation times and not the time of the start1 or start2 event.&nbsp; Is this correct, I am assuming this is the case in my proposed solution.&nbsp; One idea would be to use a buffered counter task. &nbsp;

What you could do is create a buffered counter task (configure the task timing to be implicit timing with finite samples and the number of samples be greater than or equal to 2).&nbsp; This will allow for the task to be monitored without having to have a read timeout of -1.&nbsp; After you configure the timing, you can start the task.&nbsp;

Once the task is started, the counter will be armed and the device will start waiting for the start edge.&nbsp; In the DAQStreamClass (configured when you perform a buffered measurement) has a property AvailableSamplePerChannel.&nbsp; This property indicates the number of samples that are available to read.&nbsp; Once the task has received both edges, this property will return a 1 as the number of samples available.&nbsp; Until this occurs, the number of samples will remain at 0.&nbsp; Once at least one sample is available for that task, you can call the read method (specified to read 1 sample, or use the ReadSingleSample method) to get the single sample that is available.&nbsp; If a sample does not become available before a period of time that the user specifies (or if they get bored) then the user can stop the code execution.&nbsp; Let me know if this is enough detail.&nbsp;

You are correct; a change detection event is not supported by the USB-6210 because change detection is not supported on this particular device.&nbsp; A great resource for determining the functionality of your device is the <a href="http://digital.ni.com/manuals.nsf/websearch/937C8FEC72331772862574030069E2B6" target="_blank">user manual</a>&nbsp;and the <a href="http://digital.ni.com/manuals.nsf/websearch/0118224913E0FA8D86257403006975F3" target="_blank">specifications</a>. &nbsp; The manual provides great information on what types of tasks and timing for those tasks are supported and the specifications sheet gives great information on the accuracy of those measurements.&nbsp;
Loading...