01-31-2020 04:53 PM
Hello,
I have searched throughout the forums and the examples that come with NI-Daqmx along with the Measurement Studio examples and I cannot find a solution to my problem.
I am converting an old VB6 program for one of our test stands into a vb.net program. I would like to group the Digital Output channels (one port per channel) into one Task. I can add channels to the task without problem, but I cannot find any examples on how to write an Int32 to only one of those channels, ie. to only one port.
My Task Creation:
DO0Task.DOChannels.CreateChannel("Dev2/port0", "DOPort0", ChannelLineGrouping.OneChannelForAllLines)
DO0Task.DOChannels.CreateChannel("Dev2/port1", "DOPort1", ChannelLineGrouping.OneChannelForAllLines)
DO0Task.DOChannels.CreateChannel("Dev2/port2", "DOPort2", ChannelLineGrouping.OneChannelForAllLines)
From that point, I do not know how to declare a writer or access those channels individually. In VB6, the ports(channels) could be indexed within CWDIO and the Int32 written to a specific port(channel).
Say for example all of the lines connected to DOPort1 control a set of valves, Valves 1. DOPort2 controls a different set of valves, Valves 2. Each set has a separate Int32 variable in the program that will be used to determine which individual valve is open or closed within those sets. I want to change one port(channel) with an Int32 without having to write to all of the ports(channels).
I set this up as a single Task because I thought there would be conflicts with NI-Daqmx if I had multiple Tasks calling for the same device. If I am wrong about this, then I could have a separate Task for each port(channel) and use a DigitalSingleChannelWriter per port(channel).
Again, I couldn't find any examples in the NI vb6 to vb.net migration files, the forums, Ni-Daqmx example folders, nor in the Measurement Studio example folders.
Thank you.
06-04-2020 05:56 AM
Hi all.
National Instruments provides a native .NET API for NI-DAQmx. This is available as a part of the NI-DAQmx driver and does not require Measurement Studio.
Examples are included with NI-DAQmx and can be found at:
C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET<.NET Framework Version>
or
C:\Users\<User Name>\Documents\National Instruments\NI-DAQ\Examples\DotNET<.NET Framework Version>
or
C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples
Note: If the paths above do not exist, be sure you have .NET support installed for NI-DAQmx.
Hope, this information will be helpful.
Regards,
Meri