05-13-2020 07:42 PM
Hi NI Community,
I'm measuring a 4Hz sinewave signal with DAQmx and I set the sampling rate to 100,000. The data is displayed on the waveform chart GUI but after 3 seconds of running, the waveform stops and I get the following error.
DAQmx_Gui_Producer_Consmer_1channel.vi<append>
<B>Property: </B>RelativeTo
<B>Requested Value: </B>Current Read Position
<B>Property: </B>Offset
<B>Requested Value: </B>0
<B>Task Name: </B>_unnamedTask<58B5>
Another issue I have is the waveform data that goes into TDMS does not print out the time component of it. How can I solve that?
05-13-2020 11:09 PM
Did it show an error number?
05-14-2020 03:53 AM
Hi victor55,
A sample rate of 100,000 Hz seems very high for measuring a signal at 4 Hz!
Because you are using the single sample version of DAQmx Read, that loop is going to be running very fast which may have something to do with the problem you are seeing. Why not use the N samples version and set the number of samples per channel to something like a quarter of your sample rate?
Your TDMS file will only contain the first waveform item from the queue. The second loop does not start running until the first loop has finished because of the Boolean wire from the stop button. Of course, when it does start running that Boolean is TRUE so it only runs once before stopping. If you want to write the data to file in parallel with the acquisition, the second loop must not be dependent on the first. To use the stop button to stop both loops there are many methods you can use: channel wires, property nodes, local variables, etc.
PsyenceFact
05-14-2020 04:30 AM
1. Your acquisition loop will not be able to keep up with hardware and you will get a buffer overflow. Change the DAQmx Read to Analog Input->Single Channel->Multiple Samples->Waveform. Then set the samples to read on the DAQmx Read to 10k. This will give you 100ms of data for each read (which is my general rule of thumb). Everything down from there will have no issues with this.
2. You have a data flow issue in that your stop boolean is going from inside the acquisition loop to the logging loop. This means that the logging loop cannot even start to run until the acquisition loop is complete. My suggestion is to send an empty waveform after the acquisition loop. The logging loop can check for an empty waveform and stop when it finds that sentinel. The queue is then destroyed after the logging loop.
05-14-2020 12:05 PM - edited 05-14-2020 12:06 PM
@PsyenceFact wrote:
Because you are using the single sample version of DAQmx Read, that loop is going to be running very fast which may have something to do with the problem you are seeing. Why not use the N samples version and set the number of samples per channel to something like a quarter of your sample rate?
You know, that picture was so tiny, I couldn't even seen that is was the N channel 1 sample version.! That explains a huge problem.
But the OP still should have provided the full error message including the error number.
05-14-2020 12:12 PM
@RavensFan wrote:
You know, that picture was so tiny, I couldn't even seen that is was the N channel 1 sample version.! That explains a huge problem.
It took quite a lot of zoom!
05-14-2020 12:23 PM
Thank you everyone for your reply.
1. If I want to have sampling rate at 100kS/s to detect any small transients that we might see in testing, how should I set that so things run smoothly?
2. I was able to fix the issue with my code and TDMS saves as the program is running. Once I stop acquiring data, the 2nd loop still takes a long time to complete dequeueing and saving data. How can I save larger junks of data every time the 2nd loop executes?
05-14-2020 12:40 PM
You need to acquire a set number of samples. Your current approach still tries to read as fast as possible. On your DAQmx Read there is a terminal for number of samples. Wire it. Otherwise you're telling it to read whatever samples are available when you get there. Your Producer loop is likely taking up a large amount of resources, and it's bogging down the consumer loop with lots of writes. You could, for instance, read 50,000 samples each time, giving a 500 ms update rate.
05-14-2020 12:48 PM
Another suggestion: Since you are saving to a TDMS file, use the DAQmx Configure Logging before you start your task. That will tell the DAQmx driver to stream the data to a TDMS file for you. No need for a Producer/Consumer! It makes things a lot simpler.
But, yes, you need to tell the DAQmx Read how many samples to read. I previously suggested 10k samples since that would be 100ms worth of data. My general rule of thumb is to read 100ms worth of data at a time. It is typically a good balance between speed and memory.
05-14-2020 12:53 PM
Awesome! thank you for your suggestion.
Another question I have is - my goal is to not overflow the PC's RAM with data and I would like to display X amount of data points on the screen then remove them from the buffer once they're saved to TDMS. I will probably have 16 or more channels collecting data and displaying data at 100kS/s. Basically, I want to keep only 5-10 seconds worth of data per channel in the buffer to display on the GUI and the rest is saved then removed from buffer memory.