레이블이 LabVIEW인 게시물을 표시합니다. 모든 게시물 표시
레이블이 LabVIEW인 게시물을 표시합니다. 모든 게시물 표시

2016년 8월 4일 목요일

The method to control VI VI dynamically at runtime using NI LabVIEW VI Scriting



Today programmatically to create a VI in LabVIEW, or let's learn about the features that can be edited.

Dynamically it indeyo features that used to control the LabVIEW VI.

Function that provides this capability is the right guy named NI LabVIEW Scripting.

LabVIEW VI Scripting is given to provide classes, properties, methods, etc. for the VI Server, and users can be added by creating a specific object on the front panel or block diagram, and help create new VI, running, stopping also possible.

Features of the NI LabVIEW Scripting is as follows:


  • Generating a new code programmatically running LabVIEW
  • Check and change existing code
  • Place new controls and indicators programmatically
  • VI connector pane Edit

In other words, using the NI LabVIEW Scripting hers that enables you to configure the code, connectors, fans, UI, etc. programmatically.

Therefore, users will be able to use the LabVIEW programming efficiency while having the flexibility to develop using LabVIEW VI Scripting.

LabVIEW VI Scripting is included by default from the LabVIEW 2010. Until the 2009 version, you must install through VIPM.

For LabVIEW VI Scripting You can find the relevant data in a user forum through the link below.

http://decibel.ni.com/content/groups/labview-apis

Starting with LabVIEW 2010 includes the version I'm a LabVIEW VI Scripting.

To look at the related example shown below, you can see through the NI Example Finder.



VI in the NI Example Finder to control programmatically In the example below, there are various folders.

Let us take the example of a number by executing Adding Objects.vi.
First, let's briefly look at the code.


The above code will get the new one to come see VI sets the size and location of the front panel and block diagram. And in the block diagram - Add (Substract) function to close the reference.

When this code executes, you can view the following results.



As a processing in the code to create a new VI and, after setting the front panel and block diagram location, on the block diagram - sixes entered into the function.

In this article we learned about the LabVIEW VI Scripting VI at briefly how to control the runtime to run the VI.

Thanks.

2014년 10월 19일 일요일

[LabVIEW Example] Reading a text-file to set off a clause by a line in LabVIEW



There are many chances to process a text file during your programming in LabVIEW. In order to handle a text file efficiently, you have to know how to process it using FILE IO and VI related to String. You also have to know the method for it.

In this article, I will show an example to set off a clause by a line for a text file in LabVIEW. The example for this article is implemented as a picture below.


There are simple description for that likes below.

  1. Read a text file.
  2. Make string arrays which is separated by line in a text file. 
  3. Return the result which is included about a size of arrays and the number of line.

The key point for this is a second process. This shows the method to figure out the number of line in a text file. I think there is no difficult to understand about FILE IO because we use it to read a file many times. This code uses 'Read from text file" function. It is easy to use for you.

Let's look at the topic for the second process. This process uses "Spreadsheet String To Array" function in LabVIEW.


This function is a method to make a specific array from a string. Let's check the content using the picture above. In this picture, you can see the more details than my description.

There are 4 inputs and 1 output. Inputs are consisted of delimiter, format string, spreadsheet string, and array type. Output is just array for the result.

The main point in this function is a format string. This can decide the type of array for result. You can choose a type for string, double, or integer. In fact, this function is not important in my code, but this factor is important when you use it for a different situation.

The data-type doesn't matter this code just get the number of line in text file.  If you want to process a text file more detail, you have to use a proper format string. Don't forget that string is %s, double is %f, and integer is %d.
If you want to get string array, you just modified this code likes below. You can make that is changed from double to string type.


Let's test this code. I made a sample for this test. This sample has 7 lines in a file which is named "about labview.txt" as below. 


After executed this code, you can see the result below.



I think there are other options for that, but it is one of these option to get a result easily. I am going to attach the text file and vi in this blog. (The version of LabVIEW is 2013)

Attached files:

Thanks

2014년 10월 15일 수요일

The method to download LabVIEW 2011, 2012, 2013, and 2014




