LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Blink LED N times

Hello everybody! 

I'm very new to LabView so I need so help from the community. 

I have a project that I need to prepare, and before I move to the project I need write a simple .vi program that will basically mimic the final project in future.

 

Now I'm trying to write a program that will blink LED N number of times. N is the number that I will specify as a numerical value. 

Could you please help me with that? Either point me where to look for some clues or maybe provide some advice?

 

Thank you!

0 Kudos
Message 1 of 12
(5,600 Views)

Hi Mech,

It is best that you start with LabVIEW fundamentals before proceeding on, especially with the concept of 'Dataflow' in LabVIEW. You could look at the Free Academic Training on LabVIEW for students at this link http://www.ni.com/academic/students/learn/

Just a pointer, you could use a property node, modify the boolean indicator to make it 'blink'.

Hope this helps

 

0 Kudos
Message 2 of 12
(5,566 Views)

It is clear to me that you do understand that we won't do your homework for you, but if you make use of the training links on the main forum page, write some code and show it to us, we'd be glad to help!  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 12
(5,551 Views)

I assume you have some familiarity with programming.  You may have noticed that LabVIEW differs from other systems you might know (e.g. Matlab, or C++) in that it talks about "real-world concepts", like "blink an LED".

  • What ideas (not traditional in other programming languages) does "blink" make you think about?
  • What operation(s) does a "blink" require?
  • What operation(s) does the modifier "N times" make you think about?

While you are reviewing the LabVIEW Tutorial material (or your lecture notes from your classes), do you see anything that seems relevant to the questions raised above?  Have you learned about (and do you understand) the Principle of Data Flow, the central "rule" governing LabVIEW Programming?

 

Bob Schor

0 Kudos
Message 4 of 12
(5,431 Views)

Thanks to everyone replied! 

I know that you guys are not going do my homework and I'm not asking for that. Basically when I opened LabView I got lost. So I decided to ask for some guidance  🙂

 

I'm going through the tutorials now familiarizing myself with basics. 

The idea of the project if to shoot LED 3 times and then release a valve. I don't have NI board yet, so I'm practicing with LabView suite for now. 

 

If I were using python and I had a lets say "LED" class with "blink_led_one" and "blink_led_two methods, I would write something like that:

x = int(input()) # number of blinks for the first LED

counter = 0

for b in range x:

     LED.blink_led_one()

     counter += 1

if counter == x:

     LED.blink_led_two()

 

0 Kudos
Message 5 of 12
(5,412 Views)

@Mech314 wrote:

Thanks to everyone replied! 

I know that you guys are not going do my homework and I'm not asking for that. Basically when I opened LabView I got lost. So I decided to ask for some guidance  🙂

 

I'm going through the tutorials now familiarizing myself with basics. 

The idea of the project if to shoot LED 3 times and then release a valve. I don't have NI board yet, so I'm practicing with LabView suite for now. 

 

If I were using python and I had a lets say "LED" class with "blink_led_one" and "blink_led_two methods, I would write something like that:

x = int(input()) # number of blinks for the first LED

counter = 0

for b in range x:

     LED.blink_led_one()

     counter += 1

if counter == x:

     LED.blink_led_two()

 


Okay, so here is how I would approach this:

 

I would define what a "blink" is.  To me, a "blink" is LED on (for a period of time to be determined (TBD), followed by LED "off" (again, for a period of time TBD, most likely for the same amount of time.)  This implies that we need some kind of timing mechanism.

 

Now you have the requirement that the LED "blinks" three times.  This implies some kind of loop.  Not only does it have to loop, but it also has to stop after the correct amount of iterations.  If you know how many times the loop is supposed to run - and the answer is "yes" - then a FOR loop is more appropriate than a "WHILE" loop, though either will work.

 

See what you can come up with.  Here are some hints:

timing.pngstructures.png

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(5,392 Views)

Thank you for your help! I've learned the sequence structures that allowed me to make one LED blinking. 

Now I need to find how to make a counter that will turn on second LED. 

0 Kudos
Message 7 of 12
(5,382 Views)

Alright, I managed to write the program that works as I wanted in the beginning. 

However, I still have two question. 

1) I created the shift register for For loop that starts at 0 and every iteration adds 1 to the register and outputs the number of iterations. If I place a numeric indicator it shows 3 iterations as I indicated. However, when I compare shift register value to the original numeric value that defines number of iterations I get False. If I change my shift register to start from 1, I get True in the comparison. It doesn't make sense to me, could you please explain that? 

 

2) Next step for me is to change this program so it will actually send command to NI board. I assume I need to us niDAQ assistant in Output section, is that right? I don't know yet how to use niDAQ but I assume I will be able to choose pulse width and frequency? Am I right? 

I will get the board after the New Year so I will probably continue working at the beginning of January. 

 

0 Kudos
Message 8 of 12
(5,365 Views)

That's actually not too bad.  For performance, I would choose a local variable over a property node, but you have the general idea.  I don't understand the purpose of the second LED.  Tell me more about it.  As it is, it doesn't quite make sense.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 12
(5,325 Views)

Thank you!

Well, the real program will control the LED and a valve. 

LED will illuminate my sample N number of times, once last flash of LED has been done program will open the valve with LN2 to freeze it. 

 

Here both LEDs are just mimicking the real program for practicing purpose because I had no idea how to write with LabView. 

0 Kudos
Message 10 of 12
(5,322 Views)