LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean control in array of cluster does not bound back

Solved!
Go to solution

Hi,

I am building the front panel to control multiple DC servo controller. Since I want to build it scalable, I create a cluster to control one controller and put it in an array as in Front panel picture. The issue is after click any boolean control, these boolean controls do not pound back does not matter what type of mechanical I set. As I understand because the program the not read the value directly from these control. Please let me know what is the right solution for this? I tried to set the value back to false but it does not work either as in the block diagram image.

 

Thank you in advance.

Download All
0 Kudos
Message 1 of 13
(3,500 Views)

You should not be able to set any mechanical action for booleans inside an array, and since you use local variables of that cluster elsewhere, latch actions are not allowed, even for scalar cluster elements.

 

(In the event, it would be sufficient to search for TRUE inside the loop and use a conditional terminal to terminate if one is found. The found index will give you the button and the loop iteration terminal will give you the element of the cluster array. Seems much simpler (no reshape, no Q&R, etc.))

 

In order for us to troubleshoot why it does not reset by the code in the lower loop, we probably would need to see some actual code. What's the datatype of the "x axis" enum constant? You turn a I32 into a variant, but then convert it to an enum instead. Does the INFO subVI do anything to the string?

0 Kudos
Message 3 of 13
(3,473 Views)

@Altenbach: The "x axis" just is an enum. As you see in front panel, I have an array of 2 clusters. I use an enum {Axis x, Axis y} to index one of these 2 clusters. The "Info" vi just log the case will run.

Initial the default value did the trick for me. I apply for Move Relative, Move Absolute, Update Move, Update Jog. But there is one weird thing is I don't have to do anything for  the back green button and forward green button. They just work normally.

 

 

0 Kudos
Message 4 of 13
(3,464 Views)

Thanks @gregoryj. Using Initial the default value did the trick for me.

0 Kudos
Message 5 of 13
(3,463 Views)

@NTT wrote:

@Altenbach: The "x axis" just is an enum. As you see in front panel, I have an array of 2 clusters. I use an enum {Axis x, Axis y} to index one of these 2 clusters.

 


An enum is unsigned (and by default U16). You need to be very careful when turning a I32 numeric into a variant and then try to interpret the variant as an enum. Just saying. It's not clean code.

 


@NTT wrote:

Initial the default value did the trick for me. 


Property nodes are orders of magnitude more expensive and there is no reason to use them here. Your original code should work just fine. I am sure there is a bug somewhere, you just need to find it. 😄 Why don't you put the controller terminal in the lower loop so you don't need to read from the local?

 

Anyway, here's a better way to find the changed boolean.... See if it can give you some ideas.

 

 

Message 6 of 13
(3,454 Views)

@Altenbach: What you suggested definitely improves my code. I updated my code as your suggested.

Regarding the part I did not put the controller in the second loop because depending on what boolean press, the software will access the correspondent input in the cluster to implement the task. For example use move distance for move absolute or move relative. Or update the move velocity profile. The controller will be accessed in many case so there is no reason for me to put it in one specific case. 

0 Kudos
Message 7 of 13
(3,431 Views)

@NTT wrote:

Regarding the part I did not put the controller in the second loop because depending on what boolean press, the software will access the correspondent input in the cluster to implement the task. 


Yes, but everything in the array of clusters is also available from the NewVal event data node, of course. It's all right there, terminal or not. 🙂

 

(Hard to give solid advice by just looking at truncated images, but in your current code the terminal is not even connected to anything, thus my suggestion ;))

Message 8 of 13
(3,418 Views)

@altenbach: you are the first one try to help me improving my code 😄 Thanks a lot. Please look at my updated code.

I changed boolean's machenical action to "Switch until release" then I don't have to initialize to default value anymore.

0 Kudos
Message 9 of 13
(3,404 Views)

Be careful with what mechanical action you choose and make sure it fits your needs.

 

Switch until Released behaves like a doorbell button.  It does something while its pressed, and immediately bounces back and goes to the false case when you let go.  If you read the terminal in code, it may or may not detect the button press if you press and let go before the terminal is read.  Using the event structure will detect it was pressed, but it will also generate an event when you let go.  So it actually generates TWO events, which you may or may not want.

 

Switch When Released is the one that will turn True when you release from pressing it, and turn False when you release from pressing it again.  Thing of it behaving like a single button power supply that stays clicked down on first press and releases on the next press.  Of course it would also generate two events, one on the first press and one on the second press.  But between the presses, it will remain true.  This would allow you to make sure the terminal is read, but also programmatically wire a false to it to cause it to jump back up without firing a second event, thus effectively behaving more like a Latch Action on a boolean.

 

I find "Switch Until Released" is much less commonly used.  I want to make sure you know the difference between the two and make sure you select the one that works best with the way you code your program.

Message 10 of 13
(3,394 Views)