LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reprogramm stacked sequence structure.

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

 

 

0 Kudos
Message 1 of 11
(1,186 Views)

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.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 11
(1,149 Views)

Looks pretty good, but I think there are a few small bugs.

 

  • Your string array is missing Q81. Once you add that, the Booleans depend on elements at indices 9 and 10. You only need one "index array" for the output string.
  • It is probably sufficient to operate on the numeric array, no need for all these strings. (except for debugging)
  • I would recommend to eliminate all these scalar indicators and use array indicators instead.

 

Here's how it could look like:

 

altenbach_0-1622127616519.png

 

Message 3 of 11
(1,126 Views)

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!

0 Kudos
Message 4 of 11
(1,035 Views)

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

0 Kudos
Message 5 of 11
(1,027 Views)

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)?

 

0 Kudos
Message 6 of 11
(990 Views)

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:

  • Place free labels on your frontpanel next to the array. This can get you into trouble when the program runs on a different computer using different scaling in the graphics settings…
  • Convert the array into a cluster: in a cluster each element can have its own label.
  • When you need to name the elements dynamically you can create an array of clusters, with each cluster containing a numeric element and a string: now you can display the values labelled with a random string.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 7 of 11
(984 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 11
(950 Views)

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!

0 Kudos
Message 9 of 11
(885 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 10 of 11
(879 Views)