From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-27-2021 07:41 AM
Hello everybody,
recently I took over an old labview project concerning the control of a hexapod.
The device accepts simple ASCII strings as commands for example for reading out the positions of the axes.
Because the previous VI was written by multiple persons and is rather old (read/write to xls doesn't work) anymore I have to maintain it.
Also I encountered some programming structures, which should be avoided like, in this case, (stacked) sequence structures.
I tried to change the sss to a for loop + arrays, as suggested in the forums, but I don't know if I did it the right way.
I attached a VI containing the former structure and my reprogramming attempt.
The attached (Sub)VI is meant to read the positions of the hexapod.
Could you please help me?!
Thank you in advance.
System: Win 10 21H1, 64bit
Labview: V2020SP1, 32 bit
05-27-2021 09:06 AM - edited 05-27-2021 09:07 AM
Well you certainly have your work cut out for you... Anyway you need to think "Data Flow" and remember that a VI can not even begin to run until all input conditions are met.
Probably the easiest way to force sequential execution it to use the error cluster, even if that means simply passing the error cluster through a sub-vi.
05-27-2021 10:01 AM - edited 06-10-2021 09:25 AM
Looks pretty good, but I think there are a few small bugs.
Here's how it could look like:
06-10-2021 09:15 AM - edited 06-10-2021 09:21 AM
Thank you altenbach!
I'll try to implement your suggestion.
Would it be still functional if put into a subVi?
I also did never work with in place element structures before; could you please explain how it is used and why? The Labview help explain that it will increase memory efficiency.
If it doesn't work I'm going to try RTSLVU's advice.
Thank you again!
06-10-2021 09:30 AM
@th.st. wrote:
I also did never work with in place element structures before; could you please explain how it is used and why? The Labview help explain that it will increase memory efficiency.
We don't really care about efficiency in this case. Here the IPE structure is just a clean way to modify one element of an existing array.
You can do exactly the same by indexing out the element, modify it, then place it back into the original array using "replace array element". More primitives, more wires, more places for bugs to hide. No reason for that!
06-11-2021 03:29 AM
Thank you altenbach, that made it more clear to me!
While implementing the structure two additonal questions arised:
If I want to use only the first 6 elements of the array for further calculations the function "array subset" is used starting at index 0 and a length of 6 (elements)?
Also I wanted to ask, how to add separate labels to the elements of the array indicator on the front panel? Or is it recommended to add a separate label (by double click)?
06-11-2021 04:08 AM
Hi th,
@th.st. wrote:
If I want to use only the first 6 elements of the array for further calculations the function "array subset" is used starting at index 0 and a length of 6 (elements)?
To get a subset of an array you should use ArraySubset…
@th.st. wrote:
Also I wanted to ask, how to add separate labels to the elements of the array indicator on the front panel? Or is it recommended to add a separate label (by double click)?
In an array all elements share the same properties and only differ in value.
So you cannot label the elements differently in an array.
But you can:
06-11-2021 11:09 AM
Or you can put the data into a multicolumn list box or table for the UI. Yes, this creates some data copies since the tables are strings and your data is numeric. But a table is geared more to the UI of things and provides more properties for the UI.
06-22-2021 06:04 AM
Thank you GerdW and Mark_Yedinak!
These solutions sound great! I used a cluster of indicators; it seemed more easy to implement.
But also the multicolumn list box sounds very interesting! I will try it later.
I also encountered another issue: Since the mathscript nodes are not recommended any longer the vi will display a promt every time I start it.
The mathscript node is used to downsample measured values over q samples using a FIR filter:
y=resample_fir(x,h,1,q); input 2D array of dbl; h= array of size of the sample rate with 1/samples to read as entries; q=samples to read); y=resampled signal
Is it possible to use a filter vi instead?
The vi is working fine; only the prompt is annoying.
Thank you!
06-22-2021 06:50 AM
Hi th,
@th.st. wrote:
I also encountered another issue: Since the mathscript nodes are not recommended any longer the vi will display a promt every time I start it.
The vi is working fine; only the prompt is annoying.
Which prompt are you talking about?
Can you show a screenshot?
@th.st. wrote:
The mathscript node is used to downsample measured values over q samples using a FIR filter:
y=resample_fir(x,h,1,q); input 2D array of dbl; h= array of size of the sample rate with 1/samples to read as entries; q=samples to read); y=resampled signal
Is it possible to use a filter vi instead?
Yes, surely you can implement a decimation routine without using the MathScript node…