LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

verification of my software code for best practice

Hello

 

I am attaching my working code for you all experts to suggest me what bad coding practices i have implemented in my application and request you all to suggest me the best practice to follow in place of them to improve my code's performance.

 

My code is written in labview 2019 version

 

Flow of application:

1st window - username entry_WSP Offline GUI

2nd window - WSP Offline GUI Main

In 2nd window , on pressing the "Disconnected" button ,communication with embedded device starts through USB communication against a specific protocol. It is currently working at 100 ms. But in 100 ms also i see at times it skips a packet. I want to optimize it to work at 50 ms or below. Total bytes per iteration is 39 bytes

 

Inside 2nd window, there are sub-windows at the top to see the Faults, RTC, Slide etc of the embedded device through USB communication only.

 

 

Awaiting your expert advice and suggestions to improve and optimize my code to perform better

 

thanks in advance

Dushyant

 

 

 

 

 

0 Kudos
Message 1 of 34
(3,654 Views)

Horrible code duplication where it should have been a loop.

Overuse of control references and properties where it could be handled elsewhere or with a simple Local or shift register.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 34
(3,606 Views)

In addition to the points made by Yamaeda,

the block diagram has an obnoxiously large amount of stuff in it.  This is severely compounded by excessive white space.

Basically there is extensive misuse of many things.  Here is just one example:

fl.png

This code is uncommonly bad.

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

No! No! No!

 

Some more comments (but I could literally go on for hours!)

 

  • Why would you convert large integer arrays to DBL (8 bytes/data!!!) to display a single bit per value on a pseudo-digital graph? Your data structure is 64x larger than needed!
  • Let's look at the code in one of your subVIs to join two U8 integers. There just has to be a better way that "going green", reversing and joining boolean arrays and ending with a U32 with twice as many bits than needed. All you need is blue! (And yes, there is a better way. See bottom of picture.)
  • ... arghhhh! (closing project and giving up!)

 

altenbach_0-1584906903455.png

 

Message 4 of 34
(3,570 Views)

Thanks Yamaeda for your valuable comments.

I will put your suggestions into use and try to improve the code as much as I can.

I would be glad if u provide more inputs to make the code perform better

 

thanks a lot

0 Kudos
Message 5 of 34
(3,561 Views)

Thanks Paul for your comments 

 

Few things I already know that are there in the code which are of no use and I will eventually remove them. Alongwith that i will implement your suggestions to make the code perform better

 

I would request if u could provide me more inputs to make a better working code.

 

thanks a lot

0 Kudos
Message 6 of 34
(3,558 Views)

Thanks

I will implement the code suggested by you but if you see the code, I am using the single bits as well through this Subvi. That is why converting it into Boolean array

 

If you experts won’t help the beginners like us then how would we learn the best practices.

 

 

0 Kudos
Message 7 of 34
(3,552 Views)

Sigh.  LabVIEW is difficult to learn "on your own".  You can learn the "mechanics" by yourself, for example, by spending as much time as possible with the Tutorials and other "Learn LabVIEW" features that you can find on this Forum and by searching the Web.  Start with small projects, and build.  Learn to use sub-VIs to "hide the messy details.

 

Once you have the basics well in hand, you need to learn what, for want of a better word, I will call "Style" Rules, or "How to write Good LabVIEW Code".  I went on the Web, just for fun, and typed "LabVIEW Style Guide" and got several "hits", including this one .

 

When I started learning LabVIEW, I already had several dozen years of programming experience, had learned about (and practiced) "Structured Programming", but had no LabVIEW experience.  I was fortunate that there was a senior Engineer who helped me get started, showed me "how to wire", and went over a fairly complicated project with me so I could understand a little about how to put the pieces together.

 

I also purchased two books -- Travis and Kring's "LabVIEW for Everyone(Third Edition)", which has encyclopedic information about LabVIEW, including LabVIEW 8 (but 90% is still relevant today), and Peter Blume's "The LabVIEW Style Book", also from the same era.  The first book got me started, but the second one taught me about Style, the secret of good LabVIEW development.

 

Bob Schor

0 Kudos
Message 8 of 34
(3,546 Views)

@Dushy_11 wrote:

Thanks

I will implement the code suggested by you but if you see the code, I am using the single bits as well through this Subvi. That is why converting it into Boolean array

 


A Boolean array is not "single bits", it takes 8x more memory than that. The correct way would be to use blue arrays everywhere. 

0 Kudos
Message 9 of 34
(3,537 Views)

@Bob_Schor wrote:

...

When I started learning LabVIEW, I already had several dozen years of programming experience, EW development.

...

Bob Schor


Hmm.  If you started programming when you were 10, that would make you between 60 and 80 when you started learning LabVIEW.  You've been on this forum for more than a decade, which would put you around  75 - 95 years old now.  Maybe you meant to write something else.

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