Today, I'm going to show how to download the latest LabVIEW in a website.

1) To download it, you should go to ni.com/labview and then you just click Download LabVIEW button which is located in left of the middle in a web browser  like a picture below. 


2) After click, you can see a description and a video about LabVIEW. You need to click right of the middle button. 


3) You have to select a method to login-in. If you are a user in this website, you just click a link for log-in. If you are not a user, you need to make a form and submit it.


4) After a login process, you can see the filled form. In this form, you choice the LabView what you're interested between LabVIEW 2011 or earlier and LabVIEW 2012 or LabVIEW 2013.

If you want to download LabVIEW 2014, you have to choose a second value and click a continue button.


5) As you can see a picture below, you can down load LabVIEW, modules, toolkits, and Device Driver.

Enjoy LabVIEW!!


This article showed how to download LabVIEW.
Thanks.

[LabVIEW Example] Changing Array UI programmatically in LabVIEW



When you use Array control or indicator in LabVIEW, you want to change Array in FrontPanel programmatically. Array Control and Indicator is not changed basically if some values in Array is inserted or changed likes a below picture.

In this situation, you can check the first value, but you can not check other values in array directly. To see these value, you have to click a button or insert value to a user interface. 


Can we solve this problem in programming mode? Yes, we can. We can use a property node for it in LabVIEW.

First, Let's look at the code to generate an array in LabVIEW.



The code above repeats a for loop according to the value of NumberOfArray and generates an array filled with the corresponding i values. Running it with 5 in NumberOfArray basically will be seen as a picture below.


To solve this, you should use a property node called Number of Row. When you set the array's length to this property node, you can see the result as below. If you want to use a two dimension array, you have to set Number of Row and Number of Column.


Now, I am going to show the method to implement for it. To make this property, you just click a right button of your mouse on array in Block Diagram and  choose Number of Rows as below a picture.




And then you need to modify this code to set the value to this property. Then you can see the a right result in FrontPanel.

This article explained how to change the Array User Interface in programmatic.
Thanks.

2014년 10월 12일 일요일

LabVIEW Tutorial - 2 : Shift Register



In past particle, I explained the loop related to For, While structure.

This article is going to explain how to get the result of the process in the Loop. For example, We can get the average of some process in which is calculated in LabVIEW.


At this time, we need the concepts in LabVIEW; LabVIEW calls this to a Shift Register.



Passing the values between Loop iterations.

We use a Shift Register or a Feedback Node to pass the values from one iteration to next iteration in For or While Loop.

How do you put a Shift Register in Loop? Yon can insert it when you click left-button of a mouse on the Loop. If clicked, you can find the add shift register in the popup-menu. When you create Shift Register, you can see arrow icon in the left and right side of Loop as below picture. It is a Shift Register in LabVIEW.





Then, We have to think What the important things to use a Shift Register.; The below things are the answers.

  • Initializing the value in a Shift Register
  • Calculation for Shift Register
  • The method to set multiple values in a left node of a Shift Register
  • The result of Shift Register
Let's look at the consideration for a Shift Register in detail.

1) Initializing the value in a Shift Register


This means the initial value inserted before the operation of the loop. When the first iteration is executed, the algorithm used this value to calculate results by itself. I implemented to add 1 to a Shift Register for 10 times as below the picture. In this example, the first value entered in loop is 0 because I inserted 0 to a Shift Register. If you want to set another value, you can use a control or constants in a block-diagram.





See also:

If you don't initialize a Shift Register and repeat this algorithm, the last calculation result in last execution can be a initial value for a next iteration.


2) Calculation of a Shift Register


To explain it, We should check the upper picture. In this picture, you can see the red table in a right bottom of the picture.


It shows the result when a first(i=0), second(i=1), and third(i=2) iteration is executed. It means the last value which is set to a right Shift Register moves to a left Shift Register for a next iteration. This value will be used in next iteration as an initial value. The values in the table are the results for each iteration.



3) The method to set multiple values to a left node in a Shift Register


