Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI-6509 tristate and direction problem

Hi Michal,

I have investigated this a bit further and it appears that this property returns the names of all ports available to be configured as outputs not the names of the ports configured as outputs. I have looked around the help file and found this property: DAQmxGetChanType which returns the type of the virtual channel. Details of this property can be found in the NI-DAQmx C Reference Help under NI-DAQmx C Properties>>List of Channel Properties>>General Properties>>Channel Type. This property looks like it might be a solution.

Hope this helps,

Nick

 

Message 11 of 15
(1,613 Views)

Thanks Nick,

that's exactly what i wanted to do.

This works perfect

DAQmxCreateTask("",&taskHandleOut);
DAQmxCreateDOChan(taskHandleOut,chan_out,"",DAQmx_Val_ChanForAllLines);
DAQmxGetChanType(taskHandleOut, chan_out, &direction);

but (there is always some but)

can I call DAQmxGetChanType withou calling DAQmxCreateDOChan before? When i tried it returns me error, that channel is not defined.

And ofcourse ir returns me for "chan_out" Digital output channel value if i set it one line before.

What i need is to define channel without setting direction and value (like digital, analog...)

0 Kudos
Message 12 of 15
(1,609 Views)

Hi Michal,

Glad to hear this works. You are right there is always a but with these things. I think you do need to call the DAQmxCreateDOChan before you can use the DAQmxGetChanType property but don't forget you need to do this anyway as part of your DAQmx Configure Code section so as long as your taskHandle from the configure section is valid you should be able to use the property a many times as you like.

Nick

0 Kudos
Message 13 of 15
(1,598 Views)

Hi Nick

In 1 task i can initialize only 1 type of channel.

It means if i used DAQmxCreateDOChan i can not use DAQmxCreateDIChan in the same task.

And even i have valid taskHandler i get by

DAQmxGetChanType direction of those ports which i set in DAQmxCreateDOChan before.

Maybe example would be better.

1) This works fine

DAQmxCreateTask("",&taskHandleOut);
DAQmxCreateDOChan(taskHandleOut,"/Dev5/port3/line0","",DAQmx_Val_ChanForAllLines);
DAQmxGetChanType(taskHandleOut, ,"/Dev5/port3/line0", &direction);

2) This code gives me an error- but this is what i would like to do

DAQmxCreateTask("",&taskHandleOut);
DAQmxCreateDOChan(taskHandleOut,"/Dev5/port3/line0","",DAQmx_Val_ChanForAllLines);
DAQmxCreateDIChan(taskHandleOut,"/Dev5/port4/line0","",DAQmx_Val_ChanForAllLines); //here i get error
DAQmxGetChanType(taskHandleOut, ,"/Dev5/port3/line0", &direction);

Error message is: "Task can not contain a channel with the specified channel type, because the task already contains channel with a different channel type."

3) Of course this code does not work i mentioned it previous reply

DAQmxCreateTask("",&taskHandleOut);
DAQmxCreateDOChan(taskHandleOut,"/Dev5/port3/line0","",DAQmx_Val_ChanForAllLines);
DAQmxGetChanType(taskHandleOut, ,"/Dev5/port4/line0", &direction); //Error

Error message is: "Specified channel is not in the task"

So solution could be to finish task for DO channel and start new task for DI, but i need to get port direction at any time

Michal

P.S: Thanks for your patient with me 🙂

0 Kudos
Message 14 of 15
(1,590 Views)
Hi Michal,
 
Yes the error is correct as you need to create a separate task for each. Try the following:-
 
DAQmxCreateTask("DO",&taskHandleDO);
DAQmxCreateTask("DI",&taskHandleDI);
DAQmxCreateDOChan(taskHandleDO,"/Dev5/port3/line0","",DAQmx_Val_ChanForAllLines);
DAQmxCreateDIChan(taskHandleDI,"/Dev5/port4/line0","",DAQmx_Val_ChanForAllLines); //here you should not get error
DAQmxGetChanType(taskHandleDO, ,"/Dev5/port3/line0", &direction);
 
This should work,
 
Nick
0 Kudos
Message 15 of 15
(1,552 Views)