Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI-6509 tristate and direction problem

Hi i have 2 problems with my PXI-6509. I need to control it over CVI DAQmx

 

1. I found lot of commands for setting port to high impedance (DAQmxTristateOutputTerm, DAQmxSetDITristate, DAQmxSetDOTristate, DAQmxSetDigitalPowerUpStates)

But none of them work. I also found a info, that 6509 does not support tristate, but datasheet says something else.

I need to set specific port or even better specific line to high impedance.

 

2. I also need to set/check port direction. I know that PXI-6509 has bidirectional ports, but sometimes i need to set a port just for sending data and sometimes just for receiving. But before sending data i need to check if port is set to output direction. How can i do it?

 

Any help?

Thanks Michal

0 Kudos
Message 1 of 15
(6,017 Views)

Hi Michal,

I think there may be some confusion here over the wording in the datasheet. The 6509 does NOT support Tristate outputs, it supports three states:-

1. High impedance input.

2. High output (i.e. logic 1).

3. Low output (i.e. logic 0).

If you need to use a tristate output you would need to use the 655x board, but this is much more expensive and much lower channel count.

To check if a port is set to be an output you could use the DAQmxGetDevDOPorts device property, this will return all ports currently configured as outputs then just check to see if the port you want to use is amongst them.

Hope this helps,

Nick

 

0 Kudos
Message 2 of 15
(6,013 Views)
Hi Nick, thanks for 50% help 🙂
 
1. Actually high impedance input is ok for me.
 
but
 
2. I think i have to do something wrong if i always get the list of output ports empty (see my code below)
    Just for sure i did not fing command DAQmxSetDevDOPorts for setting port direction so I hope it's ok I set it by commands DAQmxCreateDIChan or DAQmxCreateDOChan
 
  uInt8       data_in[100];
   int32    read,bytesPerSamp;
   int  taskHandleOut=0;
  
   char data[256]="";
   int bufferSize=0;
    
     
   memset(data_in,0,100);
  /*********************************************/
  // DAQmx Configure Code
  /*********************************************/
   DAQmxCreateTask("",&taskHandleOut);
   DAQmxErrChk (DAQmxCreateDIChan(taskHandleIn,"/Dev5/port9/line0","",DAQmx_Val_ChanForAllLines));
     
  /*********************************************/
  // DAQmx Start Code
  /*********************************************/
   DAQmxErrChk (DAQmxStartTask(taskHandleOut));
     
  /*********************************************/
  // DAQmx Read Code
  /*********************************************/
    DAQmxErrChk (DAQmxReadDigitalLines(taskHandleOut,1,1,DAQmx_Val_GroupByChannel,data_in,100,&read,&bytesPerSamp,NULL));   
    DAQmxGetDevDOPorts("Dev5", data, bufferSize);
0 Kudos
Message 3 of 15
(6,001 Views)

Hi Michal,

I may be missing something here but I cannot see where you are creating an output port in your code. I see an input port which would return empty. Am I missing something here?

Nick

0 Kudos
Message 4 of 15
(5,996 Views)

Sorry Nick,

my fault, here is the rest of code.

   uInt8     data_out[4]={0};
   char        errBuffOut[2048]={'\0'};
   int  taskHandleOut=0;
   char data[256]="";
   int bufferSize=0;
  

      /*********************************************/
      // DAQmx Configure Code
      /*********************************************/
      DAQmxCreateTask("",&taskHandleOut);
      DAQmxErrChk (DAQmxCreateDIChan(taskHandleOut,"/Dev5/port3/line0:3","",DAQmx_Val_ChanForAllLines));
          
      /*********************************************/
      // DAQmx Start Code
      /*********************************************/
      DAQmxErrChk (DAQmxStartTask(taskHandleOut));

      /*********************************************/
      // DAQmx Write Code
      /*********************************************/
      DAQmxErrChk (DAQmxWriteDigitalLines(taskHandleOut,1,1,10.0,DAQmx_Val_GroupByChannel,data_out,NULL,NULL));
     

      DAQmxGetDevDOPorts("Dev5", data, bufferSize);

      DAQmxStopTask(taskHandleOut);
      DAQmxClearTask(taskHandleOut);


 

0 Kudos
Message 5 of 15
(5,977 Views)
Hi Michal,
 
In your DAQmx Configure Code you still appear to be creating a digital input port not a digital output port. Try changing this line -
 
DAQmxErrChk (DAQmxCreateDIChan(taskHandleOut,"/Dev5/port3/line0:3","",DAQmx_Val_ChanForAllLines));
 
to this line -
 
DAQmxErrChk (DAQmxCreateDOChan(taskHandleOut,"/Dev5/port3/line0:3","",DAQmx_Val_ChanForAllLines));
 
Hope this helps,
 
Nick
0 Kudos
Message 6 of 15
(5,974 Views)

Hi Nick,

still nothing.

DAQmxGetDevDOPorts("Dev5", data, bufferSize);

returns me empty data, and bufferSize = 0

if i initialize bufferSize=256 before DAQmxGetDevDOPorts.

Then at the end is

data ="Dev5/port0, Dev5/port1, Dev5/port2, Dev5/port3, Dev5/port4, Dev5/port5, Dev5/port6, Dev5/port7, Dev5/port8, Dev5/port9, Dev5/port10, Dev5/port11, Dev5/port0_32, Dev5/port4_32, Dev5/port8_32"

0 Kudos
Message 7 of 15
(5,972 Views)
Hi Michal,
 
Humm this seems strange. Firstly I'm thinking that you may need to initialize the buffer size to be able to get the returned value. Second I'm now wondering if the ports are defined as outputs by default which would explain why the function returns all ports, could you try creating a second DAQmx task that is a digital input on another port and then see if that port disappears from the list of ports when you make the DAQmxGetDevDOPorts function call.
 
Hope this helps,
 
Nick
0 Kudos
Message 8 of 15
(5,968 Views)
Hi nick,
no success.
I created the program. In first part i set /dev5/port9/line0:3 to digital input  In seconf part i set /dev5/port3/line0:3 to digital output.
 
I interconnect port9/line/0 with port3/line0 and so on physically.
It seems to be working fine, but still when I initialize data with
 
data=malloc(256*sizeof(char));
bufferSize=256;
DAQmxGetDevDOPorts("Dev5", data, bufferSize);
 
I still get list of all ports.
 
or if bufferSize is initialized on 0, then no ports.
 
Are you sure I can use command DAQmxGetDevDOPorts with PXI-6509? I did not find it in help (NI-DAQmx C Reference Help)
 
Michal
 
0 Kudos
Message 9 of 15
(5,965 Views)
Hi Michal,
 
The DAQmxGetDevDOPorts property can be found in the NI-DAQmx C Reference Help under NI-DAQmx C Properties>>List of Device Properties>>Digital Output>>Ports. The inputs version can be found under >>Digital Input>>Ports. I must admit that the help text is not extensive but it appears that this propery should be exactly what you are looking for. I really don't understand why you are not getting the expected return property values, it is very strange.
 
Sorry I cannot be of more help,
 
Nick
0 Kudos
Message 10 of 15
(5,951 Views)