To move a untitled VI windows we can use the PanelBounds from VI Front Panel Window property. In order to get the mouse click, custom the button size, make it transparent and to get the mouse position the user32.dll can be used.
LABVIEW – Tip #46 – Move Front Panel to interact with user
We can use user interface to interact with user in differents ways, like changing colors, blinking, changing images and moving the front panel like i show in the video.
LABVIEW – Tip #45 – Control / Indicator Reference
level – easy
To simplify the code we can use references from controls or indicators to use in a subVI. Inside the subVI we can get properities or methods to read or change the object.
LABVIEW – Tip #44 – First Call
level – easy
Sometimes is needed to know if the subvi or a section of code is running for the first time. In this case i use to initialize a value from a ini file in a function global.
LABVIEW – Tip #43 – Close references (memory leak)
Level : Intermediate
To avoid memory leaks from labview code you need to pay attention to references that are created and not yet closed. After create the code is a good practice to create a stress test and look for memory leaks.
Memory leaks increase memory used from our program and somewhere in time crashes the program. Like the critical races, the memory leaks is not easy to detect, you need to test, test, test.
LABVIEW – Tip #42 – Notification Icon
Level : Intermediate
In Labview its posible to use .NET to connect to resourses like Notification Icon. Using the Notification Icon it’s posible to create animations changing the icon and indicate some status from the program. It’s posible create a menu and get feedback from it.
LABVIEW – Tip #41 – Change some Tools Options
level – easy
This is a very personal tip, because I believe everyone need to change the programs preferences to create a more easy and intuitive programing.
Disable in Block Diagram, ‘place front terminal as icons’, to make the code more compact and simple to read.
Disable in Block Diagram, ‘enable automatic wire routing’, to get the power to choose how and where I want the wire to go.
Disable in Front Panel, ‘show front panel grid’, to always view the final result of my UI and be able to change and move all objects pixel by pixel.
LABVIEW – Tip #40 – Change Position
Level: Easy
Using LabVIEW we can move objects during the execution of the program by using a ‘property node’ with the argument ‘position’.
LABVIEW – Tip #39 – CHANNEL WIRES
Level : Intermediate
Channel Wires can be used to pass information between parallel cycles in a simple way, without having to use queues or notifiers. This type of communication works like the producer / consumer architecture, as we have to be careful in choosing which type of connection to make.
TAG – we can guarantee the execution speed of the reading cycle and can have several modules of writing and reading in the same connection, but the reader can lose data.
STREAM – guarantees the data sequence with a determined buffer size, but the reader can be with a data queue, being delayes compared to the writer.
MESSENGER – guarantees the sequence of the data with a determined buffer size and can have several writing and reading modules on the same connection, but the reader can be with a data queue, being delayed in relation to the writer.
LABVIEW – Tip #38 – Set Mouse Busy
Level: Easy
To let the user being aware that the program is executing something, we can use the cursor functions ‘Set Busy’ and ‘Unset Busy’ to block the mouse actions and show the cursor ‘busy’.
LABVIEW – Tip #37 – Simple Run-Time Menu
Level: Easy
To simplify the ‘User Interface’ we can use a menu, that besides it can generate actions it can also set states and even create lists programmatically.
The menu can be changed while the program is running.
LABVIEW – Tip #36 – Change Data Dialog
Level : Intermediate
Sometimes it is necessary to create a dialog to be able to enter data or even configure something in the program. The dialogue function should be simple so that the user can intuitively know what to do and we can add validations to the ‘inputs’ – so that there are no errors in the program with incorrectly inserted values.
LABVIEW – Quiz #2
In the figure select corresponding leter to:
SHIFT REGISTER
CONDITIONAL TERMINAL
CONCATENATING TUNNEL
CONDITIONAL TUNNEL
INTERATION TERMINAL
TUNNEL
INDEXING TUNNEL
B – SHIFT REGISTER
E – CONDITIONAL TERMINAL
F – CONCATENATING TUNNEL
G – CONDITIONAL TUNNEL
D – INTERATION TERMINAL
A – TUNNEL
C – INDEXING TUNNEL
LABVIEW – Tip #35 – MySQL ODBC Connector by UDL File
Level : Intermediate
The use of databases in programs now is more common than ever due to being more versatile and faster to access data.
One of the ways to use a mySQL database is through the ‘Database’ module, using an ODBC connector and an UDL file.
LABVIEW – Tip #34 – Serial (VISA) – Arduino (button) to LabVIEW
Level : Intermediate
A communication with an external device can be done via USB-Serial-VISA. In this example, the arduino sends the letter ‘A’ by the serial port when the button is pressed and the letter ‘a’ when it is released. Meanwhile labVIEW is waiting for communication through a production cycle, which has the ability to recover if a serial port for disconnected. The consumer cycle makes a change in the control value.
LABVIEW – Tip #33 – Histogram + Cursors
Level : Intermediate
We can make a histogram with an XY graph in bar mode, to make it easier to create the bars, there is a ‘Histogram’ function on the probability and statistics palette. Using the cursors we can mark some values such as the mean and standard deviation.
LABVIEW – Quiz #1
Which function node execute first?
Multiply – Possible
Divide – Not
Subtract – Not
Pi – Possible
Add – Possible
Exponential – Not
Any of the functions nodes multiply, pi and add can be the first to be executed, all of them have values in their inputs when the program starts. Because we don’t known which one the compiler decides to be the first to execute, we have to be careful with our code to not create any critical run.
LABVIEW – Tip #32 – Add picture into button
Level : Intermediate
To improve the user interface nothing better then have
appealing buttons, to do that we can use normal buttons with custumized images.
LABVIEW – Tip #31 – Multiple formats and text in a numeric indicator or control
Level: Easy
Numeric indicators or controls can be formatted as a string, where it can have text and various formats for the same value. In case it is a control, the value can be edited in any of the formats.
LABVIEW – Tip #30 – VI Called dynamically by CALL SETUP
Level: Advanced
When we have functions (Vi’s) that are using memory and are not being used in the program constantly, they must be called dynamically. To make an easily call of the VI you can use the ‘Call Setup’.
LABVIEW – Tip #29 – Shortcuts
Level -Easy
To improve performance when creating the program, we can use shortcuts.
LABVIEW – Tip #28 – Bookmarks
Level – Easy
To find code more easily, we can use ‘bookmarks’, for that it is necessary to put a comment with # (‘hashtag’) following the name of the mark without spaces and then the text we want.
LABVIEW – Tip #27 – Format String vs Concatenate String
Level : Intermediate
To create a text with variables that have diferent formats, we can use several ways to do it. With ‘Format into String’ the code is cleaner, but with ‘Concatenate Strings’ it is more flexible.
LABVIEW – Tip #26 – VI to Sub Panel
Level : Intermediate
For a more flexible User Interface, we can use ‘Sub Panels’ to place VIs. During the program you can change the VI’s in the ‘Sub Panels’ as if they were different programs, passing information from one to the other or even stop its execution.
LABVIEW – Tip #25 – Producer / Consumer With Semaphore
Level : Advanced
When we have more than one producer and we just want that only one to be executed one per time, accordingly to their availability, we can use semaphore.
The semaphores will be waiting, per arrival order, of the release of the semaphore that is being executed, allowing by this way that both never work simultaneously.
LABVIEW – Tip #24 – Text to Speech
Level : Intermediate
In Labview we can use functions from ‘.NET’ , like for example: in ‘Block Diagram’, ‘Functions’, ‘connectivity’, ‘.NET’ were is ‘constructor node’ and select ‘speechSyntheizer’ to make your program speak.
LABVIEW – Tip #23 – Dynamic Threads
Level : Advanced
I like to compare a thread to a wired balloon (where the Wire is the handle) that connects to the program that has created it, so that it can be controlled in a easily way. When creating programs with dynamic threads it gives a huge flexibility, since when we add another connection to the system it is no longer required to change the code and making it more complex.
LABVIEW – Tip #22 – Webserver & IOT
Level : Intermediate
When using a webserver service, it is possible to insert data into the cloud so that they can be available in multiple devices with different operating systems. This type of interconnection may be part of a system based in IOT (internet of things) and can interact with different devices (Get/Insert Data, Input/Outputs).
LABVIEW – Tip #21 – Comments
If you have clean and clear code in labview just by itself easy to understanding, as such can be complemented by comments, images and decorations. When we want to “comment” a segment of code to not be executed, you can use the ‘Disable Structure’.
LABVIEW – Tip #20 – Value signaling – programmatically
When it’s required to generate programmatically a ‘value change’ event, we can use: property node – Value(Signaling). With this choice it looks it has been changed by the user.
LABVIEW – Tip #19 – Log File
It is important to create a file where chronological text can be inserted to report events. This function may be used in different parts of the program.
LABVIEW – Tip #18 – Custom Dashboard
One way to create a custom dashboard is by creating a transparency mask and place it over the indicators.
LABVIEW – Tip #17 – Copy String Array to Clipboard
When selecting ‘clipboard.write’ method in the ‘invoke node’ you can copy a pre-formatted string with ‘array to string from the spreadsheet’ to the clipboard. To insert the data in Excel you just need to paste or use the shortcut ‘ctrl + v’.
LABVIEW – Tip #16 – Read and Write configuration file
You can take the advantage of reading a configuration file (.INI) to create a default value in the file – in case it does not exist. Using the option ‘stacked sequence structure’ it will take less space and the configuration file can be read in a more constructed way.
LABVIEW – Tip #15 – Remove frame from controls
The change of elements in User interface makes the program more appealing and practical to use. One of the simple ways to make it happen is to change the colors. To remove the control frame you can use the brush in Tools Palette, choosing the transparent color as primary and secondary color.
LABVIEW – Tip #14 – Object Refresh in User Interface
The modification of the properties of the objects that are in the Front Panel may force that the same objects can be re-drawing, and due to that the UI can be slower. As such, in order to make the UI more fast and smooth , it is possible to block the update on the objects while they are being drawing and release this block in the end.
LABVIEW – Tip #13 – Customized XY Graph
We can draw a graph by using the dots (x,y) having an value Array as base, and like this creating a new way to present – just by grouping some dots.
LABVIEW – Tip #12 – Join Arrays with different dimensions
When joining Arrays with different sizes using Build Array, an Array with bigger dimension will be created and inserting the Default value in the smaller Arrays until they get an equal size. To keep the dimensions of the Arrays you need insert individually on each one as Cluster and with this action they can be inserted into a Build Array without losing their original size.
LABVIEW – Tip #11 – Exits/Entries of VI in Cluster
When the VI has too many exits/entries, it can be complicated to map the terminals. Grouping into clusters can be used to simplify (it should be TypeDef to make it simple and faster to change in case of any modification)
LABVIEW – Tip #10 – Code sequence
It’s not enough to put the code from left to right in labview, or even up to down to assure it’s sequence. A information flux is always needed to assure that the program behaves as we want, and for that we can use some tools to define the sequence, such as, use the Error Control Line, Flat Sequence, Stacked Sequence, FOR cycle with Structure Case, State Machine…
LABVIEW – Tip #9 – Icon Editor
When we create a ‘vi’ function it is important to change it’s ICON, to make it clear the code implementation. As such when looking to the ICON we should manage to understand it’s function, and for that the should be perceptible (Large letters and abbreviations if needed) as well as a simple drawing can be done that can identify the function, to assist it’s understanding.
LABVIEW – Tip #8 – Shift Register
When it is necessary to pass data between the existent connections of cycles, Shift Register should be used to avoid variables and assure the synchronism. The exit tunnel of Shift Register can be pushed to obtain the values of earlier interactions, from up side down (last one [-1], penultimate [-2], antepenultimate [-3], …)
LABVIEW – Tip #7 – FOR Cycle
The number of cycles can be initialized with the “N” or by the array entry of the FOR cycle. When it is initialized with “0” on the “N”, the code that is inside the FOR cycle will not executed and the exit tunnels will have their values as default. In case that it is a simple tunnel the default value is the same as the variable type default value, however if it is a shift register the value is the same as the one that is on the entry. So, when initializing with arrays, the quantity of cycles will be defined by the smaller array size. All the other tunnel entries values don’t change the number of cycles in the FOR cycle.
LABVIEW – Tip #6 – User Interface
User Interface can be more important than the code itself, being the ”face” of our program, likewise we need to treat it as such. Treating the UI as a painting, starting first to do a draft where I insert all the necessary elements for the user connection, then proceeding on making the code. During the program execution the information of the objects interacts with the balance of the UI, obtaining the desirable environment.
LABVIEW – Tip #5 – Exit LabVIEW
To exit Labview in Run Time mode (executable file) it is needed to select “Property Node” ->“Application” -> “Kind” in sequence of the program, with a case option “Run Time System” and also “Quit Labview” inside.
LABVIEW – Tip #4 – Function Global Variable
To ensure the syncronism when using variables, we can create a highly customized function and use it in any section of the program. For that we can use the while cycle to make one single interaction (“True” in exit condition) storing one or more shift register to store the information. For the entry conditions of the “case” we can use “enum”, “string”, “numeric”, “bollean”, depending on the requirement.
LABVIEW – Tip #3 – Master / Slave
To use this architecture we can use queues (data sequences) to insert data in the Master and take it out from the queue in one or more Slaves. To finish the Slave execution, it is possible to use the error line of the queue in terminate condition of the while cycle (in release queue it is needed to insert the entry “force destroy” in “True” condition)
LABVIEW – Tip #2 – TypeDef
When data structures or controls are used and we may need to change them during the program, we should use the control as TypeDef. Like this, when it is necessary to make a change in the program it can be seen in all places where it was used, saving time and making easier any future program changes.
LABVIEW – Tip #1 – While cycles
When we use a while cycle in Labview for the program structure and where there is no need for the cycles to be executed quickly, we can use this function to slow it’s execution (eg: wait until)
In this way the program will work as excepted, without making the processor creating the most number of interactions, and with this action it will decrease as well the load of our program and machine.