LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implement same logic as old VI into new VI

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!

Download All
0 Kudos
Message 1 of 6
(278 Views)

@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:

  • You have missing values, for example if the tap voltage is 50.5, you fall into a black hole.
  • 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.

0 Kudos
Message 2 of 6
(232 Views)

Here's ow the old VI could be simplified. You ca use some of the ideas for the new VI too. 😄

 

altenbach_0-1642525960030.png

 

0 Kudos
Message 3 of 6
(224 Views)

Here's one possible solution:

 

altenbach_0-1642527855409.png

 

 

 

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.

 

Message 4 of 6
(210 Views)

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.


 

0 Kudos
Message 5 of 6
(207 Views)

Thanks for the examples! I appreciate it!

 

 

 

0 Kudos
Message 6 of 6
(204 Views)