LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure numeric control with exclusive range of values

I am trying to setup a VI that compares measured differential pressure (p_d) with a setpoint (p_s) within a given tolerance (tol), so I am using a case structure to set up the following three cases:

 

Case 1: p_d > p_s + tol

Case 2: p_d < p_s - tol

Case 3: p_s - tol p_d p_s + tol

 

Because I'm using a subtraction operator to get the difference between the measured and setpoint pressures, the case structure will instead include the following cases:

 

Case 1: p_d - p_s > tol

Case 2: p_d - p_s < -tol

Case 3: -tol p_d - p_s tol

 

For Case 3 (let's say tol = 10), I know it will be specified as "-10..10" since it's an inclusive range, but I don't know how to handle an exclusive range for Cases 1 and 2. Can someone please enlighten me on how to accomplish this? It would be much appreciated!

 

0 Kudos
Message 1 of 5
(3,330 Views)

Hi Michael,

 

there are several options available...

1. You can use InRangeAndCoerce to detect a value within your tolerance band and use its output to drive an outer case structure. In case you're out of tolerance you need one more comparison to drive an inner case structure in the false case of the outer one...

2. You can do your three comparisons (well, you need only two of them) and create a boolean array of the results. Then convert that array to a number and use this number for your case selector...

3. You could build an array of (-inf, -tol, +tolerance, +inf) and use the ThresholdArray function to find the current case...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,308 Views)

Hi GerdW,

 

Thank you for the reply! I've attached the VI to give a clearer picture. To give more context, the output of the case structure is linked to a motor. If the difference between the setpoint and measured pressures is less than the tolerance, the motor should remain stationary. If the setpoint pressure is below the measured pressure, the motor should rotate counterclockwise. If the setpoint pressure is above the measured pressure, the motor should rotate clockwise. Eventually, we will add more cases to rotate the motor at different rates depending on how far off the pressures are from each other.

 

Given this information, which of the methods you mentioned would you recommend using?

 

 

 

0 Kudos
Message 3 of 5
(3,296 Views)

I think you're trying way too hard to use exactly one numeric case structure.  It should be noted that you can only reliably use integers with those and you're trying to put floating point numbers in there, so it's not going to work properly as-is.  You can kind of tell because your orange wires get wired into a blue case selector with a red coercion dot on it.

 

Your choices are:

1. Switch to boolean logic and have 2 case structures, one nested inside one case of the other.

2. Use the threshold method, which is somewhat nice and clean from a coding standpoint because it gives you just one case structure but is a bit obfuscated as to its purpose

3. Use a string or enum to define your case names and then make a single structure with those as your options, and do some logic to pick which of those cases you want.

0 Kudos
Message 4 of 5
(3,288 Views)

Using the Threshold 1D Array will be the simplest route to go.


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 5 of 5
(3,268 Views)