Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Using DAQmxWriteDigitalScalarU32 to write channels sharing same port(s)?

Solved!
Go to solution

Hello,

I have a USB-6509 and NI-DAQmx 15.5.1 installed. Using the ansi c api.

 

Is it possible to create several independent channels that use different lines from the same port?

 

DAQmxCreateTask("",&th1)

DAQmxCreateDOChan(th1,"Dev1/line0:4","",DAQmx_Val_ChanForAllLines)

DAQmxStartTask(th1)

DAQmxCreateTask("",&th2)

DAQmxCreateDOChan(th2,"Dev1/line5:9","",DAQmx_Val_ChanForAllLines)

DAQmxStartTask(th2)

....

and repeat for the following channels:

Dev1/line0:4
Dev1/line5:9
Dev1/line10:14
Dev1/line15:19
Dev1/line24:28
Dev1/line29:33

 

So I can use DAQmxWriteDigitalScalarU32 to write to each task independently?

 

for example:

DAQmxWriteDigitalScalarU32(th1,1,10,0x1,NULL)

DAQmxWriteDigitalScalarU32(th2,1,10,0x2,NULL)

DAQmxWriteDigitalScalarU32(th3,1,10,0x3,NULL)

...

DAQmxWriteDigitalScalarU32(th6,1,10,0x6,NULL)

 

Will these tasks interfere with each other since they use the same port, but are assigned different lines?

If not, do I need to bit shift the data if the task/channel doesn't start at line Px.0?

 

Thanks!

0 Kudos
Message 1 of 6
(4,002 Views)
Solution
Accepted by evizz

yes, as long as you are not using the same line on different channels, they should not interfere with each other for that reason, you can create a channel per line if you want

 

From the help reference of the DAQmxWriteDigitalScalarU32 function:
"Writes a single 32-bit unsigned integer sample to a task that contains a single digital output channel. Use this format for devices with up to 32 lines per port."

http://zone.ni.com/reference/en-XX/help/370471AC-01/daqmxcfunc/daqmxwritedigitalscalaru32/

 

so yes too, the DAQmxWriteDigitalScalarU32 can write to each task independently

0 Kudos
Message 2 of 6
(3,974 Views)

Thanks!

I just received my usb-6509 today and sure enough it works! Also verified that I do have to shift bits based on where the line starts in a port.

Is there a way to readback the bits that were written on a digital output channel? It would be nice to verify the correct value was written.

0 Kudos
Message 3 of 6
(3,971 Views)

Hi evizz

how about with the printf function? 

check this other forum, they used it to check the output status

https://forums.ni.com/t5/LabWindows-CVI/PCI-6528-Digital-output/m-p/564405

 

0 Kudos
Message 4 of 6
(3,954 Views)

Nice, so DAQmxReadDigitalScalarU32 will work on a DO channel? I tried it with the simulator, but no go.

0 Kudos
Message 5 of 6
(3,952 Views)

they said the state was always 0, I don't know why they were using that function with a DO channel on the other forum, that function is used on a DI channel to read the input, not the output, check the help for that function

http://zone.ni.com/reference/en-XX/help/370471AE-01/daqmxcfunc/daqmxreaddigitalscalaru32/

 

0 Kudos
Message 6 of 6
(3,942 Views)