Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI - DAQmx : How do I configure a channel as bidirectional?

I see the functions for configuring an IO group as Inputs or Outputs.  I have 2 port (16 bits) that are connected to a bidirectional Data bus.

   DAQmxCreateDOChan ( )

   DAQmxCreateDOChan ( )

 

How do I tell CVI that the Channel is an output when I DAQmxWriteDigitalLines ( ) and an Input when I "DAQmxReadDigitalLines ( )"  ?

 

Do I have to create 2 Tasks with the same ports and start the OutputTask when I write and then stop it.  And the same for the Input/read task?  That seems clunky.


Thanks - Phil

0 Kudos
Message 1 of 4
(4,620 Views)

Hello pmetty,

 

In order to do this with the DAQmx driver, you need to use the 'Tristate' propert.  Here is the definition of this property from the LabVIEW Help files:

 

Digital Output:Tristate Property var L_helpType = "STD_ENG";

"This property specifies whether to stop driving the channel and set it to a high-impedance state. You must commit the task for this setting to take effect.

Setting this property before you commit the task determines whether NI-DAQmx drives data on the channel or tristates the channel after the task transitions to the committed state.

Use this property when you want to read and write to channels in a task. Set this property to TRUE before you read from the channel and set this property to FALSE before you write to the channel.

When you read from an output channel that is not tristated, the value corresponds to the current value you are driving on the channel.

When you write to a channel that is tristated, no change occurs until you set this property to FALSE. After you set this property to FALSE, the value NI-DAQmx drives on the channel corresponds to the last value written to the channel.

Ensure the channel is tristated before any external devices that you connect to the channel drive data onto the channel. Failure to do so could result in double-driving the channel and damaging the device.

This property is supported only for line-configurable, bidirectional ports."

 

To implement this in CVI, you need to call the function "DAQmxSetDOTristate(TaskHandle taskHandle, const char channel[], bool32 data)".  It might depend on which device you have, so you might need to look in the NI-DAQmx C Reference Help (Start>>Programs>>National Instruments>>NI-DAQ) to see supported devices.  I hope this helps.

 

Regards,

 

Brian T

Applications Engineer
National Instruments

 

0 Kudos
Message 2 of 4
(4,598 Views)

Brian_T wrote:

Hello pmetty,

 

In order to do this with the DAQmx driver, you need to use the 'Tristate' propert.  Here is the definition of this property from the LabVIEW Help files:

 

Digital Output:Tristate Property var L_helpType = "STD_ENG";

"This property specifies whether to stop driving the channel and set it to a high-impedance state. You must commit the task for this setting to take effect.

Setting this property before you commit the task determines whether NI-DAQmx drives data on the channel or tristates the channel after the task transitions to the committed state.

Use this property when you want to read and write to channels in a task. Set this property to TRUE before you read from the channel and set this property to FALSE before you write to the channel.

When you read from an output channel that is not tristated, the value corresponds to the current value you are driving on the channel.

When you write to a channel that is tristated, no change occurs until you set this property to FALSE. After you set this property to FALSE, the value NI-DAQmx drives on the channel corresponds to the last value written to the channel.

Ensure the channel is tristated before any external devices that you connect to the channel drive data onto the channel. Failure to do so could result in double-driving the channel and damaging the device.

This property is supported only for line-configurable, bidirectional ports."

 

To implement this in CVI, you need to call the function "DAQmxSetDOTristate(TaskHandle taskHandle, const char channel[], bool32 data)".  It might depend on which device you have, so you might need to look in the NI-DAQmx C Reference Help (Start>>Programs>>National Instruments>>NI-DAQ) to see supported devices.  I hope this helps.

 

Regards,

 

Brian T

Applications Engineer
National Instruments

 


  Hi Brian,

 

I'm currently trying to do the same bidirectional IO with a PCI  6503 card (on its port A) in Labview with DAQMX. Can I 'translate' the above recipe directly into LV? I have not experience with DAQmx (nor NIDAQ) and would be grateful for any advice.

 

 

-Franz

0 Kudos
Message 3 of 4
(4,350 Views)

Hi, Brian

 

(I somehow can't edit  my previous reply, so I wrtie a new reply)

 

 

I  tried to follow the recipe given in this thread (message#3) using the following pieces of code:

snippet.png

 

It generates an error since the taskID is for an output task, but the DI.Tristate property is available for an input channel only.

 

What am I missing when I try to use the channel in bidirectional mode?

 

-Franz

0 Kudos
Message 4 of 4
(4,340 Views)