LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine Wave to Square Wave

Hi All

 

Im trying to create a VI that converts a sine wave to square wave with unsymetrical switching points. So far ive created a VI that does it symmetrically but cannot for the life of me figure out how to do it asymetrically. 

 

I want a HI when the sine wave is greater than +0.41 and switch low when the sine wave gets below -0.14

 

Can anyone help. 


Ive attached my current VI to this message.

 

Thansk 

0 Kudos
Message 1 of 8
(4,605 Views)

Hi JW,

 

so you want a switch with a hysteresis?

I would use one with a switch point at +0.135 and a hysteresis of ±0.275: switching to HI at (switch point + hysteresis) and going LO at (switchpoint - hysteresis)…

Best regards,
GerdW


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

Use a shift register to maintain which value should be output of the loop.  When the value goes above 0,41, change that value to 1.  When it is less than -.14 change it to zero.  When it is in between, output whatever value of 0 or 1 is still in the shift register from the previous iteration

0 Kudos
Message 3 of 8
(4,591 Views)

How do i do this can you explain

0 Kudos
Message 4 of 8
(4,587 Views)

can you show me how to do this.

 

Thanks 

0 Kudos
Message 5 of 8
(4,585 Views)

@JWinstanley wrote:

How do i do this can you explain


Yes.  But it is better if you try for yourself.  It is a a shift register and a couple select statements.

 

I'll give you the start and you can figure out how to put in the 2nd part.

0 Kudos
Message 6 of 8
(4,575 Views)

A ranged case structure could work as well.  Not quite as flexible, but can be simpler to understand.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(4,546 Views)

OK, your question can be summarized as follows:

  • If Input >0.41, output = Hi
  • If Input <-0.14, output = Lo
  • Otherwise, output = former output.

The key concept here is the third step, having the next output be the same as the previous output if the input is somewhere in the middle.  Do you know about While Loops in their "Do Once" mode with Shift Registers (sometimes called a "Memory")?  If you configure one such thing, you can put two Case Statements inside it to handle the "forced Hi" and "forced Lo" conditions, with the "otherwise" being the former output living on the Shift Register.

 

If none of this makes any sense to you, spend some time with the LabVIEW Tutorials (look in the upper right corner of the LabVIEW Forum Home Page).

 

Bob Schor

0 Kudos
Message 8 of 8
(4,520 Views)