LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Chopping a waveform for half cycle for higher frequencies

Solved!
Go to solution

Dear Forum Members, 

 

I'm trying to generate half of a sine wave but I need only the first wave. So I multiplied a sine wave with a square wave generator. I get a very good signal as follows...

la1.PNG

 

Problem: 

I want only the first wave and the rest zeros. Something like below, 

want.png

I tried using a ramp function and the unit step function. But the problem is, I want to generate for 6-10 Hz and they become less and less accurate for times, lesser than 1s.

 

Could you please help me? Maybe an easier method to work this out.. My vi is attached(.vi +.jpg). 

Thanks have a nice day 🙂

Best, 

Shane.

Download All
0 Kudos
Message 1 of 9
(3,998 Views)

Hi Shane,

 

create a square wave with just one pulse. Append "zero" values to get the same length as with your sine wave.

Then multiply both waveforms…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,996 Views)

 


@GerdW :

Yes. That is my intention but how to create a square wave with just one pulse? Do you mean to get them to the array and after some time, append every element to zero? Or is there an easier vi to generate a square wave with just one pulse. (which works in the ms range)

 

Thanks in advance GerdW

0 Kudos
Message 3 of 9
(3,975 Views)
Solution
Accepted by topic author ShaneJ007

Hi Shane,

 

is there an easier vi to generate a square wave with just one pulse.

All you need to know is the sample frequency and the sine frequency to calculate the number of samples you need to mask your sinewave:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(3,967 Views)

Let me see if I understand the problem:

  1. You have a sinusoid of frequency "f" (or alternatively period "P") with phase 0 (so at time 0 the sinusoid value is 0 and its slope is positive).
  2. You want a function that is the value of this sinusoid for time 0 .. P/2 (or 0 to 1/4 pi f), and 0 for all other times.

Sometimes you just create a function.  Here is "Half-sine":

Half-SineHalf-Sine

(the False case of the State is 0, of course).  And here is a generation of the first 100 points of a Half-Sine having a period of 50 (which should be a half-sine from 0 to 25 and zero everywhere else):

Generate Half-SineGenerate Half-SineHalf-Sine Graph.png

If you need something a little more complicated, your Generating Function would be a little more complicated ...

 

Bob Schor

 

Message 5 of 9
(3,963 Views)

@GerdW 

 

Hi Gred, Thanks it works. A small question, The Sinus wave now only plots upto 1s. this becomes a Problem when going to lower frequencies. Can this be resolved using a viewing option enabled? or what am i doing wrong here?

 grp3.PNGnewgrp.PNG 


 

0 Kudos
Message 6 of 9
(3,949 Views)

Hi Shane,

 

there are several controls on the front panel: play with them...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(3,942 Views)

Yes, but as i understand it has nothing to do relative display or absolute and it depends on the fs and sr....  

0 Kudos
Message 8 of 9
(3,932 Views)
Solution
Accepted by topic author ShaneJ007

Hi @GerdW 

Thank you for the first stone for solving the problem. But that was only true when the fs=#s. so changing the properties of the front panel doesn't help. (As I know but correct me if I'm wrong).  Did a few modifications based on your guidance on your code so that now always you get one pulse.Thank you. have a nice.. 

I'm just posting the following code for future references for the NI.

 

final.PNG evening...  

0 Kudos
Message 9 of 9
(3,926 Views)