Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

asynchronous nidaqmx read

Hi all -  I'm using VB 2005, Measurement Studio 8.0.1, and NIDAQmx 8.6 (just downloaded the most recent version) and I'm trying to read and save multisample, multichannel data from a DAQ board (PCI 6224). I created the walkthrough for a NIDAQmx analog read and plot, selecting asynchronous read (needed for my project) and 16 channels. The demo works fine, using NationalInstruments.Analogwaveform class to acquire (via an e.GetData method) and plot the 16 channels, and the calibrate signals look fine, so all is functioning. But a couple of puzzles:
 
(1) I'd like to save the acquired data as long integer, rather than Double, but get an editor error message, indicating that the Waveform data type can't be converted to long (or single for that matter).  Any options here? (Our data processing software downstream is written for long integer.) Any online help or tutorial available on the AnalogWaveform class methods and resulting data? I saw a similar Q on another forum, but no answer had been posted yet (c. 8-18-07 I think)
 
(2) The asynchronous read provided by the demo wizard uses only the AnalogWaveform class; but the Measurement Studio documentation  is framed in terms of an AnalogSingleChannelReader class, and (for example) a BeginReadMultiSample() method. Are these obsolete? I've seen some Forum discussions about various versions of NIDAQ supporting or not supporting asynchronous reads, and I wonder if my MS documentation needs to be updated.
 
I'd be happy to use just the AnalogWaveform, as I'm suspicious that the SingleChannelReader has been integrated into it.
 
thanks!
0 Kudos
Message 1 of 6
(4,624 Views)
Hi ifisch -

An auto-reply to my first question, I think - I was trying to convert the whole (1D) array to long integer, rather than element-by-element. Dumb error. Still interested in comments, and thought on the second question about mismatches between what MS help tells me is available, and what appears as legit within VB code. (BTW, I have the Enterprise edition of MS 8.0.1, so that's not a limit).

- Ira F.

0 Kudos
Message 2 of 6
(4,621 Views)

Hello,

In response to your second question (it seems that you have already answered the first), I would recommend that you use the AnalogMultiChannelReader class in your application. I do not think that this class is obsolete; in fact, the NI-DAQmx shipping examples for VB .NET 2005 make use of the AnalogReader and AnalogWriter classes. By default, the AnalogMultiChannelReader class is geared towards performing asynchronous reads (using asynchronous callbacks).

The DAQ Assistant (wizard) makes use of another set of classes (ComponentModel) when it automatically scripts code. Off hand, I am not sure exactly how these classes compare with the AnalogReader and AnalogWriter classes used in the example programs, but I would definitely recommend using the AnalogReader and AnalogWriter classes if you are starting from scratch and not using the DAQ Assistant.

To get started, you may want to take a look at the examples located under "c:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\DotNET 2.0\Analog In\Measure Voltage\". I hope this helps!

Regards,

Casey Weltzin
Applications Engineer
National  Instruments

0 Kudos
Message 3 of 6
(4,594 Views)
Hi Casey -

Thanks for the advice. I'm making progress, but had a couple of additional questions:

(1) to access the functions and help of the DAQmx DotNet classes, MS asked for SDK 1.1 (it was looking for a config msi file that apparently got cleaned out of the Temp folder when SDK was installed from a download); we had installed 2.0, but that didn't seem to work. Would MS work with SDK 2.0? If so, how can we do that? If not, any losses or incompatabilities - I've read that Visual Studio 2005 is tailored for the 2.0 framework.

(2) Seems strange that the DAQ Assistant doesn't use the Analog reader/writer classes. On the one hand, I think the ComponentModel approach would have all I need - but I can't figure out how to capture the data for the callback after the asynchronous read (the event is called _onReadCompleted, I think), and can't find any Help on this. So I've tried implementing the AnalogMultiChannelReader by following the mini-example from within Help.  I'm able to enter the code without evoking any syntax errors, but the Sub New that instantiates the reader and connects it with a DAQ task stream (I think I'm phrasing that right) creates a problem with the main form recognizing a second form - not an error I thought likely. Without the Sub New construction, the form is recognized, and the program compiles and runs OK. I have a hunch I'm just too ignorant about the big picture here. Any ideas, or do I need to provide more information?

