Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to single line with DAQmx

Hello,
 
life was so easy with traditional DAQ...
 
I'm trying to control single lines of DIO cards with DAQmx und CVI 8.0.1 , - the equivalent in traditional DAQ would be "DIG_Out_Line"
 
What I do:
- I create a task
- I add one channel for each digital line
 
DAQmxCreateTask (tsk_MAIN_OUTPUT_A, &tMainOutputA);
DAQmxCreateDOChan (tMainOutputA, "Dev1/port0/line0", "Line0",DAQmx_Val_ChanPerLine);
...
...
DAQmxCreateDOChan (tMainOutputA, "Dev1/port0/line7", "Line7",DAQmx_Val_ChanPerLine);
 
 
When I look into the "WriteFunction" collection, I find all kind of functions that write to tasks, but none which writes to channels...
The examples which comes with CVI only writes to a port, - 8 bit at a time, - which is what I want to avoid...
 
What am I missing?
 
Thanks a lot!
Greg
 
 
 
0 Kudos
Message 1 of 5
(5,182 Views)
Hello Greg,

You can control each of the individual lines of a DIO card by using a separate task for each line.  A DAQmx task is a collection of virtual channels, timing and triggering information, and other properties regarding the acquisition or generation. If you want to have the ability to write to a single line you'll want to have each of the lines in separate tasks.  Otherwise, you can include all of the lines in a single task and write to them all at once.

You may find these links helpful since you are just getting started with NI-DAQmx:
Transition from Traditional NI-DAQ to NI-DAQmx
Learn 10 Functions in NI-DAQmx and Solve 80% of Data Acquisition Applications
What are the Terminology Changes in NI-DAQmx

Post again if you have any further questions,
Micaela N
National Instruments
0 Kudos
Message 2 of 5
(5,166 Views)

Hello Micaela,

I've found out about the difference of tasks and channels in the meantime. However, thanks a lot for answering. The application is running fine now.

Best Regards,

Greg

 

 

0 Kudos
Message 3 of 5
(5,160 Views)

I have a 6516 card and I'm try to control the eight lines on port 3 individually.  I've gone through all the sample code and such.  Is this card capable of this?  Here's the code that I have write now.

Dim digitalWriteTask As Task = New Task()
digitalWriteTask.DOChannels.CreateChannel("Dev1/port3/line0", "port1", ChannelLineGrouping.OneChannelForAllLines)
Dim writer As DigitalSingleChannelWriter = New DigitalSingleChannelWriter(digitalWriteTask.Stream)
writer.WriteSingleSamplePort(True, 1)

I've tried ChannelLineGrouping.OneChannelForEachLine and DigitalMultiChannelWriter with no luck.  I also tried making a task in MAX to control Dev1/port3/line0 and this doesn't work either.  I'm starting to think this isn't supported on this card.

Could any shed some light on this for me.

 

Thanks in advance,

Gary

0 Kudos
Message 4 of 5
(4,781 Views)
Doh!  Sorry about that.  I had forgotten to wire the last port.  It works fine now.  It's definitely Monday.
0 Kudos
Message 5 of 5
(4,776 Views)