I am trying to generate a sine signal with a triangular envelope with NI PXI-5412.
The idea is that a user sets the frequency of the sine wave and the amplitude of the triangular wave, but the period of the triangular wave is always 500 ms. Please see the pictures below.
The output waveforms produced by the controller are exactly what I need. However, NI-FGEN VIs do not generate anything similar to the constructed waveform.
Am I right in thinking that I should use the instrument “niFgen Create Waveform” for this particular task?
The code is attached. Any comments are welcome and appreciated.
Solved! Go to Solution.
I am not sure I understand what the problem is. The triangular wave frequency is set by a constant so it will always be the same.
Could you possibly elaborate more on what the task is and what part of the signal generation is not working as expected?
Thank you for the reply!
The task is to make the signal generator produce the sine waves like those shown in the figures.
The control variables are the frequency of the sine wave and the amplitude of the triangular wave that bounds the amplitude of the sine signal. The period (or frequency) of the triangular wave is constant.
In the attached code, the Output Mode of niFgen Configure Output Mode VI is Arbitrary Waveform (as waveforms are defined by the user). The waveform is first constructed based on the input values (frequency and amplitude) and then fed into niFgen Create Waveform (poly) VI. After that, niFgen Initiate Generation VI, in turn, should generate the corresponding signal based on the received Waveform Data Array, as far as I understand. Unfortunately, nothing similar to the graphs of the waves is shown on the screen of my oscilloscope.
What is wrong with my code? Should I convert the waveforms into some arrays before feeding them into niFgen Create Waveform (poly) VI?
Thank you for explaining. Could I check what you see as an output on the oscilloscope? Arbitrary Waveform sounds like what you are aiming for so that shouldn't be the cause.
Are you looking to continuously generate the waveform? There is a LabVIEW example I am attaching that might give you some ideas.
Thank you for the reply and the code example.
Here are the graph of the desired wave and the graph shown by my oscilloscope:
The waves are clearly different in smoothness.
The problem seems to be caused by the number of samples but niFgen Set Sample Rate VI does not help: e.g. setting 400 samples/sec for the 40-Hz frequency did not change anything.
Could it be the sampling rate on the oscilloscope?
There are a few things you can try to test this:
1. Change the frequency of the input waveform you are generating sand see if the result of the scope matches it better.
2. Change the oscilloscope's time per division setting.
I seriously doubt that is the sampling rate of the oscilloscope. Here is the output of the oscilloscope when the wave is a simple 9-kHz sine function generated by the standard example Fgen Function Generator.vi:
Here is also a 100-Hz wave generated by my program:
So the result is quite poor regardless of the frequency value.
Then this eliminates the oscilloscope. Do you see any differences between the example and your code? Is what is displayed in the Sine Pulse different to what you see in the scope?
Can you tell me what the sampling rate for the oscilloscope was for the 2 scope images? Is it the same?
Are you using an auto setup function?
The constructed waves were not smooth enough because of the small sample rate of Sine Waveform VI and Triangle Waveform VI. I could not see the problem because the waves displayed in the graph still looked a little different from the output of my oscilloscope.
Now, it works as expected.