Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

USB6008 I want a single reading on DEV1/0:1.In vb6 i succesfully use DAQmxREADANALOGFF64.What is the procedure using .net2005?

Solved!
Go to solution

Hi Jeffrey,

 

There are multiple available examples that install with the NI-DAQ driver, but you have to make sure you specifically select support for VB.NET during the install. You can find these examples at the following path.

 

C:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\

 

Then select your .NET Framework Version and browse to the VB examples for Analog Measurements. There should be plenty of examples there that can guide you to reading a single sample with multiple channels.

 

Chris N White

High Speed Products Group 

0 Kudos
Message 2 of 7
(4,750 Views)

Hi Chris,

Thank you for reply.yes. Possibility is that i give you some valuable advice when i say that all the examples are for 1 single channel,not as i resolve the issue in my question.As an application engineer i am sure you can be more helpful!please

0 Kudos
Message 3 of 7
(4,736 Views)

Hi Jeffrey,

 

The examples I mentioned in my previous post are valuable guidelines. In fact there is an example called "AcqOneVoltageSample" in the vb examples for .NET 2005 that will do exactly what you want. In this sample code a new AnalogMultiChannelReader has been created in the following lines of code.

 

reader = New AnalogMultiChannelReader(myTask.Stream)

            

             Dim data() As Double = reader.ReadSingleSample()

 

These two lines of code mean that the "reader" that has been created has the functionality to read from multiple channels, you simply have to specify which channels those are. The reader is then set to read a single sample.

 

There are two ways to configure a read of 2 channels. The first is to simply use the syntax you have in the title of this thread "Dev1/ai0:1" in the Channel box of the form. When you run the code you can manually type this in to the Channel box. The other way to do it is to hard code those channels in. It would be put into the following section of the example code.

 

myTask.AIChannels.CreateVoltageChannel("Dev1/ai0:1","",_

             CType(-1, AITerminalConfiguration), Convert.ToDouble(minimumValueNumeric.Value),_

             Convert.ToDouble(maximumValueNumeric.Value), AIVoltageUnits.Volts)


Doing this will make your channels to read voltage from not selectable on your form when the code is running and the form will always read from Dev1/ai0:1. 

 

 

Chris N White

High Speed Products Group

0 Kudos
Message 4 of 7
(4,730 Views)

Thank you Chris.

lets discuss the statements

reader=NewAnalogMultiChannelReader(myTask.Stream)

Dim data() As Double=reader.ReadSingleStream()

 

data() doesn not need to be dimensioned?

data() needs to be stored in variables!How do I get my readings ch0 and ch1 apart and into variables.most important.

If I could achieve clarity on that it would be good!

I have built a vb6 controlled Voltammeter used in electrochemical analysis and R&D.vb.net2005 now the challege.

thank you very much for a good attitude

yours

jeff

0 Kudos
Message 5 of 7
(4,725 Views)

Hi Jeff

 

I'm not sure what you mean by "data() doesn not need to be dimensioned?" but basically, data() is an array of those two single voltage readings. It is comprised of the values from channel 0 and channel 1 on that single read. You simply have to index that array to get those two values and assign them to new variables that you create. Here's an example:

 

Dim chan0 As Double = data(0)

 

 

Chris N White

High Speed Products Group

0 Kudos
Message 6 of 7
(4,711 Views)
Solution
Accepted by topic author JEFFREY KAPLAN

Thank you Chris,

yes I got it right.In the case of Dev1/ai0:1,data() consists of data(0) and data(1) ,ch0 and ch1 respectively.

many thanks. 

0 Kudos
Message 7 of 7
(4,703 Views)