LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error 2501 saving the data using producer consumer

Solved!
Go to solution

Hi,

 

My application does 2 main thing:

1) acquire data (the signal of the analog output channel)

2) controlling parameters of an AC motor.

this VI is under the name: Trail of Main 2. I took this VI (that works) and I wanted to upgrade the acquired signal and analysis part, using the producer consumer pattern.  this VI is under the name: Trail of Main 2- with producer consumer. I took the analysis part of the signal and moved it to the consumer loop which there I also want to save the data.

the motor loop is irrelevant to my problem.

I don't know why I get an error, I followed the instruction in the NI web for TDMS files and the producer consumer. 

I want the user to have the ability to choose the path and name of the new file. 

 

thanks in advanced,

Naama 🙂

0 Kudos
Message 1 of 3
(2,461 Views)

and the files as explained in the previous message

 

Download All
0 Kudos
Message 2 of 3
(2,444 Views)
Solution
Accepted by topic author Naama2110

This is a strange error that doesn't seem to have anything to do with TDMS or the basic Producer/Consumer stuff, but may involve other not-so-transparent parts of your code.

 

When dealing with a complex system, with DAQ, Motor Control, TDMS, Filtering, etc., it sometimes helps to write a simple "Simulation" version of your system.  Doing this, you can test pieces of your code in isolation, and can even simulate "what you think you want" and test other assumptions that you have been making.

 

Below is a Snippet (and I'll try to remember to attach the Actual VI) of your routine with the DAQ stuff stripped out, and a WaveForm consisting of a 2KHz sinusoid, a 30Hz sinusoid, and noise generated at the frequency you are specifying for your sampling (i.e. 500KHz, seems way too high) in the Producer Loop.  The Consumer Loop does the BandPass-Rectify-LowPass operation and writes to a TDMS file and a Chart.  I'll point out some significant changes.

PC Sim.png 

  • The Producer is "on top".  This is purely Style, but keeps the idea that "data" likes to flow left-to-right and top-to-bottom.
  • The Queue is unnamed.  Since the Queue is totally defined by its Queue wire, there is no need to name it.
  • I'm trying to mimic the generation parameters in your code, generating 100K samples at a time using a "signal generator" running at 500KHz.  As I noted, I'm generating a "known" waveform with noise and two fairly-low-frequency sinusoids.
  • The Timer in the Producer Loop is set to make the loop repeat 500K/100K, or 5 times, a second, the same as the DAQ Producer.
  • The Stop Control is only in the Producer Loop.  When the Producer exits, it puts a "blank" Waveform on the Queue, which serves as a "sentinel", a signal to the Consumer that it should stop (and not process the empty waveform).
  • The Consumer is concerned with Analysis and TDMS output, so I group these functions together.
  • I use an In Place Element Structure to simplify the unbundling and re-bundling of the Waveform (keeps the Block Diagram neater).
  • A Case Structure and test if the Waveform has an empty Data Array is the test for the Producer's sentinel, the signal that means "Don't Process this, it is the Exit Signal".  If True, the first Case releases the Queue, as the Producer (which is the only thing filling the Queue) will have already exited.  The False Case (illustrated) consists of the Filter-Rectify-Filter processing.
  • The second Case simply does the TDMS and Chart output when the Sentinel is not present (otherwise it does nothing).  Note that the Sentinel value is used to stop the Consumer loop, allowing the TDMS file to be closed.
  • I took the liberty of selecting the Decorations around the Chart and the Chart itself, then using the Reorder button on the Menu Bar (the right-most) to "Group" these elements.  Now you can drag them around to reposition and everything "stays together".  A useful thing to know.
  • Unless the Time of Day is important in your Chart, I recommend using Relative Time.

This code runs without errors.  Because of the Rectify/LowPass filter, no high frequency components of the original signal are present in the TDMS data.  In particular, the "known" 2KHz sinusoid is mostly removed.  Thus you can probably reduce your sampling rate to something like 10KHz (instead of the what-seems-to-be-completely-ridiculous 500KHz rate) and still capture all the "data you want to study" (everything else at frequencies above 30Hz is largely filtered out).

 

Bob Schor

Message 3 of 3
(2,412 Views)