LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating a square wave using an array function

I want to know if is possible to create a square/pulse waveform using a build in array. I need a square/pulse wave to which I can manipulate the width of the pulse.
thanks.
0 Kudos
Message 1 of 6
(5,754 Views)
Have you tried the built-in "Square Wave.vi"? It is located in the Function pallete Analyze > Signal Processing > Signal Generation.

If you have the base package of LV, you'll have to build the square wave yourself. If you have to do this, try building two arrays, the first array will be zeros and second array filled with ones (or whatever you want you amplitude to be. You can concatante those arrays in a for loop n times until you have the signal you desire.

Post back if you need an example

Tim
Message 2 of 6
(5,754 Views)
Thanks for your answer! I tried the squarewave.vi but it doesn't work for me because I need to combine it with a sine waveform and I have to be able to change the location and width of the square waveform. Can you provide me with the example using the two arrays.
Thank you very much.
0 Kudos
Message 3 of 6
(5,754 Views)
Do you mean something like this?
0 Kudos
Message 4 of 6
(5,754 Views)
That is exactly what I am trying to do. THank you so much, I really appreciate your help. You can't imagine how much you helped me out. Now I have a good start point to finish what i have to do. I still have one question, I'm sorry to bother, why do you use the reciprocal of the sample rate.
0 Kudos
Message 5 of 6
(5,754 Views)
The reciprocal of the sample rate is used simply for plotting purposes. When using a Waveform Graph you bundle your array with a start time and delta t. Delta t is just the reciprocal of the sample frequency.

BTW, depending on what your sending the "build" waveform to, you might need to ensure that the transitions between different types of signals is smooth (e.g. end of the sine wave and start of the square wave).

Tim
0 Kudos
Message 6 of 6
(5,754 Views)