Discussion:
How to distribute vb6 app without installing NIDAQmx
(too old to reply)
AndrewMc
2006-12-15 17:40:11 UTC
Permalink
Hey Matt,
 
Another thing that you could do in your application that might help is this:
 
If you are not needing DAQmx in every instance of the application, you could only load the DAQmx driver if the functionality is required.  To do this, you could isolate all DAQmx calls into a separate DLL.  Then you can load that DLL at runtime (via late-binding in VB) only if DAQmx is installed on the system (If it's not, you could install it at that point).  This way, you won't always need DAQmx to be installed on the computer, and you can load it only when the DAQ card is required.
 
By the way, in my previous post a referenced a method to check a file existence to see if DAQmx is installed.  A good file to reference is nicaiu.dll, which is always located in the system32 folder.  If that file is not present, DAQmx is not installed.
mateozzz
2006-12-15 22:40:12 UTC
Permalink
The suggestion for "late-binding" sounds like it may work, but I haven't used that before.  Is there example code I can copy  (I haven't googled it yet to check)?
The root cause though is the decision by NI to change the architecture.  I'm sure there are 100 reasons why it was done, but the end result is an inconvience to the the end (paying) customer.  If you have a means to bring it to the attention of the right people, maybe someone will put it back the way it was....1 install and done.  Isn't that kind of the point of Visual Basic and ocx controls?  The only reason to install the whole thing should be if I need to use some of the other tools or interfaces. 
Thanks for your suggestions!
Matt
mateozzz
2006-12-18 15:40:12 UTC
Permalink
Sorry, I wasn't aware of the term.  Sure, I can do a CreateObject() to get a nidaq object.  I'm still trying to find the correct object to create, something like CreateObject("NiDAQmxCAPI.DAQmx").  Any hints would be appreciated.
Matt
Jonathan N
2006-12-18 19:10:10 UTC
Permalink
Hi Matt,
 
I understand your frustration of finding an appropriate and
simple method of distribution when deploying your VB applications that
incorprate NI-DAQmx.  We evolved going from Traditional DAQ to NI-DAQmx for
multiple reasons that all benefit you.&nbsp; I would check out the <a href="http://zone.ni.com/devzone/cda/tut/p/id/2998" target="_blank">Advantages of
NI-DAQmx</a> and <a href="http://zone.ni.com/devzone/cda/tut/p/id/3021" target="_blank">Answers to Frequently Asked Questions about NI-DAQmx and
Traditional NI-DAQ (Legacy)</a> tutorials. These documents provide some great
insights into our choices of heading down the DAQmx path.&nbsp;
&nbsp;
Since you are distributing your applications that need the
DAQmx driver, I would suggest checking out the <a href="http://digital.ni.com/softlib.nsf/websearch/1cafec237c5d5d488625722000531213" target="_blank">NI-DAQmx
Run-time Engine Version 8.3 for Windows 2000/XP</a> download page that gives you
options of downloading reduced versions of the driver. On that website, you will
notice 4 different versions of the run-time engine you can choose from.&nbsp;

