LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to give same inputs but multiple times on XY graph

If we search long enough, we can find the code of the first picture somewhere in the middle left of the diagram. You have a gigantic stacked sequence with 45 (!!!) nearly identical frames, seemingly differing by a single diagram constant. Why all that duplicate code??? This is not maintainable (i.e. if the code needs to change, you need to make identical changes in 45 different places!). Right below, you have a similar gigantic stack.

 

All you need is one instance of the code in a FOR loop that autoindexes on an array of constants. Now it will also be trivial to solve your graph problem with a few clicks of the mouse!

 

Why is there So... Much... Duplicate... Code!!!!! Why are there So... Many... Local... Variables??? This is a nightmare!

 

Most of your case structures are 100% guaranteed always true, so why are they even there?

 

alwaystrue.png

 

 

I strongly urge you to hire a professional programmer to rewrite this from scratch. Properly written it will easily fit on one screen with less than 5% of the current code. It is a relatively simple front panel and the code can be equally simple!

 

Even the front panel should be cleaned up. Align the buttons and make them the same size. Use a cluster or array of booleans, etc. Eliminate all that empty blue-space and make it fit on a 1080p screen.

0 Kudos
Message 11 of 18
(1,691 Views)

Thank you @altenbach and @RavensFan for all the suggestions.I will surely make this changes.

@altenbach i made all duplicate code because every fault having different modbus address.

Now ,Can u tell me how to get the graph for 45 faults in current scenario.

0 Kudos
Message 12 of 18
(1,674 Views)

@avana2006 wrote:

@altenbach i made all duplicate code because every fault having different modbus address.

The only thing that differs is the modbus address. All can share one instance of the code.

 

(It is pointless even trying to fix this code by adding even more code. Sorry, your code is just too large for my laptop screen, and trying to cleanup the diagram locks up LabVIEW forever. Once you use a FOR loop instead of the stacked sequence, autoindexing on an array of modbus addresses as already suggested, you can create an array of the four faults for each iteration (or address), autoindexing at the loop boundary to create a 4(columns)x45(rows) 2D array. Just wire that to your graph after transposing (or setting the graph to transpose).

0 Kudos
Message 13 of 18
(1,664 Views)

@altenbach Yes. because data is coming from hardware and  that data have to show in graph and that's why modbus address is very important.

Can you share me only snippet code for graph with 45 faults and with for loop?

0 Kudos
Message 14 of 18
(1,661 Views)

Here is how you read multiple registers within a loop.

 

 

 

PLEASE take those tutorials that have been pointed out to you before.  Loops and Arrays are basic concepts in LabVIEW and any programming language you need to understand if you want to get past any "Hello World" type of programming.

0 Kudos
Message 15 of 18
(1,650 Views)

Here's a simple example how to graph four faults for each of the devices. Maybe it can give you some ideas. (Note that I did not need a stacked sequence with 45 cases!!!).:

 

altenbach_0-1599417877220.png

 

0 Kudos
Message 16 of 18
(1,643 Views)

@altenbach I saw your diagram.Yes I want the same output but my question is how can I take output from Modbus block(Read holding Register block of modbus)?

Because every fault having there own modbus block and respective addresses.How can I read data and connect to further blocks?  Thanks in advance.

0 Kudos
Message 17 of 18
(1,620 Views)

@avana2006 wrote:

Because every fault having there own modbus block and respective addresses.How can I read data and connect to further blocks?  Thanks in advance.


Every one of the 45 calls use the same subVI to get the modbus data, just called with a different address. All can use the same. Your sequence (or my FOR loop) ensure that all calls occur in sequence. Why do you think you need 45 instances of the same subVI? Makes no sense!

0 Kudos
Message 18 of 18
(1,617 Views)