# Signal Generators

cancel
Showing results for
Search instead for
Did you mean:

Solved!
Go to solution
Highlighted

## NI-FGEN user-defined wave

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 = 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.

Message 1 of 13
(1,399 Views)

## Re: NI-FGEN user-defined wave

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

Message 2 of 13
(1,372 Views)

## Re: NI-FGEN user-defined wave

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

Message 3 of 13
(1,360 Views)

## Re: NI-FGEN user-defined wave

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

Message 4 of 13
(1,349 Views)

## Re: NI-FGEN user-defined wave

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

Message 5 of 13
(1,346 Views)

## Re: NI-FGEN user-defined wave

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

Message 6 of 13
(1,340 Views)

## Re: NI-FGEN user-defined wave

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

Message 7 of 13
(1,336 Views)
Solution
Accepted by topic author rt_kp
07-13-2018 01:48 AM

## Re: NI-FGEN user-defined wave

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

Message 8 of 13
(1,328 Views)

## Re: NI-FGEN user-defined wave

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

Message 9 of 13
(1,316 Views)

## Re: NI-FGEN user-defined wave

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

Message 10 of 13
(1,301 Views)