Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Read from DAQmx task with 10Hz sampling rate produces way too much data

Solved!
Go to solution

I have a simple setup with an NI-9237 4 channel strain amp held by a WLS-9163 C series carrier (wired ethernet mode) - details probably don't matter.

 

I used MAX to create an associated DAQmx task that samples all four gages.  The timing setting is "Scan Loads" is Continuous Samples, 2k buffer (samples to read), and 10 Hz Rate.  I would assume this task would generate 40 data values/second - 10 for each channel.

 

I have a simple read loop using DAQmx Read.vi which runs forever (without any time pacing).  The Read is set to read all available data, and then pump it into a table.
  In the attached example, I also added some debug terms to stop the loop after N iterations.

 

Since the loop is timed with a period of 0.2 seconds, I'd expect each pass of the loop to read approximately 8 samples or 2 samples per sensor.  Instead, I'm getting hundreds every pass.  It's as though the Read has overridden the sample rate I specified in the device task.  I absolutely need the data to be hardware paced.

 

Where have I gone astray?

 

0 Kudos
Message 1 of 6
(4,464 Views)
Your attachment didn't make it through.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 6
(4,455 Views)
I double checked that darn attachment but the session had expired by the time I finally submitted it and I guess the attachment didn't survive the refresh...
0 Kudos
Message 3 of 6
(4,453 Views)

Hmm this example that I derieved from the examples works perfect on my computer. Can you try it on yours? Also, you can use the Available Samples Per Channel Property node to set the right rate. If you set the rate to 10Hz, then you will only read 2 samples per channel according to the software timing that takes place.

 

Post back if you have any queries.

Message Edited by Adnan Z on 04-01-2009 11:37 AM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 6
(4,449 Views)

Oh and sorry to not address your concern. The reason you are getting more samples than you are expecting is because your loop does not run every 200ms. You are building a table and then displaying the table (user interface) which increases the loop rate. If you are interested in reading just two samples on every loop for every channel, then specify that in the read and decrease the sample rate so you don't end up overflowing the buffer. Again, the available samples per channel property node should help you set this up.

 

Otherwise, you can implement a producer/consumer architecture and have another loop take care of creating the table and handling the user interface (which is the right way to program). To get an idea of this architecture, navigate to File -> New.. and access the Producer/Consumer design pattern.

Message Edited by Adnan Z on 04-01-2009 11:46 AM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 6
(4,447 Views)
Solution
Accepted by Burnt Fingers

Thanks Adnan,

 

I changed your example only in that I selected "Strain gage" at the analog input, and then lowered the min and max thresholds to +-1e-2.  What happens is that every other pass through the loop, I get either 2048 samples or zero samples.  The display flashes an entire line, and then clears it every other pass.

 

In reply to your second message, I understand that the loop might not run at quite the rate I select.  I expect that but at a sample rate of 10 Hz, I'd have to sleep the software side for almost a minute before I built up 2K samples.

 

I played with the sample rate a bit, setting it at various values between 0.1 and 10000Hz.  The behavior is the same until I approach the high rates where the available samples stays at 2048 - sometimes 4096 and the display becomes continuous.

 

Ahhh Darn.  Yet another search turned up this link which points to the root of my confusion.  The 9237 cannot sample at arbitrary rates using its internal clock.  Duoh!  I wish the drivers were smart enough to warn you if there is a mismatch between the selected sample rate and the device's capabilities

Message 6 of 6
(4,429 Views)