06-04-2018 05:14 AM
Hi,
I have been trying to create a simple program which would allow me to switch between different interfaces ( each of which would generate a different wave: sin, PWL, ramp etc.)
I also have a button to clear the wave if needed.
However, on switching between wave cases, the previous wave created is retained. How would I clear this?
I don't want to clear on multiple additions of the same wave, but only when adding a new wave type would I want to clear.
Thanks
Solved! Go to Solution.
06-04-2018 06:10 AM - edited 06-04-2018 06:12 AM
I forgot to attach the VI, I am attaching it here.
All the waves are for the time being set as a sin wave until I figure this problem out.
06-04-2018 06:39 AM
Use a Feedback Node to compare the previous wave type to the current. If they are different, you clear the history.
06-04-2018 11:09 AM
Here's what I hope is an instructive Exercise for you -- attach a numeric indicator to the Index of your While Loop and run your program. Do you notice that almost all the time, LabVIEW is "very busy doing nothing"? The only time the counter slows down is when you do "Add Waveform" and it needs to do some calculation. That's a sure sign you are "doing something wrong".
Here's a suggestion about how to start thinking about fixing it. Open LabVIEW, click File, "New ..." (the three dots are important!), find From Template, Frameworks, Design Patterns, and choose Producer/Consumer Design Pattern (Events). Let it build, then study this design. I think this is what you want -- when you push a button, you want to "do something", and otherwise, you want to simply "wait" (or do nothing). You might even be able to do (almost) everything in the Event Loop, alone.
Do you know about Event Loops? If not, they are sure to be discussed in one of the early LabVIEW Tutorials (or you can Google "LabVIEW Event Loops" ...).
Bob Schor
06-05-2018 02:33 AM - edited 06-05-2018 02:40 AM
wrote:
Hi,
I have been trying to create a simple program which would allow me to switch between different interfaces ( each of which would generate a different wave: sin, PWL, ramp etc.)
I also have a button to clear the wave if needed.
However, on switching between wave cases, the previous wave created is retained. How would I clear this?
I don't want to clear on multiple additions of the same wave, but only when adding a new wave type would I want to clear.
Thanks
Hi mrtea,
The way you have coded clearly states you are beginner in LabVIEW, i would like to suggest few modifications to you code and not going to comment anything on architecture.
1. When ever you use a while loop place the timer commonly in loop instead of adding timer in every case. when you place it inside the case structure the loop runs independently at a higher rate and whenever the particular case structure is called the loop slows down a bit. This is what been said by @Bob_Schor as below
Here's what I hope is an instructive Exercise for you -- attach a numeric indicator to the Index of your While Loop and run your program. Do you notice that almost all the time, LabVIEW is "very busy doing nothing"? The only time the counter slows down is when you do "Add Waveform" and it needs to do some calculation. That's a sure sign you are "doing something wrong".
Making this change will also make clear chart case to work properly.
However since your title states state machine i would suggest you to learn the architecture better and also use event structures to perform the kind of actions easily. Also Place a control in While loop's stop terminal instead of a constant "F" it means you cannot stop your code while running the only option is to "ABORT" it .Hope you know Stop and abort are not same.
Hope this helps
Kudos are welcome
06-08-2018 06:01 AM
Finally had a chance to come back to this.
Here is an update.
The while loops only increment now when 'Add Waveform' is pressed.
Is the issue of the loop spending a lot of time doing nothing still there as a result?
XY Graph for looking at the immediate grpah you have produced.
The other two are for seeing all the wave-forms added together.
(is there a way to add it to the end rather than the start as it is doing currently?)
Eventually, I will need to include:
- a feature to reject some waveforms after analysing them in the XY Graph and not add it to the larger waveforms seen in Waveform Graph 3 and Waveform Graph.
- a feature to clear all waveforms
Hopefully the above makes sense.
Larger question is can you guys see any issues that I've not spotted yet?
Thanks.
P.S ignore the commented out code and I haven't had a chance yet to put the X axis on to the other two graphs.
06-08-2018 06:40 AM
1. Get in the habit of putting your buttons' terminals in their respective event case. This will make it easier to find said case (double click on the button and it jumps to the terminal, which is conveniently hiding in its event case) as well as handle the latching mechanism.
2. Since you are only adding to the XY Graph in the Add Waveform case, put all of that code into that event case.
3. Same as 2 except for the array going into the shift register. Only add to it in the event case. Have all the other cases wire straight through. There is a nice feature called "Linked Tunnels" to make this easier for you. This will also fix the unneeded Feedback Node you have in there.
2 and 3 will also make things A LOT easier for you to add in your two new features.
Attached is a partially cleaned up VI.
06-11-2018 07:54 AM
I see, thank you very much.