02-05-2018 01:23 PM
I am using Labview 2014 but it shouldn't matter for my question.
I am using a Labjack to monitor 20 digital inputs. This is a common type of test setup for us.
Is there a better way to build these arrays to save space?
In the process of thinking about this question, the second pic occurred to me.
I haven't tested it yet, but thought there has to be a better way than what I have been doing.
Solved! Go to Solution.
02-05-2018 01:32 PM
For the first one, just wire out the iteration terminal directly, forget the shift register.
For the second one, use the "Initialize array" primitive to create a 20 length array with the same value.
02-05-2018 01:47 PM - edited 02-05-2018 01:53 PM
wrote:
For the first one, just wire out the iteration terminal directly, forget the shift register.
For the second one, use the "Initialize array" primitive to create a 20 length array with the same value.
And in both cases, remove the "build array" after the loop. Since both array are of the same size, a single FOR loop is all you need.
Depending on the desired representation of the blue array, insert a conversion bullet before the output tunnel.
02-05-2018 01:49 PM
Thank you. Exactly what I was looking for. I vaguely remember initialize array from class a couple of years ago!
I also found with my application I have to get rid of the build array. As it creates a 2d array and I need a 1d array.
02-05-2018 01:53 PM
wrote:
wrote:
For the first one, just wire out the iteration terminal directly, forget the shift register.
For the second one, use the "Initialize array" primitive to create a 20 length array with the same value.
And in both cases, remove the "build array" after the loop. Since both array are of the same size, a single FOR loop is all you need.
Amazing the how I can miss the Forrest for the trees.
02-05-2018 01:53 PM
Build both arrays in the same loop. Fewer functions on the BD.
02-05-2018 01:58 PM
Just wanted to point out that your shift register usage is probably not what you wanted (it'll produce an array with a single element). The answer above is good, but in the event that you want to save even more space, you can create a subvi for the top build array example. This is commonly called a range function such as in python (https://docs.python.org/3/library/functions.html#func-range). Matlab has someone likewise built in as a primitive (https://www.mathworks.com/help/matlab/ref/colon.html?searchHighlight=colon%20operator&s_tid=doc_srch...) as do many languages (especially vector heavy languages such as R). It's not clear to me that basic labview has this function built-in so it isn't a bad idea to build it yourself.
02-05-2018 02:01 PM
For building a sequence of numbers, you can use the Ramp Pattern function.
02-05-2018 04:09 PM
wrote:
For building a sequence of numbers, you can use the Ramp Pattern function.
Useful for creating orange ramps. Overkill for integers 😄