LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Do nothing in a double case structure

Hi everyone,


I´m having a little issue that I cannot manage to solve, maybe one of you could be kind enough to provide some help.

As you can see on the joined picture, I´m using a double case structure and changing a voltage accordingly. What I would like is to keep the voltage unchanged in the False case of the internal one.

I saw two things: some developers suggested to implement a functionality that keeps the previous value for an unwired output but this hasn´t been implemented yet. Someone suggested using a shift register to keep the value unchanged. I´m new to this method and can´t seem to get a hold of it with my two cases program.

 

Thank you for your answers.

0 Kudos
Message 1 of 14
(4,374 Views)

The simplest method is to stick with the "do nothing" philosophy 🙂

Enclose the voltage setting vi in a case structure; the function should stay in the False case.

Wire a True constant out of the inner False case of your nested case structure; check the "use default if unwired" option for all the unwired tunnels.

As a result, the output value will be True for the "do nothing" case, False for all the other. Wire this value to the Voltage setting case structure input.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 14
(4,347 Views)

Thanks for your answer but I´m not sure I got what you´re saying. IF I measure something equal to 0,05, I need to change the voltage. But the rest of the time I´ll be in the other case, where I want to keep the same value. Both cases will occur and if I leave a use default if unwired, I´ll probably get zero as a voltage. Could you please send a print screen of your simple solution?

0 Kudos
Message 3 of 14
(4,333 Views)

Something like this, you mean?

 

select1.png

select2.png

 

Question: what happens to values that are 0.0499999999? Do you care about measurements that are equal to your setpoint plus some tolerance? If so, have a look at In Range and Coerce.

---
CLA
0 Kudos
Message 4 of 14
(4,323 Views)

Thanks for your amswer. The problem in your solution (maybe pincpanther´s one too) is that my case condition doesn´t concern the voltage I´m changing. At the entrance of the cases is a conductance measured somewhere before that is independent on the voltage I want to change.

 

About the tolerance, you´re right and I had a superior or equal condition before instead, maybe the equal will cause me trouble if the voltage is not dropping continuously as I would like it to do.

0 Kudos
Message 5 of 14
(4,316 Views)

That may be a little clearer for me.

 

So you're taking a measurement A and selecting an output B based on the value of measurement A.

 

If the current value of A is the same as the previous value of A, you don't want to change B? Or if the current value of A is greater than(or less than, whichever) a constant, you don't wish to change B from its previous value?

 

You can do this using shift registers to retain the value from the previous iteration. Here's a simple example of the second case: A is compared to the set point, and if it's less than the set point, the previous iteration's B value is used. If it's greater than or equal, a new set point is used. You can adapt this approach of using shift registers to retain the previous value for the capacitance, if that's what you meant instead.

 

selector3.png

selector4.png

---
CLA
0 Kudos
Message 6 of 14
(4,296 Views)

thoult escreveu:

That may be a little clearer for me.

 

So you're taking a measurement A and selecting an output B based on the value of measurement A.

 

If the current value of A is the same as the previous value of A, you don't want to change B? Or if the current value of A is greater than(or less than, whichever) a constant, you don't wish to change B from its previous value?

 

You can do this using shift registers to retain the value from the previous iteration. Here's a simple example of the second case: A is compared to the set point, and if it's less than the set point, the previous iteration's B value is used. If it's greater than or equal, a new set point is used. You can adapt this approach of using shift registers to retain the previous value for the capacitance, if that's what you meant instead.




Based on the snippet, wouldn't a select function be suitable for this situation?

I'm asking because I would do that in my first try. The result would be the same, right?

Mondoni
0 Kudos
Message 7 of 14
(4,292 Views)

It would if you only have one comparison and two output cases: if less than, do this, else do that.

 

If you have several comparisons and/or outputs, then you're probably best off using nested case structures.

---
CLA
0 Kudos
Message 8 of 14
(4,281 Views)

I don't want to hijack this thread; but I see the point. I knew that.
I asked because looking at the snippet, a select function would be completely okay.

BUT, I must add that I haven't seen the initial VI, so let me clarify that I was talking about your code, thoult 😄 (I will edit my previous post to quote yours and make this clearer).
Hope you understand me.

 

Regards

Mondoni
0 Kudos
Message 9 of 14
(4,276 Views)

You missed the point: in the selected condition you would not set the voltage at all. See the following image.

Immagine.PNG

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 10 of 14
(4,271 Views)