Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously read 2 tasks with different sample rates

Hi,

 

I'm in trouble about continuously read 2 tasks with different sample rates with a SCXI system. I want to read  a task with 2 accelerometers with a sample rate of 20kHz and another one with 10 voltage channels at 1khz. 

 

When I use the reverve/unreserve of daqmx control task the signals became discontinuous, and when I use the start/stop daqmx task the signals became discontinuous too and the loop period increases very much.

 

What is the best way to resolve this problem?

 

 

 

0 Kudos
Message 1 of 9
(4,740 Views)
Have you synchronised the two tasks to? You can syncronise both tasks to use the same same start trigger
David
www.controlsoftwaresolutions.com
0 Kudos
Message 2 of 9
(4,727 Views)

I do not use any trigger , only a button ON. The task access the same communication module SXCI 1600, and I want to monitor 2 sets of channels with different samples rates.

 

 

0 Kudos
Message 3 of 9
(4,693 Views)
Use a single task at the higher sample rate and decimate the results for the channel that you want the slower sample rate.
0 Kudos
Message 4 of 9
(4,688 Views)
The SCXI 1600 module uses only a multiplexing mode and the maximun frequency of 200kHz, then if I want to measure channels with 20kHz I can only measure 10 channels. My application must monitor at least 20, but only 4 with 20kHz.
0 Kudos
Message 5 of 9
(4,683 Views)
Your first post indicates 12 channels and now you are saying you need 20. You simply cannot have two different sample rates. If you really need 20 channels with some at 20kHz, you need to get a different card or add one to the system.
0 Kudos
Message 6 of 9
(4,677 Views)
Full system is 20 channels. I want to switch between these tasks. Like this: monitor the analog inputs for .2s and at the end of this time read the accelerometers for .2s .
0 Kudos
Message 7 of 9
(4,666 Views)
Then you are back to your original complaint where the signals are discontinuous. You can't have it both ways. You either start and stop a task before doing another, or you use a single task. The time it takes to stop one task and start another is time that you will not be acquiring.
0 Kudos
Message 8 of 9
(4,657 Views)

I'm not sure if this will be helpful or not but the following code does something similar (to the most recent description of your question):

Read Multiple Channels Sequentially Using DAQmx

 

The way the program works is as follows:

1.  Configure the Convert Clock rate to be the desired aggregate sample rate (200 kHz max on the 1600)

 

2.  Use a separate DAQmx Virtual Channel for every sample to be taken.  This allows you some freedom to dictate how the device scans through channels (although some SCXI hardware is limited in scanning options).  A few examples of how you could use the concept, depending on what SCXI modules you are using:

 

a)  Switch between individual channels without delay while sampling at the maximum rate of the device (this is what the example is set up for).  To do this your channel list would look something like this:

[0 0 0 0 0 0 ... 1 1 1 1 1 1 ... etc.]

 

b)  Switch between groups of channels sampled at the maximum aggregate rate (for example you could sample 2 channels at 100 kHz on the 1600 then switch to another 2 channels with no delay):

[0 1 0 1 0 1 ... 2 3 2 3 2 3 ... etc.]

 

c)  Sample channels at "different rates".  By repeating channels in the scan list you can achieve different effective sample rates across multiple channels.  Keep in mind that the convert clock generated by the 1600 is not going to change its rate on the fly* so if you don't space the channel list evenly you will have an inconsistent sample rate.  Here's an example scan list that shows how you could have a uniform rate on each channel while sampling channel 0 4x faster than the other four channels in your task (with a 200 kHz convert rate this would give rates of 100 kHz on channel 0, and 25 kHz on channels 1-4):

[0 1 0 2 0 3 0 4]

 

* If using an X Series DAQ Device, one could use a buffered counter output to generate a non-uniform convert clock to get more creative with scanning.

 

3.  Based off of the Scan List chosen, you then parse out the data and display it appropriately for the end-user.

 

Only case a) from above is shown in the example, but to get the other behaviors it's just a matter of building the appropriate scan list.  I'm still not clear on exactly what your scan list and rates are going to look like (you may have to make some compromises) but you might be able to play around with the above example to get something close to what you want.

 

 

The idea isn't exactly the most straightforward but I have worked with it before in specific use cases.  Assuming your hardware supports multiplexing in this way then this might be a suitable starting point for what you need to do.  If you provide more details about your application we could offer more specific advice for building your scan list.

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 9
(4,654 Views)