08-06-2009 01:36 AM
I started trying to write a way to control hardware that allows a user to organise hardware based on what they have, and using a configuration file to define what signals (channels) are connected to what line on hardware.
I found
http://forums.ni.com/ni/board/message?board.id=180&message.id=38304&query.id=363765#M38304
I have defined an unnamed task, with a single channel "Ignition" as "Dev0/port0/line4" in a config file. My software loads this config and calls DAQmxCreateTask() and DAQmxCreateDOChan(task, "Dev0/port0/line4", "Ignition", DAQmx_Val_ChanForAllLines). On another computer with the same software, but different configuration file, this might be "Dev1/port1/line2".
I'm using the function DAQmxWriteDigitalScalarU32 to set this port and clear it. How can I determine the correct value when using DAQmxWriteDigitalScalarU32()? A value of 1 generally won't work (unless it's portX/line0)
One
solution I have is to write -1 (0xFFFFFFFF), but then if I define
multiple lines separated by commas, both lines will be set and I still
have the problem if I want to separate them.
Like in the forum highlighted, the original user had initially expected that the DAQmx drivers would do the automatic bitshifting. Since it doesn't, I'm wanting to do that myself (for both reads and writes). So I need to understand how DAQmx internally takes the U32 and maps that to physical hardware. This will then become a DLL internally in our company for multiple programs and configurations.
Some notes:
I found that "Dev0/port2, Dev0/port1" means the lower 8 bits writes to port 2 and upper 8 bits writes to port 1. Is this only for 8-bit hardware (I've tested on a USB 6501, but I also have downstairs in my lab a PCI-DIO-96 card).
If I have 5 lines, over 5 ports, does this imply I can't use DAQmxWriteDigitalScalarU32()?
Thanks in advance,
Jason.
08-07-2009 10:58 AM
Hi Jason,
if you use DAQmxWriteDigitalScalarU32 the bit-channel order is as described in http://forums.ni.com/ni/board/message?board.id=180&message.id=38304&query.id=363765#M38304.
This means 8 bits per port no matter if 1 or 8 lines are used. So 5 lines from 5 ports won't work. A more flexible and readable solution is using DAQmx write 1D bool 1 chan 1 samp where each element 1 your bool array corresponds to a line maintining right order. See the to VI Snippets:
Regards,