Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

WriteMultiSamplePort with USB-6009?

Can anyone help with writing multiple DIO samples using the WriteMultiSamplePort() function in C#.  I keep getting either errors like property not supported if I try to set the number of samples.  But I don't see any other way to do this with the .NET libraries.  I have it working in VB 6.0, but would be much happier with a .NET program.  Easier to maintain.
 
If you have functioning code please help me out with this.
0 Kudos
Message 1 of 4
(3,646 Views)
Are you grouping your channels with one line for each channel or one channel for all lines?  Also, what data type are you writing to your port?  Unfortunately, I don't have any functional code right now. 
The generated data must be a 2D array with the first dimension of the array corresponding to a channel in the task. And each element in the second dimension of the array corresponding to a sample to write to each channel. The order of the channels in the array corresponds to the order in which you add the channels to the task. The order of the lines in the array corresponds to the order in which you add the lines to the channel.
Also, keep in mind that if you are not using on-demand timing you have to call the WaitUntilDone method to allow the device time to configure all the data.
 
Micaela N
National Instruments
0 Kudos
Message 2 of 4
(3,639 Views)

 

I have it set up with one channel for all lines.  I'm writing a stream of bytes to the DAQ channel, and using each line as part of a serial comm port.  Also with the USB-6009 the only timing option is on-demand.

I'm glad you mentioned the 2D array thing.  I was using a DigitalSingleChannelWriter since I only have one channel created for my task.  With it a WriteMultiSamplePort only takes a 1D array.  So I started digging through the help file etc... and found that the WriteMultiSamplePort method of the DigitalMultiChannelWriter takes a 2D array.  I changed my array declaration and to [1,100], my writer to a DigitalMultiChannelWriter, and now everything works fine.  I don't really understand why the DigitalSingleChannelWriter didn't work, but this is much better than the one C# example that writes a single sample at a time.  When I was looping through a bunch of SingleSample writes I could only get about 50Hz on the line I'm using for a clock.   Now with the WriteMultiSamplePort I get more like 500Hz.
 
At least it's working... Thanks.
 
-Shawn
0 Kudos
Message 3 of 4
(3,628 Views)
Shawn,
 
I'm glad to hear that you got it working!  Good luck with the rest of your application.
 
Micaela N
National Instruments
0 Kudos
Message 4 of 4
(3,616 Views)