LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i modify a specific control in an array of clusters

Solved!
Go to solution

Hi,

 

so i have a generic subVI that does a job. it takes an array of clusters with 4 numeric inputs in each row and moves a platform as I wish.

The function, as it is built right now, also take a boolean input from a push button and execute only if the button is pushed.

 

Now all of that works great, however with time I've realized that an extra feature is required.

I'd like to have a second button 'Start Inverse' that multiply the X values of each row and only then sends it to my subVI.

 

How can I do it in a clever way?

I can always make another function that multiply the X value before each use and wire the second button to it, but that is just silly programming.

 

I attach a test VI as my original program is richer with components. The test VI does not work at the moment, it is just a structure, uploaded to give an idea for what I have in hand.

 

Thanks for the helpersarray_of_clusters.PNGarray_of_clusters_backend.PNG

0 Kudos
Message 1 of 13
(469 Views)

I'm not quite sure I understand your dilemma, but maybe it is related to having one "pure" button ("Start", that does "one thing") and one "mixed" button ("Start Inverse", that needs to ??temporarily?? change X and then "Start", without it being clear, to me, what happens with the X value after you push "Start Inverse").

 

Maybe you need two buttons, "Start" and "Direction" -- "Start" always "starts" the movement, and "Direction" always moves, say, in the +X direction if False, and in the -X direction if True.  This would not involve changing the Cluster at all, just negating its value when being read, depending on the setting of "Direction".

 

Bob Schor

0 Kudos
Message 2 of 13
(439 Views)
Solution
Accepted by topic author Aqua-

Is this what you're looking for?

xf.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 13
(422 Views)

@bob:

The scheme of the buttons isnt that concrete to me really. It can be 1 button or 2, as long as it function as a button and no as a drop down list (enum).

The function takes the inputs (x,y,vel,rep) and make a certain movment. Id like to have a button that changes the values of only 1 num control in each row in the array - the X value.

Lets say we use your idea of a direction button. When the direction is pointed to 'inverse' all X values should be changed to opposite sign values (multiply by -1) and the new array (the old one with the described modification) should be sent to the function "Move Rel".

 

@paul:

It seems to me that you understood what i meant and possibly showed me the way, but with no labels and VI i dont understand what you did there. Can you explain?

0 Kudos
Message 4 of 13
(392 Views)

@Aqua- wrote:

 

@paul:

It seems to me that you understood what i meant and possibly showed me the way, but with no labels and VI i dont understand what you did there. Can you explain?


In your cluster be sure that the controls/indicators HAVE UNIQUE Labels; if they have no labels then label them. Then use bundle/unbundle by name to access/change particular elements. Those functions are on the Cluster, Class, and Variant palette.

 

mcduff

0 Kudos
Message 5 of 13
(387 Views)

@Aqua- wrote:

@bob:

The scheme of the buttons isnt that concrete to me really. It can be 1 button or 2, as long as it function as a button and no as a drop down list (enum).

The function takes the inputs (x,y,vel,rep) and make a certain movment. Id like to have a button that changes the values of only 1 num control in each row in the array - the X value.

Lets say we use your idea of a direction button. When the direction is pointed to 'inverse' all X values should be changed to opposite sign values (multiply by -1) and the new array (the old one with the described modification) should be sent to the function "Move Rel".

 

@paul:

It seems to me that you understood what i meant and possibly showed me the way, but with no labels and VI i dont understand what you did there. Can you explain?


The cluster constant was created from your array of clusters.  "Bundle By Name" replaces the value of "X rel dist" with "X Factor".  The "Multiply" function multiplies every element of the array by the cluster coming out of "Bundle By Name".

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 13
(350 Views)

Hi paul, thanks for replying again.

i till dont understand what you did there.

you've created a constant cluster that simulate my cluster within the array and set each numeric constant to 1. why? what's the purpose of it?

then you connected the numeric control to the "bundle by name" and sent it to multiply the array.

i dont quite get the flow of the code, can you elaborate?

I do get that you are creating a factor cluster and, change the x value, then want to multiply each control of the factor cluster with the respective controller in the the original 'input cluster', however i dont get why the x factor is a controller rather than a constant (with a case structure -> direction=inverse -> -1 etc...

and finally i dont get how you multiply the output cluster with the array of clusters. in my code it shoots an error since i try to connect an array of clusters to a cluster

 

0 Kudos
Message 7 of 13
(314 Views)

@Aqua- wrote:

Hi paul, thanks for replying again.

i till dont understand what you did there.

you've created a constant cluster that simulate my cluster within the array and set each numeric constant to 1. why? what's the purpose of it?

then you connected the numeric control to the "bundle by name" and sent it to multiply the array.

i dont quite get the flow of the code, can you elaborate?

I do get that you are creating a factor cluster and, change the x value, then want to multiply each control of the factor cluster with the respective controller in the the original 'input cluster', however i dont get why the x factor is a controller rather than a constant (with a case structure -> direction=inverse -> -1 etc...

and finally i dont get how you multiply the output cluster with the array of clusters. in my code it shoots an error since i try to connect an array of clusters to a cluster

 


The values in the constant are set to 1 because, when multiplied, you don't want to alter "Y rel dist", "velocity", or "repetition",  The '1' for "X rel dist" is irrelevant because it gets replaced.

The "Bundle By Name" replaces the value of "X rel dist" with the value from the control "X Factor".  I made "X Factor" a control because I have no idea where you will be getting the factor.  Wire the "X rel dist" input of "Bundle By Name" to whatever you like.

When you multiply an array by a scalar, every element of the array is multiplied by the scalar.  If you're getting an error, it must be that you have a a type mismatch.  Hover your wiring tool over the broken wire to see the details.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 13
(292 Views)

Hi,

im almost sure i got it right, however i realized that a 3 state button is the best option to handle the data in terms of code and UI.

 

i have created a slider with 3 states - Inverse movement (as you told me), normal movement, and static.

I am quite sure it works properly (will test tomorrow), but now my problem is that it does not work like a button in the sense that it wont return to default state (static) after execution.

Any idea how to do it?

i tried the INVOKE NODE --> reinitialize to default option, but i cant quite understand how to use it.

I have checked the net and most of the solutions referring to reinitialize the entire vi.

with that solved i think we're done 😆

 

Thanks for helping

0 Kudos
Message 9 of 13
(256 Views)

Hi Aqua,

 


@Aqua- wrote:

i tried the INVOKE NODE --> reinitialize to default option, but i cant quite understand how to use it.

I have checked the net and most of the solutions referring to reinitialize the entire vi.


Write "static" into a local variable of that slider after processing the inverse/normal request…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 10 of 13
(247 Views)