01-18-2022 09:31 AM
Hello,
Please see the attached VIs. I'm trying to create a new VI that automates the selection of the required input voltage and current level. The old VI required the user to manually select the ranges.
New VI = VIT Config.vi
Old VI = Inst Inc VIT Config.vi
Disclaimer: my mastery of the use of arrays is a work in progress.
I appreciate the feedback!
01-18-2022 10:58 AM
@JayWW wrote:
Disclaimer: my mastery of the use of arrays is a work in progress.
I recommend some of the training resources listed at the top of the forum.
Some initial obervations:
Do you have a truth table of the outputs you want based on input. we cannot really tell, because your code makes no sense, as already stated.
01-18-2022 11:13 AM
Here's ow the old VI could be simplified. You ca use some of the ideas for the new VI too. 😄
01-18-2022 11:38 AM - edited 01-18-2022 11:50 AM
Here's one possible solution:
You might need some extra code after deciding what should happen if the inputs are e.g. negative or if the input exactly hits a range boundary.
01-18-2022 11:46 AM
Hi altenbach,
Thanks for the feedback! I'm working my way through the online training as I work on projects. The "truth table" would be found in the old VI. I need to replicate the output of the old VI in the new VI.
I'm not sure how I would create an array that functions as a lookup table to supply an index. Where can I find more info on this?
I'm also unclear on how I could create a single case structure for each input. Would I somehow associate a string constant to each range? Or would this only work with the array that functions as a lookup table for indexes?
Thanks
- All you need is one case structure for each input.
- Your cases differ by a single constant, the rest of the code can be shared.
- You could just use a boolean array constant instead of all that song and dance starting with a numeric.
- If you pick the correct representation for your numerics, there is no need to change to U8 later.
- If you use "built array" in concatenate mode, you would not need to reshape later.
- reshaping to an array with one element is the same as taking the first element.
- reshaping the array with two elements again, ends up with an array of size=1, no matter what, so all earlier calculations are mostly lost.
- To check ranges, one would typically threshold into an array of limits to get an index.
- ...
Do you have a truth table of the outputs you want based on input. we cannot really tell, because your code makes no sense, as already stated.
01-18-2022 11:48 AM
Thanks for the examples! I appreciate it!