Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2167

Configuring NI9401 Digital Output Channels

$
0
0

Hi All,

I'm programming in VB.NET 2010 with Measurement Studio. I've got a cDAQ9188 with a NI9401 digital I/O module. I want to be able to individually control 3 separate output lines to turn relays on and off. My form has 3 switches, each to control it's own relay.

 

My code looks like this:

 

Dim DORelays as Task

DORelays = New Task

DORelays.DOChannels.CreateChannel("/BDIO/Port0/Line0:2", "", ChannelLineGrouping.OneChannelForEachLine)

Dim DORelaysWriter as New DigitalSingleChannelWriter(DORelays.Stream)

If Switch.Value = True Then

   DORelaysWriter.WriteSingleSampleSingleLine(True, 1)

ElseIf Switch.Value = False Then

   DORelaysWriter.WriteSingleSampleSingleLine(True, 0)

EndIf

 

At this point it throws an error:

"Write cannot be performed, because the number of channels in the data does not match the number of channels in the task. When writing, supply data for all channels in the task. Alternatively, modify the task to contain the same number of channels as the data written.

Number of channels in Task: 3

Number of channels in Data:1

 

If I modify the line where I create the channels to have ""/BDIO/Port0/Line0" then my DIO line will toggle between 0 and 5 volts correctly.

 

How do I code so that my one task can individually control three separate relays each with it's own switch on the form? What am I doing wrong?

 

Much appreciation here,

 

Mike


Viewing all articles
Browse latest Browse all 2167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>