Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a generic digital reader/writer using DAQmx&VB.NET

I've been using Traditional DAQ and MS VS 6.0 (VB) for years. And now I try to more to DAQmx and MS VS.NET 2003. It seems that the DAQms is not convenient.

(1) To use digital I/O in traditional DAQ, just simply call DIG_In_Line/DIG_Out_Line. But using DAQmx, I have to do 1. task, 2. channel, 3. reader/writer, etc.

    Question: How to make a generic digital reader/writer using DAQmx&VB.NET. There 24 DI and DO lines, and I want to use them ramdomly in rondam. Do I have to declare 24 DI channels and readers (and same for the DO lines)?

(2) Same question for analog (I have PCI NI 6527 and 6024E).

 

Thanks

Thank you for your help
0 Kudos
Message 1 of 4
(4,009 Views)

Hello PIGM,

 

so you are correct in that in Traditional daq there were 'easy' I/O functions, but these comprised directly of the advanced functions which do exactly what DAQmx does.  We had to standardize with the 'advanced palette' when we moved to DAQmx because the main issue we were seeing is that you couldn't switch between using the easy and advanced functions easiy.  DAQmx no has one set of function calls and that includes creating a task/channel then configuring that task, read/write then close the task after completion.

 

If you are interested in seeing examples of how to do this please look on your machine:  ...\National Instruments\NI-DAQ\Text-Based Code Support.  Choose the proper coding environment and navigate to see which examples apply best to you!. 

Let us know if you have any other questions. 

Charley Dahan

Global Account Manager
0 Kudos
Message 2 of 4
(3,994 Views)

Hi,

Thanks for the response.

(1) (To confirm)So, I do have to create 24 DI Channels, readers in order to use individual DI line in PCI 6527 in random?

(2) When I tried the example code in: C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Digital\Read Values\ReadDigChan_ChangeDetection_DigFilter\vb

      I changed the task time out value to: myTask.Stream.Timeout = -1 (because the event that I want to measure is a ramdom event). The issue is, however, that the task will not be abort by using Task.Control(TaskAction.Abort), Task.Control(TaskAction.Stop) if the event does not come, and I have to use Device.Reset.   Did I use it right?

Thank you for your help
0 Kudos
Message 3 of 4
(3,988 Views)
Hey PIGM

So yes you do have to create 24 virtual channels if you are to use them as digital input.  What this does is configure them to be digital inputs.

Now you have two options.  If you are using Static Digitlal I/O (which I believe you are) you have the coice of either creating 24 separate tasks (1 for each channel) this allows you to read each channel independently.  Or create one task with 24 virtual channels, can use commas or a colon to select multiple channels. 

ch1:12 - selects all channels from 1--> 12
ch1,ch3, ch4 selects channels 1 , 3, 4.

The DAQmx read function is a blocking function and therefore if you specify a timeout value then nothing else can be called until this function fully executes.  The Task will continue to run even if you abort the program because you are not stopping/clearing the task.  Resetting the device will fix clear the tasks. 

I hope this helps let us know if you have anything else!

Charley Dahan

Global Account Manager
0 Kudos
Message 4 of 4
(3,971 Views)