From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead 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?

Download All
0 Kudos
Message 1 of 8
(3,156 Views)

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
(3,147 Views)

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.

0 Kudos
Message 3 of 8
(3,135 Views)

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
0 Kudos
Message 4 of 8
(3,089 Views)

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.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 8
(3,073 Views)

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

0 Kudos
Message 6 of 8
(3,043 Views)

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

Capture.PNG

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
0 Kudos
Message 7 of 8
(3,032 Views)

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

0 Kudos
Message 8 of 8
(3,023 Views)