12-24-2019 10:51 PM
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!
12-24-2019 11:54 PM - edited 12-25-2019 12:03 AM
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
12-25-2019 01:35 AM - edited 12-25-2019 01:35 AM
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! 🙂
12-25-2019 09:25 AM
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".
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
12-25-2019 11:08 AM
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()
12-25-2019 12:53 PM
@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:
12-25-2019 01:21 PM
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.
12-25-2019 03:26 PM
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.
12-25-2019 06:08 PM
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.
12-25-2019 06:14 PM - edited 12-25-2019 06:18 PM
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.