07-19-2018 01:54 PM
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!
07-19-2018 03:10 PM
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...
07-19-2018 03:55 PM
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?
07-19-2018 05:31 PM
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.
07-20-2018 06:01 AM - edited 07-20-2018 06:02 AM
Using the Threshold 1D Array will be the simplest route to go.