LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimate.vi doesn't work for me

Solved!
Go to solution

Hello,

 

I am using two NI9237-modules and a NI9219 in a NIcDAQ-9174 chasis. The NI9237's are used to measure strains and the NI9219 is used for currents. I want to measure both with a frequence of 100 Hz. I already know that the min sample rate of the NI9237 is 1613 Hz so I used 2000 Hz for this and decimated it to 100 Hz with the decimate.vi. 100 Hz is the max sample rate of the NI9219 so this should work.

My problem now is that I get multiple errors and the excel file of the measured information is empty. I also don't really know what to put in the 'samples to read' box in the DAQ assistant.

 

I hope somebody can help me. Included is my vi.

 

Kind regards

0 Kudos
Message 1 of 18
(3,778 Views)

I found the problem

0 Kudos
Message 2 of 18
(3,718 Views)

Then tell us what it is.  That way if anyone has a similar problem and searches the forums, your solution may be able to help them!

0 Kudos
Message 3 of 18
(3,711 Views)

Hello RavensFan

 

There seem to be several things that could go wrong.

 

At one side the 9219 is reading 1k samples at a 100 Hz rate.

At the other side the 9237 is reading 15k samples at a 2k rate.

With this in mind I do not see/understand why a decimating factor of 20 is being used.

 

Aside from this it seems like one of the DAQ Assistants for the NI 9237 is refering to a cDAQ (cDAQ2Mod3) and another one is not referring to a cDAQ (Dev1).

 

I don't have the exact modules at my side, but just similating with 3 modules in a cDAQ at my side gives me the exact error the customer gets.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 4 of 18
(3,679 Views)

Hello,

 

I'm sorry I forgot my solution for the decimate problem. I had to use the decimate.vi on all the seperate signals and not on the combined signal. I included my newest prog.

The program has slightly changed. I now use two triggersignals which both can activate the case structure. The two NI9237 are still reading data from strain gauges and the NI9219 reads a voltage and a current. (Still all at 100 Hz)

I am still getting errors though. Sometimes 10 minutes later when I started the prog and sometimes in the beginning... I changed the buffer sizes and the decimate factor to correct values (I think).

 

Could someone check my vi,

thank you

 

 

 

 

0 Kudos
Message 5 of 18
(3,642 Views)

Update: the error occurs only with the NI9219 but I can't solve it

 

0 Kudos
Message 6 of 18
(3,628 Views)
Solution
Accepted by topic author Stephny

That is a buffer overrun error.  You don't have your acquisition rates and number of samples to read set correctly.

 

All 3 DAQ assistants are set for continuous samples.  So once they start executing the buffer starts filling up.  Your two 9237's are set for 50k samples at a 2k rate.  So it will take 25 seconds for it to return data.  (As a separate issue, you set your timeout to 25 seconds, but that is probably too close to how long it takes to acquire data.  It is always on the verge of timing out when it finally gets its last sample.  Any minisicule delay could result in a timeout error.)

 

Your 9219 is set for 2k samples at 100 Hz, so it takes only 20 seconds to acquire your data.  (Again, the timeout is too close to that.)

 

So what happens?  Your 9237's establish the loop rate at 25 seconds.  In 20 seconds, the 9219 returns 20 seconds worth of data, but collects 5 more seconds.  Next iteration.  After 15 seconds, the 9219 returns 20 seconds worth of data (5 from before, and 15 new)  then proceeds to collect 10 more seconds in the buffer before the 9237's return their data and the loop iterates.  Third iteration, 9219, 20 seconds worth of data (10 from the buffer, 10 new), then 15 more seconds fill up the buffer.  After every iteration, the buffer fills up with 5 more seconds.  Do it long enough and the buffer will overflow and you'll get that error.

 

Balance your data collection rates better.  For the 9219, collect 2500 samples at 100 Hz, so you get 25 seconds worth of data.  Or return all samples instead of a finite amount.  You'd be better off using the underlying DAQmx functions than using the DAQ assistants.  Do you really want every loop iteration to take 20 or 25 seconds?  That is a long time that the VI will look like it is doing nothing.  If you hit the stop button, it will take up to almost 50 seconds for the VI to actually stop.  Collect fewer samples per iteration.

 

Why are you collecting so many samples at a high rate?  You are decimating them without doing any averaging, so you are just throwing away most of the data.  You might as well collect feweer samples at a lower rate.

Message 7 of 18
(3,604 Views)

Hello

The reason why I don't work with daqmx fucntions is that is like chinese to me. Smiley Frustrated

About the program, I changed the samples to read of the NI9237's to 20k with a sample rate of 2k. So it takes 10 second to get the samples. The NI9219 has 1000 samples to read with a frequence of 100 Hz. So it takes also 10 second to complete this. The signals from the NI9237's are decimated with a factor of 20. The time-out is the default value of 15 with the three modules. It works now. I'm gonna let it run a night and I will see if it runs perfectly...

 

Thank you very much!

 

 

0 Kudos
Message 8 of 18
(3,594 Views)

Those numbers sound like they will work for you.

 

Good luck!

 

PS.  There are a few ways to learn more about the DAQmx functions.  On NI there are tutorials like Getting Started with NI-DAQmx: Main Page.  In the example finder, there are dozens of example VI's showing DAQmx.  Also, in a copy of your VI, (since the following steps might be undoable), right click your DAQ Assistant and choose Open Front Panel.  That creates a normal subVI you can open and see the underlying DAQmx code that the DAQ assistant had configured.

0 Kudos
Message 9 of 18
(3,581 Views)

I edited my previous post. Because of the sample rate you need a minimum buffer size. So the minimum time for getting the samples is 10 seconds

 

How Is Buffer Size Determined?

Input Tasks

If your acquisition is finite (sample mode on the Timing function/VI set to Finite Samples), NI-DAQmx allocates a buffer equal in size to the value of the samples per channel attribute/property. For example, if you specify samples per channel of 1,000 samples and your application uses two channels, the buffer size would be 2,000 samples. Thus, the buffer is exactly big enough to hold all the samples you want to acquire.

If the acquisition is continuous (sample mode on the Timing function/VI set to Continuous Samples), NI-DAQmx allocates a buffer equal in size to the value of the samples per channel attribute/property, unless that value is less than the value listed in the following table. If the value of the samples per channel attribute/property is less than the value in the table, NI-DAQmx uses the value in the table.

Sample RateBuffer Size
No rate specified 10 kS
0–100 S/s 1 kS
100–10,000 S/s 10 kS
10,000–1,000,000 S/s 100 kS
>1,000,000 S/s 1 MS
Note Note  For performance reasons, the default buffer size for continuous acquisitions differs slightly when logging is enabled.

You can override the default buffer size by calling the Input Buffer Config function/VI.

NI-DAQmx does not create a buffer when the sample mode on the Timing function/VI is set to hardware-timed single point.

Note  Using very large buffers may result in diminished system performance due to excessive reading and writing between memory and the hard disk. Reducing the size of the buffer or adding more memory to the system can reduce the severity of these

0 Kudos
Message 10 of 18
(3,576 Views)