07-09-2018 08:07 AM - edited 07-09-2018 08:08 AM
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.
amp = 1, freq = 15 Hz, period = 0,5 s
amp = 10, freq = 100 Hz, period = 0,5 s
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.
07-11-2018 08:22 AM
Hi rt_kp,
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?
Kind Regards,
Riley Ilieva
Applications Engineer
National Instruments
07-12-2018 02:27 AM - edited 07-12-2018 02:31 AM
Hi Riley,
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?
Best regards,
Artur
07-12-2018 03:58 AM
Hi rt_kp,
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.
Kind Regards,
Riley Ilieva
Applications Engineer
National Instruments
07-12-2018 06:10 AM - edited 07-12-2018 06:12 AM
Hi Riley,
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.
Best regards,
Artur
07-12-2018 07:12 AM
Hi Arthur,
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.
Many Thanks,
Riley ilieva
Applications Engineer
National Instruments
07-12-2018 07:55 AM - edited 07-12-2018 07:59 AM
Hi Riley,
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.
Best regards,
Artur
07-12-2018 08:08 AM
Hi Artur,
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?
Many Thanks,
Riley Ilieva
Applications Engineer
National Instruments
07-12-2018 11:32 AM
Hi Artur
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?
Thanks
Jerry
07-13-2018 03:44 AM - edited 07-13-2018 03:45 AM
Hi Riley,
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.
Thank you!
Artur