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.

댓글 없음:

댓글 쓰기