Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting started

I have been having an incredibly hard time getting started with Measurement Studio/NI-DAQ for Visual Basic. First I tried using VB 2005 .NET but this appears to be unsupported and does not seem to work. Then I switched to VB 6 and found that I cannot program for the cards we bought (PCI-6514, PCI-6221) because they are only supported by DAQmx. Documentation appears to be sparse and lacking detail. All I want to do is acquire analog waveforms, perform frequency, voltage, and duty cycle measurements on the acquired waveforms and acquire simple digital input. At this point I am completely frustrated, my project is dead in the water, and I wouldn't recommend NI products to anyone who values their sanity and wants to get some work done. I have wasted hours with no progress searching through the NI website and trying different examples and PDF files.

Why isn't NI starting to embrace VS 2005, even in beta stages? One would think it would benefit NI and it's customers to get a head start on developing for this new technology. Even in it's current beta state VB.net has proven to be extremely stable. My current applications on the beta platform are running fine, except for data acquisition! Can someone please point me in the direction of some USEFUL information and example code?

John Voltz
Hindley Electronics, Inc.
0 Kudos
Message 1 of 9
(8,579 Views)
The error I keep getting in VB 2005 is:

An unhandled exception of type 'System.TypeLoadException' occurred in NationalInstruments.DAQmx.dll

Additional information: Could not load type 'nNIMSAI100.tControlObjectQueryList' from assembly 'NationalInstruments.DAQmx, Version=7.1.0.273, Culture=neutral, PublicKeyToken=4544464cdeaab541'

I cannot even see how to use DAQmx with VB6, the ActiveX controls only seem (to me) to work with the Traditional NI-DAQ virtual channels. The boards we bought don't show up in the combo box for virtual channels.

Can anyone explain what I need to do to get these boards working?

Thanks,

John Voltz
0 Kudos
Message 2 of 9
(8,569 Views)
Hello John

The DAQmx .NET class library is fully supported with Visual Studio .NET 2003 (.NET 1.1).

We currently do not support using Visual Studio .NET 2005 Beta (really .NET Framework 2.0) with DAQmx because it is a beta and we will not provide release libraries against a beta version of their product. We work very hard to ensure that our release libraries are backward compatible between versions. If the framework we build our libraries on (.NET Framework 2.0 in this case) can change, we cannot ensure this backward compatibility. Additionally, when the framework we build our libraries on is in beta, we cannot ensure any minimal level of quality because the framework itself does not ensure a minimal level of quality.

We have fully embraced the new .NET technology and are actively developing libraries and environment integration features that will be compatible with the release version of .NET Framework 2.0 and Visual Studio .NET 2005. This effort takes time, but you can look forward to beta versions of these libraries from us in the first half of next year. The .NET Framework 2.0 is still many months from release and so is currently in a state of flux. We are working closely with Microsoft and supplying feedback to them. In fact, the problem that you reported in VS .NET 2005 is a bug that we have reported to Microsoft and they are looking to correct it for their official release.

Visual Studio .NET 2005 beta issues aside, there are a variety of options available to you with released Microsoft development environments. The best option would be to use Visual Basic .NET 2003 and the DAQmx .NET class library. This option includes MSDN integrated function reference, C# and VB.NET code snippets, C# and VB.NET example programs, and concept topics that are fully integrated with the Visual Studio system. We have fully tested this library with the .NET Framework 1.1.
If you don't want to use Visual Studio .NET 2003, you can use Visual Basic 6.0. As you noticed, the CWDAQ ActiveX controls provide an interface to the Traditional DAQ driver and so are not usable with DAQmx devices. Instead, you will need to do use the DAQmx C API from within Visual Basic 6.0.

Using the DAQmx C API with VB 6.0 is supported, but requires a bit of work. We are looking to provide better support for using VB 6.0 and DAQmx in the future. But for now, you can use the functions in VB 6.0 by making direct calls to the DAQmx dll, which is nicaiu.dll, found in the system32 folder. Here is an example of how to do simple DIO with DAQmx and VB 6.0. You can use the NIDAQmx header file (NIDAQmx.h found under C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev ) to map the functions to VB. C Examples can be found under C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.

For example, the CreateTask function would map over as the following

Public Declare Function DAQmxCreateTask Lib "nicaiu.dll" (ByVal taskName As String, ByRef taskHandle As Long) As Long

based on the C declaration, which is the following

int32 DAQmxCreateTask (const char taskName[], TaskHandle *taskHandle);

You can reference the C examples to see how to setup the function operations.


We are committed to making you successful with our hardware and Visual Basic. We just cannot commit to doing it for unreleased versions of Visual Basic. If you encounter issues working with either the DAQmx .NET library in Visual Studio 2003 or working with the DAQmx C library in Visual Basic 6.0, please post them here or contact customer support so that we may provide assistance.
Bilal Durrani
NI
0 Kudos
Message 3 of 9
(8,548 Views)
Hi Bilal,

Thank you very much for your response, I will try calling the DLL tomorrow and let you know how it works out for me, I spent the remainder of the day today generating the attached file from the DAQmx C header. If you don't mind, could you please take a quick look at it and see if it looks like I did the variable castings properly? If it looks good to you, I bet other users would be interested in this file being available from the NI website. The file is so big in it's entirety that VB 6 will possibly throw an error "Out of memory" but users can cut and paste the needed declarations. VB 2005 .NET will open it without a problem.

Thanks again,

John Voltz
0 Kudos
Message 4 of 9
(8,534 Views)
looks great. If you do run into any problems while using this, please let us know.

Quick question though, is there a reason why you are not developing your application using visual studio .net 2003?

Thanks for the vb file.
Bilal Durrani
NI
0 Kudos
Message 5 of 9
(8,512 Views)
> Quick question though, is there a reason why you are not developing your application using visual studio .net 2003?


Let me just say, it's a long story. I'll just leave it at "availability"

John Voltz
0 Kudos
Message 6 of 9
(8,504 Views)
I'm happy to announce that I now have waveforms on my screen using VB.NET 2005! Thanks Bilal for your assistance. I have one more question, is there a reference document for the DAQmx DLL functions? I cannot find any documentation that explains all of the DLL exports and the variable functions. I have managed to muck my way through so far, but a procedure reference would be very useful.

Thanks again,

John Voltz
0 Kudos
Message 7 of 9
(8,495 Views)
You can find the reference manual installed at- Start >> Programs >> National Instruments >> NI-DAQ >> NI-DAQ C Reference Help.

It will provide a list of all the functions and each prototype. Hope this helps!

Allen P.
NI
0 Kudos
Message 8 of 9
(8,484 Views)
Hi Allen,

That's exactly what I was looking for, thanks!

John Voltz
0 Kudos
Message 9 of 9
(8,470 Views)