LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxWriteDigitalScalarU32 port mappings

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.

 

0 Kudos
Message 1 of 3
(3,156 Views)

Hello Jason,

 

I would recommend to post this question in the Multifunction DAQ section where you sure would receive a good answer.

 

Regards

LDP 

0 Kudos
Message 2 of 3
(3,118 Views)
Hi,

According to the documentation, The least significant byte maps to the first port added to the channel list.  So, if you add port 1 before port 0 in your channel list, port 1 will contain the lowest significant byte.  The lowest line in the port will contain the least sigificant bit (In my example port1/line0 will be the least significant bit).  If you do not specify enough lines to satisfy the U32 than the unused bits are zeroed out on the device (you wont receive any output).  This information is included in the NI-DAQmx Help manual (search "Digital Data (Integer Format)"

I have not done specific testing on this but this is something that you could try out with any DAQ device.  What you can do is reference one of the digital output examples and try outputting a single integers with varying channel lists to see the result

This problem may be easily solved by using the function DAQmxWriteDigitalLines instead of writing U32 to the digital lines.  That way he could specify his line state individually and configure his channel list.  With this function the amount of channels in the task has to match the input array of data.

Regards,
Ulrich
AE NICER
0 Kudos
Message 3 of 3
(3,107 Views)