LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Output Arrays Question (Labview Core 2 Excercise 6-1)

Solved!
Go to solution

Hello!
I'm going through the labview core 2 training and was given a very simple problem to work on but I'm having trouble figuring out how to approach it.  I realize it's probably very simple but I want to make sure I understand how to best deal with it. 

 

I'm given some chaotic code that takes a 1 dimensional array, places the positive values into a "positive array" and the negative values into a "negative array".  I'm asked to refactor the code, so it's pretty straight forward. 

 

The issue I'm having is with the implementation on how to only output values into a given array if it's positive or negative.  I tried using a select statement but that only allows me to choose between two different values for a single output path (rather than a selected output for different paths).  Realistically, I need to make some sort of logic multiplexer (if I understand correctly). 

 

The other approach I've taken is using a case statement, testing if it's positive or negative and outputting the value into the necessary array within the case statement but it gives me a conversion error when I try and place a single element and force it into an array output (maybe I need some sort of array conversion or I need to apend an existing array and update it again). 

 

It's possible my thinking is all wrong but I've tried a few different approaches and none of them seem to have panned out.  I'm guessing there's a simple solution but I'm having trouble finding it.  Unfortunately, I've been taking the courses when I can over the past few months but that's a lot of time to forget things in between . . .

 

Any suggestions as to how to approach this problem, what blocks to work with, etc would be greatly appreciated.  Obviously, none of this is for a grade, I'm not looking for someone to "do it for me" but I'd like to understand the right approach for this so I can get better at it. 

 

Sorry for all the typing.  If you need me to upload screenshots, let me know.  Thanks!

0 Kudos
Message 1 of 7
(3,133 Views)

What happens if the value is zero?

 

Anyway, have you tried using this guy?

greater then zero.png

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(3,122 Views)

Yes, I have.  I used a less than zero and a greater than or equal to 0 (so zero is considered a positive in this case) but both of those provide logical outputs that I need to turn into an actual output.  For this, I used a select statement  to potentially output to the desired database.  This gives me two different issues:

 

1) A conversion issue which has me trying to convert an element into an array (might be able to get around that using some sort of array appending or something to that effect)

2)  A requirement to give an output to both arrays every element, which potentially gives me junk data going to the opposite array.  For instance, if I have a value of -1, it's found to be less than zero so in that check, it will pass the value to the desired array.  On the check for the positive side though, I believe I have to have an element hooked up to both sides of the select statement so I have to send something to the positive array, which I don't want to do. 

 

Maybe I'm missing something really obvious though.  Thanks for the quick response!

0 Kudos
Message 3 of 7
(3,118 Views)

Attach your VI so we can see what you are actually doing rather than guessing at what you say you are doing.

0 Kudos
Message 4 of 7
(3,087 Views)
Solution
Accepted by topic author JBrookley

Have you tried to use conditional output tunnels? 

 

I will bet you dollars to doughnuts they can help 


"Should be" isn't "Is" -Jay
Message 5 of 7
(3,083 Views)

Heh, as soon as I started typing, I realized I might as well just have uploaded it (unfortunately, I've tried about 40 different approaches trying to make it work so I don't have the history of everything I've tried).  Anyway, I'm attaching the VI I'm working on.  As I mentioned above, the issue with my approach is that if I leave the false cases empty, I get an error for leaving a floating node.  I'm not sure if there's a "NULL" value that won't send anything.  I currently have it set to send a 0, which obviously won't work. 

 

I'm attaching the original that I'm supposed to "refactor".  Let me know if you guys have any suggestions.  Thanks a lot!

Download All
0 Kudos
Message 6 of 7
(3,044 Views)

Jeff, I just googled conditional output tunnels and that was EXACTLY what I was looking for.  Got it sorted out.  Thanks a lot!

Message 7 of 7
(3,043 Views)