&nbsp;
As far as examples and information about using NI-DAQmx in
Visual Basic 6, I would check out the <a href="http://digital.ni.com/public.nsf/websearch/B22FE2B0F9C8935286256E920073DA07?OpenDocument" target="_blank">NI-DAQmx Support in Visual Basic 6.0</a> and
<a href="http://digital.ni.com/public.nsf/websearch/735848148B5B4964862571F5004692C7?OpenDocument" target="_blank">NI-DAQmx Examples for Visual Basic 6.0</a> KnowledgeBases.&nbsp;
&nbsp;
If you are interested in the late binding concepts Andy
mentioned, check out the MSDN article <a href="http://support.microsoft.com/kb/245115" target="_blank">Using Early Binding and Late Binding in
Automation</a>.&nbsp;
&nbsp;
I know you are using Visual Basic 6, but there is an awesome
tutorial out there entitled <a href="http://zone.ni.com/devzone/cda/tut/p/id/4344" target="_blank">Transition from Traditional NI-DAQ (Legacy) to
NI-DAQmx using Microsoft Visual Basic .NET</a>.
&nbsp;
Hope this helps!
&nbsp;
Best Regards,
mateozzz
2006-12-18 19:40:12 UTC
Permalink
Probaly I should be more clear.&nbsp; I am only interested in Digital IO, I don't use any other functions.&nbsp; I have a very simple app that just sets and reads IO.&nbsp; This is a pseudo-excerpt of my code...
&nbsp;&nbsp;&nbsp; ' Create the DAQmx task.&nbsp;&nbsp;&nbsp; DAQmxErrChk DAQmxCreateTask("INPUT", taskHandle)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DAQmxErrChk DAQmxCreateDOChan(taskHandle, daq_str, "INPUT", DAQmx_Val_ChanForAllLines)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Start the task running, and read from the digital lines.&nbsp;&nbsp;&nbsp; DAQmxErrChk DAQmxStartTask(taskHandle)&nbsp;&nbsp;&nbsp; DAQmxErrChk DAQmxReadDigitalLines(taskHandle, 1, 10#, _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DAQmx_Val_GroupByChannel, readArray(0), arraySizeInBytes, _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sampsPerChanRead, numBytesPerSamp, ByVal 0&amp;)
Currently I include the reference "NiDAQmxCAPI" into the project to allow this to execute.&nbsp; This does not work for me because then I have to install another app (either the big NiDAQ or the runtime) before my program will even run, whether or not it needs to use the NiDAQ card.&nbsp; What I need is help to do the above without the reference included in my project, which means it should run fine as long as it does not&nbsp;call a NiDAQ function.&nbsp; On the small number of computers that need NiDAQ, I will install the NiDAQ software.&nbsp; Does anyone have that solution?&nbsp; I think it should be simple, but all the URLs etc... just dance around the concept, no concrete examples.&nbsp; I'm thinking it would be something like...
&nbsp;&nbsp; set my_daq = CreateObject( "nidaqmxcapi.daqmx" ) &lt;==this doesn't work in reality
&nbsp;&nbsp;&nbsp; ' Create the DAQmx task.&nbsp;&nbsp;&nbsp; DAQmxErrChk my_daq.DAQmxCreateTask("INPUT", taskHandle)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DAQmxErrChk my_daq.DAQmxCreateDOChan(taskHandle, daq_str, "INPUT", DAQmx_Val_ChanForAllLines)&nbsp;&nbsp;&nbsp;&nbsp;My code is mostly just cut-and-paste from the DIO example code (suggestion:&nbsp; update the examples to show whatever solution we come up with here).&nbsp; I'm not a pro developer so&nbsp;I'm not&nbsp;doing rocket science...
&nbsp;
Matt
&nbsp;
&nbsp;
Jonathan N
2006-12-19 21:40:09 UTC
Permalink
Hi Matt,
&nbsp;
The DAQmx C API is not object oriented and thus you cannot instantiate objects. Its C based and therefore&nbsp;the CreateObject method will not work. When we mentioned late-binding, we should have been a litte more clear on what we meant. Basically, you are going to have to abstract out your DAQmx calls and put those in a DLL that you create.&nbsp;&nbsp;This DLL will be statically linked to the DAQmx type library via adding the type library as a reference to the project.&nbsp; Then your main project will dynamically load that DLL when needed. When you load that DLL is up to you which would be based off your conditions of determining if DAQmx is going to be used.
&nbsp;
Anyway, hope this clears things up. Sorry for the misconfusion.
&nbsp;
Best Regards,
mateozzz
2007-01-10 15:40:12 UTC
Permalink
OK, I've spent some time updating my software.&nbsp; Basically my original project continues with the CWDAQ ActiveX object but has an option to use the DAQmx.&nbsp; When that option it chosen it calls a routine like that shown below which creates an ActiveX object from a dll.&nbsp; The dll is one that I wrote that makes the actual calls and has the reference to the NiDAQ C API.&nbsp; Therefore my application can install and run without any NI software installed, only stations using an NI device need the software.
&nbsp;
I have found one problem, though.&nbsp; Once NiDAQmx 8.x is installed the CWDAQ 6&nbsp;ActiveX object can no longer access any ports on the device.&nbsp; It shows up in the list of "Legacy" devices, but the number of ports is 0.&nbsp; The test panels work, but neither my app or the example software works. When my app is running that's OK because the correct version of NiDAQ would be installed, but for development it's a pain because I can't validate both the CWDAQ and the NiDAQmx with the same configuration of my workstation.&nbsp; I would have to reinstall 7.4, test CWDAQ, reinstall 8.3, test NiDAQmx.&nbsp;&nbsp; Am I missing some sort of configuration secret to get both to work at the same time (or at least with just a config change to swap back and forth)?
&nbsp;
Thanks for your help (although I'm still irritated at NI for making this so difficult!)
&nbsp;
Happy New Year
&nbsp;
Matt
&nbsp;
&nbsp;
====================
&nbsp;
Public Function nidaq_write(dev_name As String, port_num As Integer, io_val As Long)&nbsp;&nbsp;&nbsp; Dim my_daq As Object&nbsp;&nbsp;&nbsp; Dim status As String&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; On Error Resume Next&nbsp;&nbsp;&nbsp; Set my_daq = CreateObject("GumpDAQmx.NiDAQ")&nbsp;&nbsp;&nbsp; If err.Number = 0 Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = my_daq.nidaq_write(dev_name, port_num, io_val)&nbsp;&nbsp;&nbsp; Else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = err.Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; err.Clear&nbsp;&nbsp;&nbsp; End If&nbsp;&nbsp;&nbsp; If status &lt;&gt; "OK" Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = "NiDAQmx or the nidaqmx.dll is not installed"&nbsp;&nbsp;&nbsp; End If&nbsp;&nbsp;&nbsp; nidaq_write = statusEnd Function
&nbsp;
The function in my dll
&nbsp;
Public Function nidaq_write(dev_name As String, port_num As Integer, io_val As Long)&nbsp;&nbsp;&nbsp; Dim i As Integer&nbsp;&nbsp;&nbsp; Dim sampsPerChanWritten As Long&nbsp;&nbsp;&nbsp; Dim arraySizeInBytes As Long&nbsp;&nbsp;&nbsp; Dim writeArray() As Byte&nbsp;&nbsp;&nbsp; Dim daq_str As String&nbsp;&nbsp;&nbsp; Dim mask As Long&nbsp;&nbsp;&nbsp; Dim status As String&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; On Error GoTo ErrorHandler&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If taskHandle &lt;&gt; 0 Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StopTask&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; taskHandle = 0&nbsp;&nbsp;&nbsp; End If&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; arraySizeInBytes = 8&nbsp;&nbsp;&nbsp; '&nbsp; Re-initialize an array that holds the digital values to be written&nbsp;&nbsp;&nbsp; ReDim writeArray(arraySizeInBytes)&nbsp;&nbsp;&nbsp; mask = 1&nbsp;&nbsp;&nbsp; status = ""&nbsp;&nbsp;&nbsp; For i = 0 To arraySizeInBytes - 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If io_val And mask Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeArray(i) = 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = status &amp; "1"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeArray(i) = 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = status &amp; "0"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mask = mask * 2&nbsp;&n
Jonathan N
2007-01-10 19:40:11 UTC
Permalink
Hi Matt,

The CWDAQ ActiveX controls are purely for Traditional NI-DAQ and do not work
with NI-DAQmx.&nbsp; You can have both drivers installed on the same
system.&nbsp; You can use Traditional NI-DAQ and NI-DAQmx at the same time if
you have two DAQ devices and one of them is using Traditional NI-DAQ and the
other NI-DAQmx.&nbsp;&nbsp; If you only have one DAQ device, you can still use
both Traditional NI-DAQ and NI-DAQmx but only in sequence ? not at the same
time. You need to reset your device to switch between Traditional NI-DAQ and
the NI-DAQmx driver as part of the sequence.&nbsp; Refer to the <a href="http://digital.ni.com/public.nsf/websearch/0D00C4218DA9A21886256D2C0076FD6F?OpenDocument" target="_blank">How
Do I Convert My Configuration from Traditional NI-DAQ to NI-DAQmx?</a> KnowledgeBase
for information.&nbsp;&nbsp; Hope this helps!Best Regards,Message Edited by Jonathan N on 01-10-2007 01:25 PM
mateozzz
2007-01-12 15:10:11 UTC
Permalink
This post might be inappropriate. Click to display it.
Jonathan N
2007-01-12 16:10:11 UTC
Permalink
Hi Matt,You can have one program use both drivers but not at the same time (since your are using the same card). If you run your application first and it uses the DAQmx driver, and you now want to use the Traditional DAQ driver, you need to reset the Traditional DAQ driver. To do this, open up Measurement and Automation Explorer, navigate to your Traditional DAQ device (My System &gt;&gt; Devices and Interfaces &gt;&gt; Traditional DAQ Devices), and then right-click the device and select Reset Driver.&nbsp;&nbsp; After doing this, you can use your Traditional program and see your device.&nbsp; If you want to do this programmatically, see the KnowledgeBase <a href="http://digital.ni.com/public.nsf/websearch/13734D71A825355A86256F8E0070CDE8?OpenDocument" target="_blank">How Do I Reset My DAQ Device From A Text Based
Language?</a> Best Regards,
mateozzz
2007-01-12 16:10:11 UTC
Permalink
There is no option to reset the device in the Traditional devices, only in the NiDAQmx devices.&nbsp; Is there anything special about the PC-DIO-96?
&nbsp;
Matt
&nbsp;
Jonathan N
2007-01-12 17:10:12 UTC
Permalink
Hi Matt,The Reset Driver for Traditional NI-DAQ option is located under Devices
and Interfaces ยป Traditional NI-DAQ Devices in the right-click menu.&nbsp; So, you don't right-click on the device but rather you right-click on the category Traditional NI-DAQ Devices.&nbsp; Remember that after using a device in Traditional NI-DAQ, you must reset the device before you
can use that device in NI-DAQmx.&nbsp; Best Regards,
mateozzz
2007-01-15 15:10:11 UTC
Permalink
This post might be inappropriate. Click to display it.
mateozzz
2007-01-19 15:10:09 UTC
Permalink
Ding, ding ding!&nbsp; We have a winner!&nbsp;&nbsp; The first command in that kb article solved the problem.&nbsp; Now all 12 ports show up in the CWDAQ object.&nbsp; Just for posterity:&nbsp; it was a clean install of W2K with all current patches, VB6 sp 6a, nidaq mx 8.3, nidaq traditional 7.4.&nbsp;
Thanks to everyone for helping to solve the problem!
Matt

Loading...