05-03-2022 12:37 PM
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.
Solved! Go to Solution.
05-03-2022 12:46 PM - edited 05-03-2022 12:48 PM
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.
05-03-2022 01:00 PM
It should be a push button. I attach my VI. Thank you.
05-03-2022 01:13 PM - edited 05-03-2022 01:19 PM
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.
05-03-2022 01:28 PM
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
05-03-2022 01:33 PM
@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:
05-03-2022 01:53 PM
Now it works. Thank you so much!