LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use a Button in a cluster to call a sub-vi

This should be simple but I can't figure it out.

I am writing a GUI program for a chip with a lot of control registers in it. The front panel displays the current register status and allows new values to be written to one register at a time. Each register is one to eight bytes long. I am using an array of clusters to hold the register name, the current register contents, the new data to be written and the address and size of each register. I also have a button that I want to call a sub-vi that helps enter the data to be written to the register. I have a program working with a register index control and "Enter Write Data" button external to the cluster. This is clumsy. I would prefer a button in the cluster that sends the register index to the sub-vi.

I wondered if a producer-consumer loop would do the trick but this function is a component of a master Producer/Consumer loop that includes power control, test point read-back and other functions. I believe nesting P/C loops is frowned upon.

The vi's are attached along with a screen shot of what I want to do. Any advice?

0 Kudos
Message 1 of 5
(2,855 Views)

Normally you monitor array of clusters Value change event, compare old and new values (or simply find true value) and figure out which button has been pressed.

 

 

In your case:

It is a bad idea to have indicator and control data in one cluster. You are typing in value, it reads new data, updates whole array and replaces what you typed with old data.

I usually separate settings (address, number of bits, etc), input and output data and user display.

So I would recommend:

Option 1)  2 arrays - settings (control) and indicator (data) with synchronized scrolls (Read/Set Index values property)

Option 2) double click opens simple window to enter Value to write and 2 buttons (OK, Cancel). You know where you clicked, convert coordinates into array index - you know register.

 

General recommendations:

You do not need 2 indicators to display the same value in hex and decimal format. Change display format to something like "hex: %x dec: %d" and it will show "hex: 2A dec: 42" - see attached

Move labels above array and hide them in each cluster. 

0 Kudos
Message 2 of 5
(2,825 Views)

Somehow I managed to post 2 replies at once. Ignore this one please or delete, if you can.

0 Kudos
Message 3 of 5
(2,825 Views)

I reckon you'll have a much easier time detecting a button press if the cluster was not a part of an array.  Value change events for arrays like this do fire on a button press but you don't have a way of knowing what control triggered the value change.  I suppose you could accomplish it using events by indexing the array and checking the status of the button on every value change of the array but this will cause many more events to fire when a text or numeric control is also updated. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 5
(2,818 Views)

>> but this will cause many more events to fire when a text or numeric control is also updated

Event is not fired when program changes control (local variable), the only exception - "Value Signalling" (do not use it, it is like bad goto operator)

If user can change other cluster elements in run-time, you can detect and properly process them in the same event frame. If he can not - then disable them. But making button(s) separate - better.

Another option - you can have a reference for cluster element (your button). If you register dynamic event for it, it will fire when any of the buttons in the array is pressed and obviously will not fire if something else changes.

0 Kudos
Message 5 of 5
(2,794 Views)