12-20-2006 09:26 AM
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!
12-20-2006 10:54 AM
12-20-2006 11:49 AM
– 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 dialogbox 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.
12-20-2006 03:36 PM - edited 12-20-2006 03:36 PM
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,
Message Edited by YuGen on 12-20-2006 03:38 PM
Message Edited by YuGen on 12-20-2006 03:39 PM
12-21-2006 06:19 AM
12-21-2006 08:00 AM
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.
12-21-2006 10:00 AM
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