LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change tunnel mode

Solved!
Go to solution
Solution
Accepted by topic author rhupd

Here I modified it to do what you want.

0 Kudos
Message 11 of 29
(1,255 Views)
Solution
Accepted by topic author rhupd

I guess I was lateSmiley Very Happy

NEW.png

I also took the NaN route but the case structure seemed silly

 

I think the OP should explain back to us WHY NaN's don't plot.

Spoiler
They a Not A Number. 

 

Bill, You missed the Plot visability checkbox Smiley Wink


"Should be" isn't "Is" -Jay
Message 12 of 29
(1,247 Views)

@JÞB wrote:

 

Bill, You missed the Plot visibility checkbox Smiley Wink



That's a relatively new feature that I don't even remember it exists.

0 Kudos
Message 13 of 29
(1,239 Views)

Thank you RavensFan and Jeff!  I was almost there but I couldn't figure out how to make the signal disappear when the button is unclicked.  A google search revealed that NaN means 'not a number' so if the condition is false, I don't want to display 0 becuase that would be a straight line, I want to display NaN which is nothing!  

 

Just out of curiousity, why is it silly to use a case structure and would it be bad practice if I didn't use the select function and kept the = condition that I previously had?  It's working now but I kinda kept my old structure.

Why does 'waveform chart' show big waves while 'all 3 signals together' shows the entire signal?

0 Kudos
Message 14 of 29
(1,236 Views)

Equal to True is just plain silly no matter whether you use the Select function or a case structure.  (Check the Rube Goldberg thread.)   If you feed in a True and compare to true, what do you get?  A true.  Feed in a False and =True, you get a False.  The =T part is just pointless.  Remove the equals and the True constant in your code and you will see the exact same results.

 

The reason I big Select rather than Case Structure.  I use a case structure when there are things that need to or cannot execute depending on the condition.  Or if there is more than one output that depends on the condition.  When there is a simple Either/Or like we have here, then Select is simple enough to use and you see both possibilities at once without one being hidden.

0 Kudos
Message 15 of 29
(1,226 Views)

Just out of curiousity, why is it silly to use a case structure and would it be bad practice if I didn't use the select function and kept the = condition that I previously had?  It's working now but I kinda kept my old structure.

Why does 'waveform chart' show big waves while 'all 3 signals together' shows the entire signal?



Mostly do to readability.  Let LabVIEW work with the arrays directly whenever possible.  You'll find things to be a lot easier that way.

 

The DDT does weird things.  That's why we tell you to avoid using it.

 

Do you also notice that you are throwing away 99 samples from your simulations with each iteration?  You get getting 100 samples, but by changing to a scaler, you are throwing a lot of data away.


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 16 of 29
(1,225 Views)

@RavensFan - I read the thread about Rube Goldberg code and I now understand why the equal to true is silly.  I also see why we don't need to use a case structure.

 

@crossrulz - what do you mean I'm throwing away 99 samples and where am I changing the data to scalar?  That was mentioned earlier as well but I don't see where that happens and does it affect the data being displayed?

0 Kudos
Message 17 of 29
(1,215 Views)

If a boolean value is equal to TRUE it IS TRUE.

 

The constant and comparision is Tautologic and hence clutters the code with unneeded operations  Just wire the boolean to the case structure selector.

 

Boolen drive case structures with no sub-vis inside either case are USUALLY replaceable with a "Select" primitive.  This is one of those cases.  The select primitive permits all the code to be on one sub diagram "Cases hide code"  Hidden code is less preferable to a valid alternative.  Although it could be said the a select function could always be replaced by a boolean driven case, and therefore needlessly "Bloats" the language it has many advantages.  When you really start using the language you'll learn about test case coverage how its metrics are calculated and realize you have better (arguably more acurate) metrics for code coverage using the select function where approprate.

 

I found the case structure silly because all three non-default cases essentially did the same thing to data of the same type.  That screams for an auto-indexed for loop and "Code it once" its much easier to maintainSmiley Wink

 

CAUTION: While the set-up you have know results in arrays of equal size you might lose data if the number of samples from each simulate signal is not the same.  You would need some additional code to "Square up the data" before building it into a 2D array  (The help file and tutorials will explain why)

 

EDIT: throwing away 99%  Look at the snipett I attached (Drag it to your desktop then drag to to an empty block diagram POOF code!)

 

The "to dbl" conversion of the DDT only returns the first scalar value without even warning you it did so! (DDTs are evil!)  my example shws the correct conversion with the "From DDT express vi"


"Should be" isn't "Is" -Jay
0 Kudos
Message 18 of 29
(1,207 Views)

rhupd wrote:

@crossrulz - what do you mean I'm throwing away 99 samples and where am I changing the data to scalar?  That was mentioned earlier as well but I don't see where that happens and does it affect the data being displayed?


You simulation Express VI is setup to output 100 samples.  Then you use the From Dynamic Data to change the value into a scaler.  That conversion right there is where you are throwing away 99 samples.


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 19 of 29
(1,206 Views)

@JÞB wrote:

Bill, You missed the Plot visability checkbox Smiley Wink


Also, what would happen if you would replace the array of 3 NaNs with a scalar NaN? 😄

 

(A scalar NaN would make the code much more maintainable. Currently, if he would add another signal, a seemingly unrelated change would need to be done in the lower left corner...)

0 Kudos
Message 20 of 29
(1,202 Views)