To add and set the multiple values to Shift Register nodes, you have to click and drag-and-drop on a left node of a Shift Register. You can add multiple nodes as you need. I modified the upper code and added additionally a node to a Shift Register.




In the above picture, you can see the another table which shows the initial value and the results.

You can understand it easily if you have the concepts about a Shift Register. If you don't understand it, you should find the more information about it or read a above description in this article.


When this algorithm is repeated 4 times, the values are as follows:


  • i = 3
  • First Left Shift Register = 3
  • Second Left Shift Register = 2

After this 4th iteration, the value will be changed as follows:

  • i = 4
  • First Left Shift Register = 4
  • Second Left Shift Register = 3

Therefore you can think the value of second left shift register is set from first after the iteration.

4) The result of a Shift Register 


This result is returned when the Loop is exited. To confirm this value, you can connect this value to an indicator in a block diagram as above the code.


I explained the meaning and the usage for a Shift Register in this article.


Thanks.


2014년 10월 8일 수요일

[LabVIEW] About the casting from Byte to String, and vice versa.



When your application make a communication(RS232, TCP, UDP, GPIB, and so on) to other device in LabVIEW, the type of data which is transmitted is STRING. But C and other text language use byte to transmit to LabVIEW.

User can feel confused when they integrated their system with other program which is implemented in C or C#. How does it solve this problem in LabVIEW?

To solve it, you should cast a data-type from byte to string , and vice versa. You can use Type Cast function for it in LabVIEW.

The description of Type Cast is as follow:
  • X : It is a real value to cast
  • type : It is a type of data to cast
  • Result : It is a result which is change


The below code is the example which used this function. As you can see, the first algorithm change from HEX values(1-9) to STRING values(ASCII code) and then string values change from STRING values to INTEGER values. The important point is that the result size is variable depend on the size of INTEGER.


You can check it in the result. As you can see, the value in length(i8) is 1. The means the result which is changed from I8 is 1byte. On the contrary to this, length(I32) is 4.

In other words, the Type Cast function converts each 8-bits of input data into a result. 

This function can generate unexpected data if x and type are not the same size. If x requires more bits of storage than type, this function uses the upper bytes of x and discards the remaining lower bytes. If x is of a smaller data type than type, this function moves the data in x to the upper bytes of type and fills the remaining bytes with zeros. For example, an 8-bit unsigned integer with value 1 type cast to a 16-bit unsigned integer results in a value of 256.


The cast from byte to string in LabVIEW makes many people confused in real world situation. This article explained how to solve this problem. Thanks.


2014년 10월 6일 월요일

[LabVIEW] Creating and Configuring MSSQL UDL Files and Implementing a code in LabVIEW




In this article, I will explain the way that interworks LabVIEW and MSSQL.

To connect the Database, We need to create or have a UDL file. UDL is a Universion Data Link which defines how to access the specific data source such as MSSQL, MySQL, and so on.

The Microsoft Data Access Components (MDAC) provide the Data Link Properties dialog box as the common user interface for specifying connection information to a data provider on Windows 2000 and later operating systems.

1) Creating and Configuring UDL file

1-1) To create a udl file, you have to select the folder in which you want to store the udl file and create a txt file in Windows.

1-2) Rename this file, removing all spaces and changing its file extesion to udl.

1-3) Double-click the universal data link (.udl) file. The Data Link Properties dialog box opens, displaying the following tabs: Provider, Connection, Advanced, and All. Choose Next to navigate from tab to tab.


1-4) In Provider tab, For MSSQL server, select Microsoft OLE DB Provider for SQL Server. 

1-5) In Connection tab, enter the information about server name, login information, and database which is made in server.

1-6) Click Test Connection and confirm the result. If your setting is correct, you can see the below picture. 


2) The implementation to use a database in LabVIEW

We need to use a Database Connectivity Toolkit for an efficient database programming in LabVIEW. The information of this toolkit is as follows:


Let's look at the part of the programming. 

You can find the functions for a Database Connectivity Toolkit in Functions - Connectivity - Database. These functions are to use easily. These functions are made intuitively. Therefore you can use these functions(subVIs) easily.

