11-19-2012 02:04 PM
I am really new to LabView.My task is to continuously sample multiple analog input channels, view them in real-time, and store them to a file (preferrably .csv file). I also need to command two analog output channels given user input.
I began by working with 1 input channel.
My incoming signal ranges from 100 - 200Khz, and I am using the NI USB-6351 which can sample at a maximum of 1MHz. Using the DAQ Assistant I configured it for continuous sampling, a sample rate of 300Khz, and 30k samples to read.
Using a function gen, my input is a 100khz sine wave, 1vpp. When I view the signal in a waveform graph on labview, the signal looks aliased. It looks like a triangular waveform.
Can anyone help please. I have attached my block and front panel along with a screenshot of the waveform.
11-19-2012 02:13 PM
Sample faster...
Let me put it this way. 100kHz input signal, 300kHz sample rate. This means you will have 3 samples/cycle of your sampled sine wave. That's why it looks funky. I would recommend running at the full 1MHz sample rate. I like to sample at at least 5x the maximum desired frequency, which is 200kHz in your situation, meaning you should sample at the 1MHz.
11-19-2012 02:40 PM
Do you know the reason for this. I assumed that Nyquist theory was upheld. However, this completely boggles me.
11-19-2012 02:49 PM
As I said before, you are only getting 3 samples/cycle of your input frequency. So take a pure sine wave. Now divide the time into thirds. Now draw a straight line connecting the points of the sine wave at the 1/3 time markers. That is what is happening.
All Nyquist says is that you have to sample at more than twice the max frequency in order to reproduce the frequency characteristics of the input. It says nothing about how clean your sampling will look.
11-19-2012 02:57 PM
Thank you.
Now that I am able to reconstruct my signal, is there a way that I can simultaneously generate an analog output within the same while loop?
I am obtaining a command voltage from the user and want to display it while generating an analog output. For some reason when I add this portion, my first Daq Assistant throws an error:
Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
11-20-2012 08:35 AM
I would actually recommend reading and writing in separate loops. This way the different IOs can run at whatever rate they need to.