LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"How do I generate a sequence of waveforms, like first a sine wave, then a square one, and say again a sine wave?"

"Hello everyone, I hope someone can answer the following question. How do I generate a sequence of different waveforms, with different attributes?
Like, i want to generate a sine wave for some time, then a square pulse of some width and then again a sine wave of some other time. Finally I want to repeat this sequence. I'll really appreciated it if I can get an answer soon. Thank you!
0 Kudos
Message 1 of 6
(3,703 Views)
Create an empty array to hold the final signal, generate the sine segment and the square segment...and insert them into the final signal array using the array replace function...Or, if you are using the waveform functions, generate the two segments and use the append function.

If you want smotth transitions you could just create two full signals of each type and then create two "masks" that gradually fade each signal in and out in different segments of the final signal (the sum of the two after being multiplied with their masks).
0 Kudos
Message 2 of 6
(3,703 Views)
Thank you so much, now I have another question. By creating an empty array to hold the final signal I can manipulate the lenght and location of the square wave. What I'm trying to do is a sine wave that has a square wave attach to it for some time and then goes back to the sine wave. The final point is that when I run the code to an oscilloscope I get a sine wave that blanks out at certain points but I have to be able to manipulate the lenght and location of the square wave because that is the blank part on the oscilloscope. If you can answer this for me I'll really appreciate it. Once again thanks.
0 Kudos
Message 3 of 6
(3,703 Views)
From the previous comments I am assuming that your waveforms are arrays, rather than the waveform data type. I am also assuming that the sine waves on both sides of the square wave are the same signal.

If so then I suggest a slightly different approach. 1. Generate your sine wave, rather than the empty array. The length should be the length of the entire end signal.
2. Generate the square waveform. You can either generate it at the length you need, or you can generate a much larger square wave, and then use the Array Subset VI to get the portion you need. Which method you use depends how you want to implement the whole method.
3. Use the Replace Array Subset VI to place the portion of the square wave at the location (index) of the original sine wave you ge
nerated.

The result of this method will be an array that starts with your sine wave, and then at the index you choose it will place the square wave of the length you want right into the signal, and then finish up with the sine wave for the rest of the signal.

Evan Collier
Application Engineering
National Instruments
0 Kudos
Message 4 of 6
(3,703 Views)
Thank you evan for your answer. My waveforms are not arrays, I generated each waveform using waveform generator.vi and yes the sine waves are the same signal. Now, I'm a bit confused with your answer. You are suggesting to generate the sine wave and the square wave using the waveform generator.vi? Also, I will like to know if you have any examples where you use the array subset VI to get the needed portion of the waveform. Once again thanks for you help, I really appreciate it.
0 Kudos
Message 5 of 6
(3,703 Views)
It looks like Shan gave a great answer on your other posting, Creating a Square Wave Using an Array Function, with a sample VI included.


If you have any more questions about either of the postings feel free to keep replying to either one.

Evan Collier
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(3,703 Views)