Labview LED control example with switch:tutorial 24




In this tutorial I will explain the working of LabView software with the help of an example projects. The project discussed here is a simple mini project and its implementation is explained with the explanation of every step. I will try to blink an LED in the block diagram with the help of a switch and then blink it multiple times up to a specific number of iterations, or until a specific condition is fulfilled. At the end of the tutorial you are provided with an exercise to do it by yourself, and in the next tutorials I will assume that you have done those exercises and I will not explain the concept regarding them.




Labview LED control example with switch

  • Lets’ work with the LEDs, create a VI as we have done in tutorial 1 and save it for future use by selecting File>>Save as or by pressing <Ctrl+S>. From the control palette i.e. a dropdown by right clicking on the front panel.
  • select Boolean and then select vertical toggle switch as shown in the figure below,Labview LED control example with switch

Figure 1: Vertical toggle switch

  • Now from the control palette on the front panel, select Boolean and then select Round LED as shown in the figure below,Labview LED control example with switch

Figure 2: Round LED

  • Label each of the block on the front panel for convenience as shown in the figure below,Labview LED control example with switch

Figure 3: Labeling




  • Switch will act as a control and the LED will act as an indicator in this case. Connect the output terminal of the switch (control) to the input side of the LED (indicator) as we have been doing from the start. The resulting block diagram will look like the one shown in the figure below,Labview LED control example with switch

Figure 4: Block diagram

  • Now when you run the VI continuously you can control the round LED with the toggle switch. Label the positions of the switch as we have discussed in previous tutorials and also align the blocks as we have been doing.
  • Implement all the tricks you have learned so far in the projects we will be doing in the upcoming tutorials. When the switch is downwards the LED will be off as shown in the figure below,Labview LED control example with switch

Figure 5: Off state of switch

  • VI is running continuously and during the run time change the present state of the switch and the LED will turn on as shown in the figure below,Labview LED control example with switch

Figure 6: On state of switch

  • Now lets’ blink the LED continuously using a ‘for’ loop as we have used in previous tutorial. When the iterative index is even the LED will not glow and when the iterative index is odd the led will turn on.
  • From the function palette select structures and then select for loop as shown in the figure below,Labview LED control example with switch

Figure 7: For loop placement

  • Remove the toggle switch and place the LED inside the loop as shown in the figure below,Labview LED control example with switch

Figure 8: For loop

  • Create a constant at N giving it a value for the loop index. Now we have to set a situation for the LED to turn on and off. From the function palette select Numeric and then select Quotient and remainder, as shown in the figure below,Labview LED control example with switch

Figure 9: Quotient and remainder

  • Connect one input of this block to the iterative index and at the other create a constant of value 2, and at the output place a Not equal to zero block. From the function palette select comparison and then select Not equal to zero? As shown in the figure below,Labview LED control example with switch

Figure 10: Not equal to zero?

  • At the output of this block connect the input of the LED, the resulting block diagram for the even odd condition is shown in the figure below,Labview LED control example with switch

Figure 11: Odd even difference

  • Also place a wait block that will decide the time of iteration. From the function palette select timing and then select wait (ms) as shown in the figure below,Labview LED control example with switch

Figure 12: Wait block

  • At the input side of this block create a constant and set its value to 500 as shown in the figure below,Labview LED control example with switch

Figure 13: Wait block placed

  • Now run the VI continuously and the LED at the front panel will start blinking after each 500ms of time. The loop will complete a single iteration after 500ms and the iterative index will increment by 1 and according to our specified condition when the iterative index is odd the LED will glow. And the iterative index will switch from even to odd number after every 500ms and LED will glow for 0.5 sec and will remain turned off for next 0.5 sec.

Exercise:

  • Using the knowledge you have gained so far design a VI in which the LED will keep on blinking until a stop button is pressed.

(Hint: Try using a while loop)

<< Previous tutorial                                                  Next tutorial>>




Add Comment