08-09-2016 10:10 AM - edited 08-09-2016 10:12 AM
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!
Solved! Go to Solution.
08-10-2016 06:31 PM
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
08-10-2016 09:44 PM
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.
08-11-2016 03:18 PM
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
08-11-2016 03:33 PM
Nice, so DAQmxReadDigitalScalarU32 will work on a DO channel? I tried it with the simulator, but no go.
08-12-2016 08:53 AM
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/