(3) the DAQ Assistant works by first creating a DAQ task (which I can do manually from within the program using the Add Component / DAQ Windows task), which puts DAQTask.mxb (I think that's the notation) among the project solution object files. At that point, the DaqComponent object can be used to place a component on the form (nonvisible area). Double-clicking that component produces the default _OnreadCompleted procudure frame. In contrast, when I wrote the AnalogMultiChannelreader code, I needed the DAQtask.mxb (type?) installed, but didn't need to place a DAQcomponent on the form. Is the reader / Sub New process doing the equivalent of what the Assistant is doing by putting an actual component in the project form?

Well, that's a lot for a Sunday morning, but thanks in advance to you (or others that want to help out). BTW, MS 8.0.1 seems to have put the VB examples in a folder under Programs Files, rather than under the Shared Documents.

- Ira / ifisch

0 Kudos
Message 4 of 6
(4,575 Views)

HI Ira / ifisch,

There are a few things I wanted to clarify after reading through both Casey's and your post.  First off, I notice that you and Casey are referring to different examples locations for Measurement Studio.  This is because in Measurement Studio 8.1.1, the example locations changed.  In previous versions of Measurement Studio, the examples were installed to
Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples. In Measurement Studio 8.1.1, the examples are installed to a subfolder of the My Documents folder on Windows XP and the All Users\Documents directory on Windows Vista. In the Measurement Studio help, we have a Where to Find Examples help topic which has been updated to show the different directories for Measurement Studio, DAQ, VISA, GPIB and SCOPE.  Now, if you look at your "Where to Find Examples" help topic and don't have this update, this just means that you don't have Measurement Studio 8.1.1 or some of our latest hardware drivers. In that case, check out the NI-DAQmx, NI-VISA and NI-488.2 .NET Example Locations KnowledgeBase that has 2 screenshots attached that show these updated locations.

Secondly, Visual Studio 2005 only targets the .NET Framework 2.0 and Visual Studio .NET 2003 targets the .NET Framework 1.1. Visual Studio 2008 (still in beta) is changing this restriction in that you can now target multiple .NET Frameworks within the same Visual Studio IDE. Measurement Studio provides support for both the .NET Framework 1.1 and .NET Framework 2.0. When you install Measurement Studio, you will notice two different setup.exe's named setupVS2003.exe and setupVS2005.exe. If you were using Visual Studio 2005, then always select the setupVS2005.exe installer.

Third, the DAQ Assistant does use the Reader/Writer classes. For example, if you chose to do some Analog Input, the DAQ Assistant generated code would be use the
AnalogMultiChannelReader class. See snapshot AnalogMultiChannelReader.jpg

Now I could go into detail about how the DAQ component works but our help does a great job of this so I am going to refer you to there. See the help topic Creating a Measurement Studio DAQ .NET Application under NI Measurement Studio Help >> Developing Measurement Studio >> Developing with Measurement Studio NI-DAQmx >> Creating a Measurement Studio DAQ Application. There are several topics under there that discuss the DAQ component. Also, check out the Walkthrough: Creating a Measurement Studio NI-DAQmx Application under the Getting Started with Measurement Studio Class Libraries >> Measurement Studio Walkthroughs section which actually uses the DAQ Assistant.

Also note that in the Configure DAQ Component UI dialog, you set up the callback functions as shown in the screenshot Generate DAQ UI.jpg.

If after reading through all that material, you are still having some difficult (again its great material and documentation), please let me know. Honestly I would run through the walkthrough first to get comfortable.

Hope this helps!!
Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 5 of 6
(4,558 Views)
Forgot to attach the imagesSmiley Very Happy

Best Regards,

Jonathan N.
National Instruments
Download All
0 Kudos
Message 6 of 6
(4,553 Views)