Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

CWDIO1.Ports(0).Assignment = cwdioLineConfigured

'Configure port 0 as 'line configured'
'Configure the lower 4 bits of port 0 as output and the rest as input
CWDIO1.Ports(0).Assignment = cwdioLineConfigured
CWDIO1.Ports(0).LineDirection = 15 ' binary = 1111
My question: When setting the "Assignment" to  "cwdioLineConfigured" , do I need to specify the "Linedirection" for each port.line, or are they able to accept input and output. I have a selection window where users can select ports, lines, devices, etc. Based on what they're selecting, I need to have the selected DIO set specifically for Input or Output. The combinations are endless. Is there a way for me to create a string of zero's and one's (001101011), conver the string to Hex and then set the linedirection? Help at this stage would be eye opening,
Thanks in advance
0 Kudos
Message 1 of 2
Hello Tuch,

Writing to the CWDIOPort.Assignment property determines the direction (input or outpu) of the port you are configuring.  The property can take on four different values: 'cwdioInput' which sets the whole port for input, 'cwdioOutput' which sets the whole port for output, 'cwdioUnused' if the whole port is not used, and 'cwdioLineConfigured' which allows you to specify direction for a port on a line-by-line basis using the LineDirection property.  You can write to the LineDirection property with a decimal number.  The binary representation of that decimal number represents the input and output configuration of the port.  For example, with an 8 line port, writing a binary value of 00001111 will set the first four lines for input and the next four for output.  The decimal representation of the binary number 00001111 is 15, so you write a value of 15 to the LineDirection property to configure the port as such.  Here are the commands used to write to the Assignment and LineDirection properties.

CWDIO1.Ports.Item(0).Assignment = cwdioLineConfigured
CWDIO1.Ports.Item(0).LineDirection = 15 

So if you have the user making selections for the direction of the lines in the port, you can build these boolean values into an 8-bit binary integer, convert binary to decimal, and write that value to the LineDirection property.

For more information about the specifics of the CWDAQ ActiveX control, see the cwdaq.chm help file installed under C:\Program Files\National Instruments\MeasurementStudio\Help.

I hope this helps,
Travis G.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 2