# LabVIEW

cancel
Showing results for
Did you mean:

## How to generate only a single cycle wave?

How do I make the sawtooth waveform vi to generate only a single cycle no matter what the frequency is adjusted to?

Message 1 of 8
(2,937 Views)

## Re: How to generate only a single cycle wave?

Hi AntZ,

using a loop when you want something to happen only once is kind of silly…

To generate just a single pulse/period of your signal you need to adjust the sampling info. Please read the help for the singal generation function - all the help on all those inputs…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(2,928 Views)

## Re: How to generate only a single cycle wave?

The Help Window doesn't explain much. But if I'm not mistaken, sampling frequency is the frequency at which the wave is being sampled whereas the number of samples is simply...what it says. To generate a single cycle all I need to do is to set the sampling frequency really high and the number of samples as small as possible. Too much samples would construct the structure of the wave beyond a single cycle on the graph. Correct me if I'm wrong. Kudos if I get it right...joking.

Message 3 of 8
(2,916 Views)

## Re: How to generate only a single cycle wave?

Hi AntZ,

To generate a single cycle all I need to do is to set the sampling frequency really high and the number of samples as small as possible.

Well, you're half way…

Simple math: #samples = period time * sampling frequency

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 8
(2,870 Views)

## Re: How to generate only a single cycle wave?

AntZ(TW),

> To generate a single cycle all I need to do is to set the sampling frequency really high and

> the number of samples as small as possible

> Correct me if I'm wrong. Kudos if I get it right...

You have the right idea, but an arbitrarily "high" sampling frequency is probably not the best solution.

The rule of thumb is to sample at 4 times the frequency of your signal.

But it depends on what you want to do with the resulting signal.

In the attached vi (LV 2013) you can play with the Sample Rate Multiplier and see the impact of different sample rates.
Note the Sample Rate Multiplier must be greater than or equal to 2 (this was set in the properties dialog).

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Message 5 of 8
(2,854 Views)

## Re: How to generate only a single cycle wave?

Hi Everyone,

I'm an Applications Engineer with NI and I've picked up stevem181's code and made a small change to it to make sure it only outputs one wave, whatever the sampling rate or frequency, I hope this helps.

I've added an event structure to wait for input from the user before outputting the sawtooth, one cycle at a time. To make sure it doesn't get stuck if the code is used as a subVI, I've configured it to output a cycle every two seconds if no input is detected.

Best Regards

Message 6 of 8
(2,824 Views)

## Re: How to generate only a single cycle wave?

This is one of those rare times when an express vi can help.

Playing with the rate, freq and # of samples and seeing the graphed signal can be valuable timesavers.

@VSenior The OP Posted in 2013.0 and likely cannot open the 2014 mod you uploaded

"Should be" isn't "Is" -Jay
Message 7 of 8
(2,813 Views)

## Re: How to generate only a single cycle wave?

Hi Jeff,

Thanks for the prompt, you're quite right, I posted in the wrong version of LabVIEW.

Here's the 2013 version...

Best regards

Message 8 of 8
(2,804 Views)