LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change a sine signal to square pushing a button

Solved!
Go to solution

Hi, 

I need to design a labview program in which pressing a button changes a sine wave to a square wave and pressing it again changes it back to a sine wave. I have tried using a shift register and it switches correctly to a square signal, but when I press the button again, it doesn't t return to the sine signal. How can I solve it? Thank you.

0 Kudos
Message 1 of 7
(894 Views)

What's the mechanical action of the switch and what is your code architecture? What's kept in the shift register?

 

We can only help if we see some code.

 

0 Kudos
Message 2 of 7
(888 Views)

It should be a push button. I attach my VI. Thank you.

0 Kudos
Message 3 of 7
(882 Views)

Well, you are pushing the square signal permanently into the shift register! Make sure you understand how that works.

 

Your button is switch action (i.e. a "switch", not a "push button"!), so all you probably need is the following. (make sure to add some timing to your loop or simulation) If you would use a latch action boolean, slightly more code is needed.

 

altenbach_0-1651601525089.png

 

0 Kudos
Message 4 of 7
(871 Views)

My problem is that I have to use a button, I can't use a switch. In my project I have to use a button on a board through the DAQ assistant. I am simulating how it would be without using the DAQ. 

 

I tried using the case structure in this way, but when I stopped pressing the button the signal reverted to sine. 

 

The signal should initially be sine and when the button is clicked, it will change to square. If the button is clicked again, it will return to sine. 

 

Thank you

0 Kudos
Message 5 of 7
(846 Views)
Solution
Accepted by topic author john_murphy

@john_murphy wrote:

I tried using the case structure in this way, but when I stopped pressing the button the signal reverted to sine. 


You must have change the mechanical action (e.g. to "switch while pressed"). In the VI you have attached, each click on the switch will toggle the boolean..

 

If you would use a latch action button (right-click...mechanical action...latch when released), you could use something similar to the following:

 

altenbach_0-1651602715846.png

 

Message 6 of 7
(842 Views)

Now it works. Thank you so much!

0 Kudos
Message 7 of 7
(834 Views)