Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-FGEN user-defined wave

Solved!
Go to solution

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 samp = 1, freq = 15 Hz, period = 0,5 samp = 10, freq = 100 Hz, period = 0,5 samp = 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.

0 Kudos
Message 1 of 13
(6,066 Views)

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

0 Kudos
Message 2 of 13
(6,039 Views)

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

0 Kudos
Message 3 of 13
(6,027 Views)

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

 

0 Kudos
Message 4 of 13
(6,016 Views)

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:

oscilloscope graph.jpg

wave graph.jpg

 

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

0 Kudos
Message 5 of 13
(6,013 Views)

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

0 Kudos
Message 6 of 13
(6,007 Views)

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:

sine1.jpg 

 

 

 

 

 

 

 

 

 

 

 

 

 

Here is also a 100-Hz wave generated by my program:

 

 result21.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

So the result is quite poor regardless of the frequency value.

 

Best regards,

Artur

0 Kudos
Message 7 of 13
(6,003 Views)
Solution
Accepted by rt_kp

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

0 Kudos
Message 8 of 13
(5,995 Views)

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

0 Kudos
Message 9 of 13
(5,983 Views)

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

0 Kudos
Message 10 of 13
(5,968 Views)