LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mutliple if conditions with anologue inputs

Solved!
Go to solution

hi everyone

 

we (my group) are totaly new to labview but we have to use it for a project and i was wondering if you guys can point us in the right direction.

 

we need to make an if condition that does something similar to the following:

 

if (output 1 from circuit) >= a and <= b then ans1=1

if (output 1 from circuit) >= c and <= d then ans1=2

if (output 1 from circuit) >= e and <= f then ans1=3

if (output 1 from circuit) >= g and <= h then ans1=4

this goes on up to ans = 8

 

if (output 2 from circuit) >= i and <= j then ans2=1

if (output 2 from circuit) >= k and <= l then ans2=2

if (output 2 from circuit) >= m and <= n then ans2=3

if (output 2 from circuit) >= o and <= p then ans2=4

this again goes on up to ans = 8

 

we will need this for four outputs like this where the a,b,c etc values will most likley be non interger values.

 

once we have the four outputs and what band they lie in we need to put them together like:

 

if ans1=1 and ans2=1 and ans3=1 and ans4=1 then display "this is a 1p"

if ans1=2 and ans2=2 and ans3=2 and ans4=2 then display "this is a 2p"

if ans1=3 and ans2=3 and ans3=3 and ans4=3 then display "this is a 5p"

once again this will go on up to ans=8 aswell

 

i know there is alot of data and it will be complex because the inputs are from a hardware circuit. we dont have loads of time to learn everything so i was wondering if anyone can point us in the correct direction. i have came across using case structure on this forum when i was trying to look for answers but i really dont know much about them and it they will work for what we would like.

 

i am not asking anyone to do this for us but any help would be great.

 

sorry if this is not in the correct section

 

thanks

adam

 

p.s apologies for all the reading

0 Kudos
Message 1 of 8
(3,248 Views)

Check this out.

You can set up a case structure (which has the functionality of an 'if' statement more or less)

to run a certain set of code in a range of values.

 

 

I attached a very simple example of how to implement this.

See if you can figure out what is going on in the block diagram.

Message Edited by Cory K on 03-12-2009 11:49 AM
Cory K
0 Kudos
Message 2 of 8
(3,245 Views)

This won't work.  The original poster said they might have non-integers as part of the ranges.

 

Question.  The ranges are listed as a..b,  c ..d,  e..f,  ....  What if there is a gap between b and c the value could fall into?  Then what?

 

This handles the first part of the question.  It shouldn't be hard to figure out the second part.

Message Edited by Ravens Fan on 03-12-2009 01:14 PM
0 Kudos
Message 3 of 8
(3,228 Views)

thanks i think that link will help us a lot

 

yeah i did read that it will not work with intger vaules somewhere.

 

i am not sure at the moment what the difference between the a,b,c values are yet but i would imagine that they will have to be less than one but not as much as say 4 decimal places. i did read about multiplying them by 100 etc forehand so that they are integers.

0 Kudos
Message 4 of 8
(3,220 Views)
Solution
Accepted by adamkse

Check RangesAdam

 

Here is a sample to handle your logic - if I understood it correctly.

Message Edited by VADave on 03-12-2009 12:24 PM
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
Download All
0 Kudos
Message 5 of 8
(3,209 Views)

In range and coerce!  Definitely a better choice.

 

By the way, it isn't necessary to put them in a For loop.  In range and coerce is polymorphic and will take arrays for its max and min.

Message Edited by Ravens Fan on 03-12-2009 01:32 PM
Message 6 of 8
(3,206 Views)

wow i did not expect so much help this quite

 

thanks so much guys, it looks pretty close to what we want to do. i do not have labview here at home but i will try this out as soon as i get a chance.

 

thanks again

 

adam

0 Kudos
Message 7 of 8
(3,188 Views)

i was playing with labview again yesterday and i think we are on the right track now.

VADave you circuit is very close to what we want to do so than you very much

 

also thanks to everyone who helped us.

 

if i get stuck on labview again know where to come 🙂

0 Kudos
Message 8 of 8
(3,151 Views)