LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the case structure not reset itself on each cycle?

I have a voltage measurement (NI 9274) which is wired to two separate (>) and (<) both of which have the same constant.  So, if the voltage measured is <, then, it sends TRUE  to  case structure 1 and FALSE to the other.  If the voltage measured is >, then, it sends TRUE to case structure 2, and FALSE to the other.  In this way, only one case structure operates per one voltage measurement.  The case structures command NI 9211 digital output module.  The intention is for the measured voltage to be used to select one or the other case structure for the digital output.

 

When you change the input voltage, you should be able to see the appropriate case structure give the 9211 the command.  However, instead, the vi does NOT switch in between case structure outputs as you vary the input voltage.  Why not?

0 Kudos
Message 1 of 4
(3,072 Views)

THere are lots of things that are wrong with your code. First and foremost, DO NOT use mutually exclusive parallel case structures. This is a ridiculous code construct. Simply put the code from the TRUE case of one of the case structures into the FALSE case of the other and delete the one you moved the code from. In addition, your output from the compare is not a boolean which the case structure is expecting. It is a cluster that contains a name, a start time, a time stamp, an x and a y value. A Case structure requires either a boolean, a string or an integral value (ENUMs are integral values). You cannot wire a cluster or a floating point number to the case selector. So, in addition to eliminating one of your case structures by combining them you also need to change your comparison to compare only the single axis value (your voltage) with your constant and use that boolean result to select either the TRUE or FALSE case.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 4
(3,065 Views)

Thanks so much for your help. I understand about putting the two codes into the same case structure, but, what about when I have 3 or more cases? Is it OK to use parallel case structures in that case?

 

I am confused about one point you make.  You say that the output to the case structure is not boolean?  Is all that other data passing through the < to the case structure?  I thought it was boolean because the output from the < and > are boolean, returning TRUE or FALSE.

 

"cluster that contains a name, a start time, a time stamp, an x and a y value"...where is all this coming from?  How do you see that all those are going into my < and >?  Where can I see those, and eliminate the ones that I don't want?  I want only the voltage value, of course, in mV.

 

Thanks again for your help.

0 Kudos
Message 3 of 4
(3,058 Views)

I should have said the output of the compare. Sorry about that. There are better ways to handle selection than to use parallel case structures.

 

Here are a few examples of how you can make your selections.

Case Selection Methods.png

 

You can use the unbundle by name to retrieve the value that is your voltage and wire that to your comparison.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(3,051 Views)