03-13-2011 10:30 PM
I want to specify 3 ranges as the case selectors. For example, I am measuring mV, and I want 0..10, 10..20, and 20..30, but, when I enter them this way, I get an error that says the selector values are not unique.
I want case one to respond when the input is greater than 0 but less than 10.
I want the second case to respond when the input is greater than 10 but less than 20.
I want the third case to respond when the input is greater than 20 but less than 30.
And, there is the default case, 0. Does the case structure think that my default is overlapping with my case one? How does one correctly list these ranges in the case structure selector label to avoid the error??
Also, I wired my voltage to "TO LONG INTEGER" and then to the case structure terminal to convert to integer for the case structure input (blue wires). Is that the right thing to do, since my voltage values will certainly be decimal numbers, not integers.
Solved! Go to Solution.
03-13-2011 10:39 PM
The proper settings would be
0
1 to 9
10 to 19
20 to 29 and so on so that each values are unique.
Now since the data will be double, converting them to i32 will take of all the decimal and the logic will work with your code since it will go to respective cases in the case structure..
Guru
03-14-2011 01:17 AM
Before converting to I32, use e.g. "round to +inf" and adjust the cases accordingly.
(A plain to_I32 will round to the nearest integer, making your boundaries impossible to meet.)
03-14-2011 10:32 AM
Hi, thanks a lot. That solved the problem, and now I see what I did wrong clearly. Can you explain one thing, though.
"Now since the data will be double" what do you mean about the data will be double?
Also, I noticed that when I run the vi with HIGHLIGHT EXECUTION on, it appears to be sending 2 voltage values at a time. Is that what you mean by double?
Thanks again,
David
03-14-2011 11:02 AM
@dav2010 wrote:
Can you explain one thing, though. "Now since the data will be double" what do you mean about the data will be double?
I think he meant that your data is DBL (double precision flaoting point) and thus not directly suitable for a case structure, which only handles integer values for numeric selectors..
I don't understand what you mean by the highlight execution comment. That makes no sense.
03-14-2011 11:11 AM
When I use HIGHLIGHT EXECUTION, and I watch the bubbles passing through the wires, I change the voltage at the beginning of the cycle, but, the previous voltage is displayed a second time before it reads the new voltage. That is what I mean about seeing each voltage twice.
03-15-2011 12:55 PM
Hi dav2010,
What are you using to read the voltages? It is possible that the VI is not reading as fast as the buffer is filling up so you are seeing what's left in the buffer before you changed the voltage.