This code is that

1) Connect the server through a udl file

2) Run sql command as "Select UserName, UserAge from UserTbl"

3) Get the result from MSSQL server and show it to an data indicator

4) Remove rows if condition is true

5) Run sql command as "Select UserName, UserAge from UserTbl"

6) Get the result from MSSQL server and show it to an data 2 indicator

7) you can compare the result

In this article, I explained the way to create and configure a udl fine and the usage in LabVIEW.


2014년 10월 4일 토요일

LabVIEW Tutorial - 1 : About Loop(For, While)





1. While and For Loops

LabVIEW has the merits to learn and to implement an application fast then the text-based language such as C, C++, C#. But it also requires a specific structure for an algorithm to implement the program. 


This article tell you about the loop structure(While, For) to implement it.

While and For Loop is a method to make and repeat an algorithm.
What does it have a difference between it?

1) While Loops

An while structure is one of the loop method. It can make a decision for the repeat prior to running the loop. If conditional statement is false, an while loop will make the repeat for the algorithm in the while loop. In C Language, a programmer use a For Loop more than a While Loop. But LabVIEW user tends to use the While Loop than a For Loop. 


Let's take look at the below picture to understand a flowchart for an While Loop.


This picture show a while loop in the text-based language.  You can write the code that repeat infinitely when A statement is true. If A statement is true, the algorithm process B statement. But if A is false, then an while loop is ends up.

Additional Tips!!
When you use an while loop in the LabVIEW, it make an additional thread in the program. You have to manage a thread which is made by a user manually in the text-based language. In the LabVIEW, the compiler  can handle it. User don't make a control for an additional thread. 

If you add 3 while loops in the block diagram, this program make and run 3 threads in the CPU.

We will see how to use a while loop in the LabVIEW. First, Let's take a method to insert it. You can find and add this statement in the popup menu of the block diagram when you click the right button of your mouse. You also find a for statement at same place.


[Path : Function - Programming - Structure - For or While Loop]



I am going to introduce an while loop. You should repeat the code in the sub-diagram until the specific condition is true. You can find more information in the LabVIEW's help. When added an while loop in the block diagram, you can see the Repeat Terminal and the Conditional Terminal in the block diagram. 
  • Iteration Terminal : It defines the number of an iteration. 0 is the first value.
  • Conditional Terminal : It defines when the loop stops. You have to enter a boolean value to it. 
  • There are two settings for the Conditional Terminal: Continue If True and Stop If True. When set to Continue If True, the while loop runs only if a Boolean Value which is provided to the Conditional Terminal is true.

About the configuration for the Conditional Terminal
  The left picture is Stop If True. When set to it, the while loop runs only if value is false. 

Otherwise,

  The left picture is Continue If True. When set to it, the while loop runs only if value is true.
To switch the Conditional Terminal, you have to click a right button on the Conditional Terminal


The most important things for an while loop is the time to decide the Conditional Terminal is true or not. An While Loop make this decision after running the algorithm once. An While Loop have to run algorithm at least once.

The below picture show and make code for the While Loop to repeat 5 times. 




2) For Loops

A For Loop is a statement to repeat N times. N is the terminal which refers the number of the iteration.  You also  add conditional terminal to For when you use above LabVIEW 2012. 


You can find a For Loop as same method to add an While Loop. 
A For Loop is like a below picture.
  • Counter Terminal(N) : It defines the number of the iteration to run.
  • Iteration Terminal: It defines the number of the iteration which is running. 
As I mentioned, User can add the Conditional Terminal in above LabVIEW 2012. In order to use it, you have to click right-button of you mouse on selected a For Loop.


It this is checked, A For Loop is changed to below picture. At that time, the iteration will ends up when the Conditional Terminal is true or iteration is executed N times.


The most important thing in a For Loop is that this loop have to be executed N times. When N is 0, this loop is not executed. That is big difference between an While Loop and a For Loop.

While Loop is executed at least once. But For Loop can not be executed. 

The below picture show the code that executed 5 times.



This article tell you the introduction and difference for an While and For Loop.