Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

6503 How to Read/Set the Active High/Low state in .NET

Hi,

I know that the default for the NiDAQmx devices is "Active Low". Is there a function to read what the current setting is? I know physically on the 6503, there is a jumper on the board to changes this. Likewise, if the device can be changed via software, what's the command to switch it back and forth.

 

0 Kudos
Message 1 of 9
(4,411 Views)

I got it to set the state by doing the following on the DAQCard-DIO-24:

 

 Dim digitalWriteTask As New Task()

Dim OutputChannel As DOChannel

 

OutputChannel = digitalWriteTask.DOChannels.CreateChannel(cbPort.Text, sPortName, ChannelLineGrouping.OneChannelForAllLines)

OutputChannel.InvertLines = True

 

Dim writer As DigitalSingleChannelWriter = New DigitalSingleChannelWriter(digitalWriteTask.Stream)

writer.WriteSingleSamplePort(True, Decimal.ToUInt32(lblPortValue.Text))

digitalWriteTask.Dispose()

 

I still can't tell what the current state of InvertLines was prior to setting it. Also, will the codee above work for the 6503 which has a dipswitch for this setting?

0 Kudos
Message 2 of 9
(4,397 Views)

I ran the same code on the PCI-6503 and even though it has the Hardware jumper, the code works regardless of what the jumper is set to. Now all I need to know is how to read the current state of InvertLines...

 

0 Kudos
Message 3 of 9
(4,380 Views)

Hi Tim,

        I'm glad you've figured things out to this point. Have you tried reading the line immediately after you start the task? If that doesn't work, then you don't have too many options. 

 

The other thing you could try if that doesn't work would be to take what the default state is (either from the manual, or by looking at how the jumper is configured)- then, you could have a case structure that indicates whether the line is high or low based on what whether or not you have inverted the line.  This isn't really "reading the line" like you would like, but it may be better than nothing.

 

Let me know if neither of those work out, have a great weekend!

 

0 Kudos
Message 4 of 9
(4,377 Views)

I tried reading it as follows:

 

bInvertLines = OutputChannel.InvertLines

 

But that appears not to work. I get the following message from the debugger:

 

"Measurements: Value of this property cannot be determined until the containing task is verified."

 

Any ideas?

0 Kudos
Message 5 of 9
(4,373 Views)

Hi Tim,

       Sorry that didn't work out- not all of our cards allow you to read them before  you write to them/start the task.  Because of this, you're very limited in how you can get your program to tell you whether the line will start high or low.  Right now, your only option would be to do something like I had suggested in my last post.  You'll be limited to having a case structure where you have a true case (line is inverted) that indicates to you that the line is high (or low, depending on how you have your jumper configured, and a false case (line not inverted) that indicates to you that the line is low (or high).  

 

This means that you won't be reading whether or not your line is high or low from your card, but your program will display that information based on the case structure you've configured.   Sorry there's not a better way to do that.  Please let me know if I haven't explained any of this well.  Thanks!

 

0 Kudos
Message 6 of 9
(4,349 Views)

Anita,

Is there no one at NI that knows how to use your software with .NET. It obvious from messing around in the debugger, that there is a way to do what I'm requesting. I don't just want to try something and find out it's not the correct way of doing it and will get broken when the driver gets updated...

 

Someone must know how to use your software with .NET...

0 Kudos
Message 7 of 9
(4,326 Views)
Sorry to have disappointed you.  However, please note that this is not a .NET issue, but a limitation of the driver and hardware.  I will speak with R&D one more time to double check if there is a better way.
0 Kudos
Message 8 of 9
(4,308 Views)

No disrespect intended, but it absolutely is a .NET issue. Here is the full error message:

 

Measurements: Value of this property cannot be determined until the containing task is verified.

Before attempting to get the value of this property, you must make sure the task has been verified.  You can do this by starting the task, using the task control method to verify the task, reading from the task if the Read Auto Start property is true, or writing to the task and specifying true for the auto start parameter.

Task Name: _unnamedTask<0>

Status Code: -200593"}

 

If I start the Task, I do get access to the state of that variable. What I am asking is for someone that understands your Class Libraries, to explain what the recommended way to get access to that variable is. Do I have to do a Start() to gain access or is there some other recommended way to get access?

0 Kudos
Message 9 of 9
(4,303 Views)