03-12-2024 10:59 AM
Often times there is a requirement to either increase or decrease a command voltage to some device between two set points.
So i created a Sub VI which does the following - VoltIncDec.vi
- Based on the Start Volt and End Volt decides either to Inc or Dec
- Till the actual value reaches 90% of the end value, it ramps up fast and thereafter slowly. ( to avoid overshoot )
- Once it reaches end value it outputs a Boolean which the caller VI can use to branch off.
Now in the actual logic this SubVI will be called in many places asynchronously. So what execution should it be allotted with regard to re-entrancy. ( Tried reading the Help on this but must admit it wasn't quite clear )
The attached ParamIncDec.vi uses this subVI - VoltIncDec.vi
Thanks
Solved! Go to Solution.
03-12-2024 11:20 AM
This is the option which you're looking for, I guess:
03-12-2024 11:56 AM
When you say you looked at the help, did you look at this page or was it one of the others:
If you didn't see that one, that has a handy chart listing the two types of reentrancy compared to non-reentrant VIs.
If I had to summarize it would be that the "Preallocated" option is better for any VI needing simultaneous calls except when it comes to memory usage. If there's a chance your VI could have high memory use (either because you call it in dozens or hundreds of places, or because each instance of it is large either due to VI size or the VI holds large arrays of data) then consider "Shared" instead..
03-12-2024 02:43 PM
@MogaRaghu wrote:
Often times there is a requirement to either increase or decrease a command voltage to some device between two set points.
So i created a Sub VI which does the following - VoltIncDec.vi
- Based on the Start Volt and End Volt decides either to Inc or Dec
- Till the actual value reaches 90% of the end value, it ramps up fast and thereafter slowly. ( to avoid overshoot )
- Once it reaches end value it outputs a Boolean which the caller VI can use to branch off.
Did you even test your subVI? Since by default it goes from 5V to 2V and 0.9x2V is less than 2V, it will undershoot (or overshoot the target).
It seems exceedingly complicated. Here's a simple replacement that will slow down if it is within 0.5V of the end, no matter the direction.
All you probably need is the following. And yes, set it to reentrant (not done yet):
(Yes, this is just a quick draft. It can probably be simplified)
.
03-12-2024 11:28 PM
@altenbach
Maybe its not as simple as you suggested but it does it job OK. In the case no 2 , it finally handles the marginal overshoot or undershoot by feeding in the required end point.
Will check out yours.
Thanks for the time to put together the snippet.
03-12-2024 11:30 PM
Thanks to all those who responded.
And also pointing to the correct help document to refer to !!
03-13-2024 12:52 AM
@MogaRaghu wrote:
In the case no 2 , it finally handles the marginal overshoot or undershoot by feeding in the required end point
Mine ends exactly at the endpoint and avoids any over- or under-shoot. Nothing marginal ever.. 🙂
03-13-2024 10:58 AM
Here's a quick test bench. It always helps to see the result graphically:
Of course there are other ways to do that, for example a (slightly modified) exponential filter would gradually approach the endpoint.