01-11-2016 02:41 PM
I have been searching all morning for information on how I can programically tristate individual IO lines on a PXIe-6535, and my search has turned up empty.
How can I make a single line, for example, "PXI1Slot6/Port3/Line3" tristate?
01-12-2016 06:37 AM
using (NationalInstruments.DAQmx.Task task = new NationalInstruments.DAQmx.Task("tristate task")) { var channel = task.DOChannels.CreateChannel("PXI1Slot6/port3/line2, "", ChannelLineGrouping.OneChannelForEachLine); channel.LineStatesDoneState = DOLineStatesDoneState.Tristate; DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(task.Stream); writer.WriteSingleSampleSingleLine(true, true); }
I did a bit more digging through the API, and found the DOChannel.LineStatesDoneState, which looks excactly what I want to so. So I tried the above code, and now it's throwing a DaqException.
NationalInstruments.DAQmx.DaqException: NationalInstruments.DAQmx.DaqException: Property requested is incompatible with the given Timing Type. NI-DAQmx can automatically select a compatible property value for you. To use the requested Timing Type, do not set the specified property and allow NI-DAQmx to set it for you. To use the requested property value, chose a different value for the Timing Type. Property: NationalInstruments.DAQmx.Timing.SampleTimingType Requested Value: NationalInstruments.DAQmx.SampleTimingType.SampleClock Property: NationalInstruments.DAQmx.DOChannel.LineStatesDoneState Requested Value: NationalInstruments.DAQmx.DOLineStatesDoneState.Tristate Possible Values: NationalInstruments.DAQmx.DOLineStatesDoneState.NoChange Task Name: tristate task Status Code: -201122.
What does the done state have to do with the sample timing type?
01-12-2016 02:50 PM
Hi CurtisHx,
Have you come across this article yet? It gives an explanation for how to do it programmatically.
http://digital.ni.com/public.nsf/allkb/C57731813979131B86257ACD003FE9DE?OpenDocument
Also, this article gives mores specifics about tri-state capabilities with your hardware:
http://digital.ni.com/public.nsf/allkb/09B559BE292C75DB8625698500640E0A
Hope this helps!
Best,
Hannah
National Instruments
01-13-2016 05:46 AM
Hi Hannah,
The first article only explains how to tri-state in MatLab. I'm trying to tristate with the .NET DAQmx API. The second article states
The 653x devices support tri-state operation. See page 2-2 of the 653X User Manual (linked below) for details.
Which is exactly what I want to do, and am attemting to di in the code sample above. However, the code throws a DAQ exception. I'm trying to figure out why I can't tri-state on a device that supposedly supports tri-state.
01-13-2016 01:19 PM
Hi CurtisHX,
By going through the NI-HSDIO .NET Wrappers, I was able to find this section of code that may be helpful for you:
Public Function TristateChannels(ByVal Channel_List As String, ByVal Tristate As Boolean) As Integer
Dim pInvokeResult As Integer = PInvoke.TristateChannels(Me._handle, Channel_List, System.Convert.ToUInt16(Tristate))
PInvoke.TestForError(Me._handle, pInvokeResult)
Return pInvokeResult
End Function
I would recommend trying this, as it is the intended wrapper for tristating channels.
Best,
Hannah
01-13-2016 02:30 PM
I was not aware that HSDIO even existed. Downloading now.
I did a little playing around, and it looks like this code works:
using (NationalInstruments.DAQmx.Task task = new NationalInstruments.DAQmx.Task()) { var channel = task.DOChannels.CreateChannel(line, "", ChannelLineGrouping.OneChannelForEachLine); DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(task.Stream); writer.WriteSingleSampleSingleLine(true, true); channel.Tristate = true; }
Note the "channel.Tristate = true;" at the end. So the channel can be tri-stated manually (at least the code doesn't crash. I haven't verified it with the o-scope), but it can't be tristated by using the "LineStateDoneState" property?
This makes no sense at all...
01-14-2016 01:41 PM
Hi CurtisHx,
My mistake - I was looking at the PXIe 6535 module you are using and immediately was thinking in terms of HSDIO driver functions, not DAQmx. But I am glad that my confusion introduced you to another set of wrappers that may be helpful to you!
The reason the Tristate in the LineStateDoneState property does not work is because the PXIe 6535 is not a device that has bidirectional lines. Refer to the article at the link below:
http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/df59f9ed/
If the channel.Tristate = true is working well for you, I'd suggest using that for now.
Cheers,
Hannah
National Instruments
01-15-2016 01:23 PM
So then what's the difference between setting LineStatesDoneState to tristate, vs channel.Tristate = true? I know for a fact that the PCIe-6535 can be tristated, so why does setting
channel.LineStatesDoneState = DOLineStatesDoneState.Tristate;
throw an exception, but
channel.Tristate = true;
does not throw an exception?
01-19-2016 05:20 PM
Hi CurtisHx,
According to the .NET Help documents, DOLineStatesDoneState specifies the state of the lines in a digital output task when the task completes execution whereas setting the channel.Tristate to true specifies whether to tristate the lines in the channel. The core reason the DOLineStatesDoneState doesn't work for your setup is because your card does not support bidirectional lines, as referenced in the article I linked in my previous reply. The difference between the two commands seems to be that DOLineStatesDoneState resets the state of the line after a specific task completes whereas the channel.Tristate = true simply sets the channel to tristate, regardless of tasks being executed.
Best,
Hannah
02-09-2016 07:22 AM
What's the underlying reason behing needing bidirectional lines in order specify a desired "done" line state? It appears to be a fundamental operation that shouldn't rely on needing specialized hardware. Why can't a non-bidirectional IO module (that's a condatriction in terms...) set the line states to *insert state here* when a task is done?