Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB 6008 multi-channel AI program in C#

Solved!
Go to solution

I am writing a program in C# to gather voltage data.

 

I wish to allow the user to enable/disable which channels they wish to collect from (to a maximum of 4), designate sample count and sample rate for each, and write the log into a tdms file. I'm thinking of calling Task.AIChannels.CreateVoltageChannel four times to create the four channels, and Task.Timing.ConfigureSampleClock four times to configure sampling parameters individually.

 

Similar threads seem to indicate that one AI channel must finish sampling before another AI channel could begin. Is that true? Could my method work?

0 Kudos
Message 1 of 5
(3,870 Views)

You could have multiple channels running on a single task, so you would be able to configure all of them  in a single task, and then run that task to read from all of the ones you configured, but you can't change which channels are running on the task while the task is running, and you can't run multiple AI task with the same device at once either.

 

So if you want the user to confiugre which channels he is reading from at different times, you'd have to stop the task that is running at that moment, reconfigure it, and then start it again.

 

Cheers.

Message 2 of 5
(3,847 Views)

Thanks for your reply.

 

So I figured out that I could run multiple channels in the same task, but it seems that the sampling parameters are only read once and applied to every single channel. (If I configure sampling parameters multiple times inside my program, only the most recent call will be applied to all enabled channels.) Does that mean that there is only a single internal clock governing sample rates/sample count inside the hardware?

0 Kudos
Message 3 of 5
(3,843 Views)
Solution
Accepted by topic author darktongue

You are correct about that, there's only a single clock controlling the task, so there's no possibility of setting the channels at a different rate, and the API would use the last one that was configured.

 

A common practice when different sampling rates are required is to sample at the fastest needed rate for all the channels, and then 'decimating' the data obtained for the slower channels so you can obtain the ammount of samples you'd expect.

Message 4 of 5
(3,834 Views)

That's a great idea. Thanks a lot!

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