07-21-2011 01:46 PM
Hello all,
I'm still new to LabVIEW, but I've played around enough to create a simple analog waveform generator. The signals produced appear staircased when displayed on an oscilloscope, but are smooth when I reread the signals into an analog input (as shown by the waveform graph). How can I change my program settings so that I can view this staircased signal?
I run LabVIEW 2010, and use a USB X Series Multifunction DAQ.
Thanks,
-Olivier
Solved! Go to Solution.
07-21-2011 01:53 PM
I've replaced the NI-DAQmx code with the DAQ Assistant for convenience. Updated version below.
07-22-2011 03:20 PM
Olivier,
More than likely, it is the sampling rate of the oscilloscope. If you are not sampling fast enough, this would cause the waveform to appear "stepped".
Have you tried using some of the LabVIEW Example Finder (LabVIEW » Help Menu » Find Examples... » Browse Tab » Hardware Input and Output » DAQmx » Analog Generation) examples to generate a sine wave and then acquire that signal? This is a good way to eliminate any programming errors that might have been made.
If you generate a sine wave with Cont Gen Voltage Wfm-Int Clk.vi, do you still see the jagged edges when acquiring with the scope?
Let me know if you have further thoughts or questions.
Regards,
Aaron
07-25-2011 02:11 PM
Thanks for your help. The sampling rate does play a role in the number of steps displayed, but I've found that altering a combination of the DAQ sampling rate, the number of samples outputted, and the duration and frequency of the signal also influences the resolution. However, I don't know the exact relationship between these four controls and, furthermore, the signal becomes distorted when the duration involves a decimal. Can you explain how these factors affect the resolution, and how I can avoid distorting the output signal? I've attached several pictures to describe my situation below.
08-01-2011 04:24 PM
Olivier,
Thank you for posting. I am a little unclear about what some of the front panel controls are in you're images, but I will explain the best that I can about what I believe is going on.
Take a look at the following images.
Generating a 1kHz sine wave:
Acquiring at 100kHz:
Acquiring at the Nyquist Frequency (2X the input signal's frequency):
What I am trying to demonstrate here is that you are only going to see a smooth signal if you are sampling fast enough. For instance, if you generate a 1kHz and sample at 2kHz, you will only see two samples per period. This will give you an accurate period and frequency, but nothing else. Because an analog to digital converter is used here, you must sample at a much faster rate to get a "smooth" signal. In my above 100kHz acquisition, you see that we are getting 100 samples per period which produces a much smoother waveform. I would suggest that you acquire a 5kHz signal at something on the order of 500kHz to see a smooth signal.
Let me know if you have further questions!
Regards,
Aaron
08-04-2011 09:39 AM - edited 08-04-2011 09:40 AM
I don't think my error concerns the sampling rate so much as the resolution of my generated signal. Even at high sampling rates, the acquired signal physically appears 'stepped' (you can view the acquired signal on the right in my previous pictures) as opposed to jumping from point to point as a result of a low sampling rate. Is there a way to manipulate the frequency or clock rate to maximize the resolution of the generated signal?
Also, I noticed that the LabVIEW example voltage generator uses 'Basic Function Generator'.vi to create a signal, while I use 'Signal Generator by Duration'.vi. Is there any significant difference between these two VI's?
08-05-2011 12:20 PM
Olivier,
The signal's resolution is maximized by default when it is output. Do you mind posting you're example VIs or screenshots of the block diagrams so that I can take a look at you're DAQmx configuration?
Thank you,
Aaron
08-05-2011 01:10 PM
Here are updated copies of my Waveform Reader and Generator, along with a picture of my issue.
08-08-2011 04:21 PM
Olivier,
The issue is in you're waveform generation VI. I would suggest that you take a look at the way the Cont Gen Voltage Wfm-Int Clk.vi example VI is constructed (I know this example produces the correct behavior). I would also suggest that you use Waveform Buffer Generation.vi to produce the waveform. I believe that the stepped behavior is because of the way you constuct you're waveform that is input into the DAQ Assistant. The examples are located in the Example Finder: LabVIEW » Help Menu » Find Examples... » Browse Tab » Hardware Input and Output » DAQmx » Analog Generation | Analog Measurements » Voltage.
This is how I would run the test:
1. Connect an Analog Output channel of you're DAQ card to an Analog Input channel.
2. Run the example Cont Gen Voltage Wfm-Int Clk.vi. Select the appropriate device and channel. Leave the remaining parameters as default.
3. Run the example Acq&Graph Voltage-Int Clk.vi with the appropriate selections made for you're device and channel. Change the Sample Rate to 20kHz.
Regards,
Aaron
08-13-2011 07:22 AM
Even using the LabVIEW examples, the waveform still appears staircased at low frequencies. Is this simply normal behavior for a produced signal?
My parameters are:
Cont Gen Voltage Wfm-Int Clk
Desired Frequency = 100
Cont Acq&Chart Samples-Int Clk
Rate = 20k
Samples to Read = 1000
X-scale = 0 to 0.002
Y-scale = -1 to 1
Everything else is default