Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB-6009 DAQ & Measurement Studio

Hi,

 

I’ve been developing Windows applications using VS 2005 (vb.net) and Measurement Studio 8.01.  Actually, when I look at the “About” under Visual Studio, I see…

 

Microsoft Visual Studio 2005

Version 8.0.50727.42

Microsoft .NET Framework

Version 2.0.50727

NI Measurement Studio   8.0.20.334

Measurement Studio for Visual Studio 2005

 

I recently purchased an NI USB-6009 DAQ for an application I’m creating.  I created a new windows project and when the DAQ Assistant came up, I configured a single Analog input as voltage, ai0, terminal configuration = RSE (single-ended input).  After clicking finish, the assistant created a small form with a WaveformGraph and a read button.  I connected a DC voltage up to the input terminals of the DAQ for ai0 and when I click the Read button, the WaveformGraph control displays the correct value of the voltage.  The code generated for this is:

 

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim acquiredData() As NationalInstruments.AnalogWaveform(Of Double) = DaqTaskComponent1.Read

    WaveformGraph1.PlotWaveforms(acquiredData)

  End Sub

 

I haven’t been able to find any documentation on how to access (i.e. program) the DAQ.  I have two simple questions (for now).

 

1)       What code would I add to the button_click procedure to display the measured value in a textbox?  I obviously can’t use…

Textbox1.text=DaqTaskComponent1.Read

… as the .Read returns an array of Double for the waveform.  I just want a single value.

 

2)       How (and this is dumb) do I re-invoke the DAQ Assistant at a later point in the project to add/modify/delete i/o?

 

Thanks in advance for any help!

0 Kudos
Message 1 of 7
(4,032 Views)
Hi,

You can find here manuals and examples:
C:\Program Files\National Instruments\NI-DAQ\
0 Kudos
Message 2 of 7
(4,028 Views)
Yes, I have found the manuals.  Trying to re-invoke the DAQ Assistant after the initial contguration is my problem.  The manual says...
 

– In Measurement Studio:

1. Open Visual Studio .NET and the project in which you want

to create a DAQmx task class.

2. Select

Project»Add New Item. The Add New Item dialog

box opens.

3. In the Categories pane, select

Measurement Studio»

Assistants

.

4. In the Templates pane, select

DAQmx Task Class.

5. Specify a name for the DAQmx task file and click

Open.

6. Specify whether to create a new task or a project copy of a

global task you create in MAX and click

Finish.

 

My problem is that if I follow steps 1 - 3, I should see Measurement Studio >> Assistants in the Categories pane (according to the manual).  My problem is that I do not see this.  All I have in the categories pane is "Visual Basic Items" with "Measurement Studio" under it in the tree.  In the right pane (Templates), I do have "DAQ Component" which has a description of "A custom component for a DAQmx task."

Now this is what I am getting for the "AcqOneVoltageSample.2005.sln" example in the C:\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples\DAQmx\Analog In\Measure Voltage\AcqOneVoltageSample\Vb folder.

 

Is it possible that I do not have something loaded?  Everything seems to work for the DAQ.

0 Kudos
Message 3 of 7
(4,020 Views)
My problem is that if I follow steps 1 - 3, I should see Measurement Studio >> Assistants in the Categories pane (according to the manual).  My problem is that I do not see this.

In my case:  VB .NET  2003 +  Measurement Studio 8.0 for VS2003 + NIDAQmx  8.0,
I can see
in the categories pane:
- "Local Project Items"
- "Measurement Studio"
    - "Assistants"
The Assistants subitem includes 2 templates: "DAQmx Task" and "DAQmx User Control".
I am sorry but I can't help with VS 2005.
It can even be the compatibility issue, but I cannot claim it for sure.

In my projects I did not use NI Assistants, but studied examples and coded everything directly.
Maybe you can do the same.

P.S. Noted just now: you did not mention your NiDAQmx version. Do you have it installed?

Message Edited by YuGen on 12-20-2006 03:38 PM

Message Edited by YuGen on 12-20-2006 03:39 PM

0 Kudos
Message 4 of 7
(4,014 Views)
I have it working now.  I was able to sucessfully create a DAQ task in my project and am now able to read voltage values from voltage sources connected to the DAQ.  The biggest problem I seem to have had is that the documentation  doesn't match the actual tool useage layout very well... maybe it's related to using VS2005.  Anyway, I am now forging ahead.  Thanks for your help!
0 Kudos
Message 5 of 7
(4,006 Views)
psgeorge -
 
I assume that you figured out the answer to your question (1) from your original post. You need to index into the acquiredData array to pull out the single Double value that you want to display.
 
For question (2), you right-click on your DAQ Task .mxb file in Solution Explorer inside Visual Studio 2005 and choose View Assistant to launch the Assistant to re-edit the task.
 
Lastly, it seems that you are having trouble finding the correct documentation. Please note that there is completely different MSDN and Measurement Studio documentation for VS2003 and VS2005. This is necessary, because as you have noticed, there are differences in functionality. In the case of class libraries, the VS2005 support is always compatible (or as compatible as possible) with the VS2003 support; any differences are just enhancements. However, with the integration support, such as the DAQ Assistant, backward compatibility is not an issue. In the case of the DAQ Assistant, we changed it a great deal in VS2005 to make the classes and user interfaces it generates more feature-rich and much more usable in large-scale applications.
 
Theory aside, you should be able to find the Measurement Studio Visual Studio 2005 support documentation in a variety of ways. One way is: inside Visual Studio 2005, choose Help>>Contents. In the Help Table of Contents, expand NI Measurement Studio Help. Inside this section, there are a variety of topics that I recommend you read:
  1. Developing with Measurement Studio>>Developing with Measurement Studio NI-DAQmx>>Creating a Measurem... (and all its sub-topics)
  2. Developing with Measurement Studio>>Developing with Measurement Studio NI-DAQmx>>Selecting a DAQ Par...
  3. NI Measurement Studio .NET Class Library>>Using the Measurement Studio .NET Class Libraries>>Using t... (and all its sub-topics)

In order for the links above to work (and for you to have this help), you must have installed the MSDN help that comes with Visual Studio 2005 prior to installing Measurement Studio. Please let us know if you are able to find the correct help.

 
0 Kudos
Message 6 of 7
(3,998 Views)

Thanks for your reply.  I found everything I needed.  My code as I implemented it is below and it works great.  My documentation is good… I just need to look at the right documents when going in through Windows Explorer.  Thanks again to everyone!

 

 

  Private myTask As Task  ' Main task which is assigned when the btnXDFFT05Measure button is clicked

  Private reader As AnalogMultiChannelReader

 

      ' Create a new task

      myTask = New Task

      ' Create a virtual channel

      myTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "", AITerminalConfiguration.Rse, 0.0, 1.0, AIVoltageUnits.Volts)

      ' Verify the task

      myTask.Control(TaskAction.Verify)

      reader = New AnalogMultiChannelReader(myTask.Stream)

      Dim data() As Double = reader.ReadSingleSample

      ' Apply slope/offset to raw measurement and update textbox

      txtXDFFT05Measure.Text = Format(CDbl((data.GetValue(0) / ai0Vr) * ai0Cr), "0.00") & " A"

    Catch ex As Exception

      MessageBox.Show(ex.Message)

    Finally

      myTask.Dispose()

    End Try

 

0 Kudos
Message 7 of 7
(3,987 Views)