06-24-2013 04:57 AM
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.
06-24-2013 06:00 AM
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.
06-24-2013 06:34 AM
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?
06-24-2013 06:44 AM
Something like this, you mean?
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.
06-24-2013 06:54 AM
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.
06-24-2013 07:36 AM
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.
06-24-2013 07:39 AM - edited 06-24-2013 07:54 AM
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?
06-24-2013 07:49 AM - edited 06-24-2013 07:51 AM
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.
06-24-2013 07:53 AM - edited 06-24-2013 07:55 AM
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
06-24-2013 07:55 AM
You missed the point: in the selected condition you would not set the voltage at all. See the following image.