08-08-2012 04:25 AM
Thanks a lot. I downloaded both examples and now I´m trying to understand. I never used anything like that, as I said, beginner 🙂 Hopofully I´ll get it. Thanks again.
08-08-2012 06:50 AM
Hi Tikka,
I read your code and your problem is basically in choosing wrong architecture. It is good to use templates. It is basic code with some structure, where you can start. You can find it clicking on "File > New" and in opened window there is list. Choose VI > From Template > Frameworks > Design Patterns. For your use is good to use Producer/Consumer Design Pattern (Events). Basically, there are two loops, first for receiving user action, second with code to execute based on user action.
I have also some tips for improvements at your code:
1. You are using a lot of wires. Good way is merge them into cluster using function Bundle by Name and using only one wire for multiple signals and using function Unbundle by Name you can pick one (or more) of this signals for usage.
2. Never use two Event Structures in single while loop. Try to use only one Event Structure at your code, If you want to use more of them, only one structure should handle one particular event.
3. Try to reduce execution time for every event case as much as possible. If not, user interface will be freezed and you will not be able to change anything.
4. Use timing function only on one place. Anyway, why do you wait 300 ms in upper Flat Sequence?
5. People here are telling you to use local or global variables. Basically, it is not a good way how to program your code. In bigger projects it causes big problems because it is very hard to debug. Using Producer/Consumer Design Pattern (Events) is better for you.
6. You are using Flat Sequence a lot. Using state machine is way more better solution. Look at example code showed on https://decibel.ni.com/content/docs/DOC-15515 . Notice, there is used Type Definition. Article on http://zone.ni.com/reference/en-XX/help/371361E-01/lvconcepts/custom_cont_ind_type/ describes what is that and how can you work with it. Big advantage of Type Definition is fact, that modifying the structure will affect all instances used in code.
Good way how to avoid Flat Sequences is also appropriate use of error cluster. You can easilly determine dataflow with it. So good way is also to add error cluster to subVIs.
7. You can also merge your front panel elements into a cluster with type definition as mentioned above.
8. For saving the place on block diagram, you can right click on terminal and uncheck View As Icon for compact view. You can also set this as default in Tools - Options - Block Diagram - uncheck Place front panel terminals as icons.
9. Try to comment your code well. Use free labels.
10. Use subVI for functionality, what is repeatedly used in code. It saves time and make your code more readable. Also do not forget to comment your subVI and write descriptive input and output variable names. For example, you can replace your formula node with related arithmetics with subVI. For example, you are doing some calculations before you show the values on terminals. In this case, using subVI can make you code more readable. Do not be afraid of using subVI in subVI. Use View > VI Hierarchy to show hierarchy of your code.
11. Add your files into a project. It is more transparent for you and also for others.
12. In hodnotaCreg.vi is better to use Select function.
13. In nastaveniCreg.vi, nastaveniFilament.vi, nastaveniHV.vi and NavazaniKomunikace.vi you are using string constant for setting the address. Use Numeric Constant and by right click, Display Format and select Hexadecimal in Type section. Using this you will avoid to use redundant function for converting string into number.
In some of this subVIs you are using same arithmetics, so you should use subVI.
For better learning, I also add some webcasts:
1. Design patterns http://zone.ni.com/wv/app/doc/p/id/wv-2886 and http://zone.ni.com/wv/app/doc/p/id/wv-2322 .
2. Clusters http://zone.ni.com/wv/app/doc/p/id/wv-2971 .
3. Using arrays and clusters effectively http://zone.ni.com/wv/app/doc/p/id/wv-2885 .
4. Tips and tricks for creating LabVIEW user interface http://zone.ni.com/wv/app/doc/p/id/wv-3260 .
Good luck with your project!
Martin
08-08-2012 10:07 AM - edited 08-08-2012 10:14 AM
Bundle your data lines for cleaner look and change your Icons...
and right click on your "Teplota">>Visible Items>>check "Digital Display"...no need to add another "dig display" at the lower left of it
Again, no need for 2x "Event Structures" within your while loop....I do not understand your reasoning for using multiple "Wait(ms)". Check out LabVIEW 101