03-22-2020 05:15 AM
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
03-22-2020 09:54 AM
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
03-22-2020 12:05 PM
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:
This code is uncommonly bad.
03-22-2020 03:00 PM - edited 03-22-2020 03:01 PM
No! No! No!
Some more comments (but I could literally go on for hours!)
03-22-2020 03:36 PM
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
03-22-2020 03:41 PM
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
03-22-2020 04:01 PM
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.
03-22-2020 04:21 PM
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
03-22-2020 04:57 PM
@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.
03-22-2020 07:09 PM - edited 03-22-2020 07:13 PM
@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.