LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can this even be done?

Solved!
Go to solution

In the attached VI I am trying to achieve 2 things.

 

1) When I press the ON boolean, I want the power level to go to to 100%

 

2) When I press the STOP boolean I want to do all 4 of the following

a) Overwrite the ON boolean

b) set "Power Level" to go to "Off"

c) The desired hex string at "Off" is sent to VISA

d) switching off the program.

 

Can this be done?

 

Other criticisms of the block diagram are also appreciated!

 

Thanks

 

mhaque

Download All
0 Kudos
Message 1 of 11
(7,081 Views)
Can it be done? Yes. Criticism? Your block diagram is quite large. Typically, you want to keep your VIs to size of just one screen so you can see everything without having to scroll. You could remove a lot of white space that would make things easier to see. When you start creating larger, more complex projects you'll really appreciate having things compact. Consider putting all of your LEDs into an array or a cluster. This will take up less space on the block diagram and make it much easier to make your code modular.
---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 2 of 11
(7,051 Views)

The checksum VI is neat, but overly advanced.

If the char is a hex character, add it to an array, feed the array to a shift register. Once it has looped through you've done both your first loops in one small one. Then you only need to convert back to string and Hexadecimal string to number.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 11
(7,028 Views)

Hi mhaque,

 

one of the things i would point out is the use of the property nodes. In some circumstances they are necessary but you still need to be careful with how you use them. In the top left corner of your main vi you are writing to property nodes each iteration whether the controls for Fans or Lamps should be visible or not:

 

Prop node snippet.png

 

Above is a snippet of that section (Looks messier then it actually is due to the way snippets are created). Each iteration you are reading from a local variable the amount of Lamps or Fans. From that string you are then outputting booleans from a case structure into the visible properties of the indicators. Writing to a property node is a slow operation as it forces a thread change to the UI thread. I cannot remember the exact speeds but its enough to make you want to limit the amount of times you do it to a minimum. I was very recently helping a guy who was failing to get a sample rate he required to read from an external piece of equipment. One of the main reasons causing this was because he was writing to 100+ property nodes every iteration. In your example you will not notice the impact of the property nodes as you have a 350ms pause per iteration. It is still good habit to handle property nodes correctly though as you dont know what might change in the future.

 

To make your code more efficient i would start off by placing all your lamp indicators in a cluster and all your fan indicators in a cluster. If you use the Cluster from the classic palette you can use the paint brush tool to make it transparent, giving you the effect you currently have. I would ensure that all the indicators in the cluster where in the correct order. I would then encapsulate the changing of the property within a subvi that can be used by either the Fans or the Lamps.

 

Change visibility vi.png:

 

In your main vi i would then use shift registers to see whether the #Fans or #Lamps Enum had changed (In yours you use a combobox, i have changed this to an Enum for this example). If there has been a change you could then use the subvi to change the visibility accordingly:

 

Change visibilty ex 1.png

 

 

Now you will only write to a property node when the value of your Enums change. If it was a large vi and i didnt want lots of shift registers i would use a small vi to indicate whether the Enum had changed since the last iteration:

 

Change visibilty ex 2.png

 

 

This does exactly the same as the shift register but helps reduce clutter and keep the vi tidy.

 

Is there a reason you are using a combobox? An enum would better suit your needs from what i have seen. As long as the amount of Fans or Lamps are continuous, ie from 0,1,2,3,4,5. If you do need to miss some values, ie can never be 3, then i would use a text ring. Both of these control output a number instead of a string.

 

Rgs,

 

Lucither

 

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 4 of 11
(7,004 Views)

In general the program could easily be converted to an Event structure which'll make it tidier and better structured. The Visibility would then automatically only be performed when a button is pressed.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 11
(6,972 Views)

Thank you all for the constructive critcism!

 

But my main issue has still gone unanswered. Where would the event structure fit in? I am fairly new to LabVIEW and I have had minimal succes in using event strctures.

 

mhaque

0 Kudos
Message 6 of 11
(6,941 Views)
Solution
Accepted by mhaque

How's this as a first look at an event based change?

I also modified the Checksum, i should work the same (dont throw your current code until you've double checked)

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Download All
Message 7 of 11
(6,888 Views)

could you post this in LabVIEW 9 or less?

 

mhaque

0 Kudos
Message 8 of 11
(6,883 Views)

your version of labVIEW is 10.0. I currently only have 9 😞 so it won't open.

 

 

0 Kudos
Message 9 of 11
(6,862 Views)

@Yamaeda wrote:

The checksum VI is neat, but overly advanced.

If the char is a hex character, add it to an array, feed the array to a shift register. Once it has looped through you've done both your first loops in one small one. Then you only need to convert back to string and Hexadecimal string to number.

 

/Y


 

On a side note (if he used your method this would be a non-issue anyways) but delete from array is being used in a loop. Have a look at using replace array subset then replacing the array afterwards.

0 Kudos
Message 10 of 11
(6,859 Views)