LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

beginner need help

Solved!
Go to solution

Hi everyone,

I just start learning Labview, how can i write a while loop to do a = a +1 and this loop will stop when ''a'' equals a certain number?

I know this is pretty silly question but i can not do it since labview is unlike other programming languages, it has numeric control and numeric indicator.

Thanks for your help

0 Kudos
Message 1 of 9
(2,764 Views)
Solution
Accepted by topic author joenguyen0109

Hi Joe,

 

how can i write a while loop to do a = a +1 and this loop will stop when ''a'' equals a certain number?

You need a WHILE loop, a shift register and a comparison function. That's it.

Basic LabVIEW stuff: you don't use "variables" like in textual programming. The wire is the variable!

 

What have you tried so far?

Where are you stuck?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,754 Views)

Thank you for your help,

I have searched it up on internet and i'm able to perform a = a + 1 by using "Local variable" and while loop. However, i tried to stop when a == 20 by using comparison and connect that comparison straight to the loop condition button but it doesn't really work.

0 Kudos
Message 3 of 9
(2,742 Views)
Solution
Accepted by topic author joenguyen0109

hi joenguyen0109

this vil will help youbasic while loop.PNG

 

Just create 2 numeric controls on front panel and use this in block diagram.


CLD Using LabVIEW since 2013
Message 4 of 9
(2,739 Views)

Hi Joe,

 

However, i tried to…

Whenever your VI does not work like intended you should attach that VI instead of writing some words on the required behaviour!

How should we tell you where you did wrong? How do you want to learn from your errors if you don't know them?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(2,723 Views)

@kartiknattar wrote:

hi joenguyen0109

this vil will help youbasic while loop.PNG

 

Just create 2 numeric controls on front panel and use this in block diagram.


I guess you just solved his homework problem.

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 9
(2,707 Views)
I struggle with the balance between helping new coders understand data flow and giving them the solution flat out. When I started with labVIEW I always looked for example code to visualize the language. Was that wrong? I’d suggest the best way to help new coders would be to explain the theory/principle OR show the most efficient pattern to solve the problem. This way juniors can get the best of both worlds. It irks me to no end how we tend to pounce on our young for asking basic questions by assuming they are trying to just get their homework done. EVEN IF the OP is a student, showing the solution for a graphical language isn’t a bad thing. I’m sure I’m not the only one who’s stared at LV code and still took time to think through the data flow. Perhaps sharing efficient code could lead to a community of LV devs with less spaghetti code in the ecosystem; and a heck of a lot less refactoring for seniors.
0 Kudos
Message 7 of 9
(2,693 Views)

Hi everyone, thank you for you guys's advice. I'm in the first year of uni and this is nothing to do with my homework. I was working on java and c but then my uncle told me to learn labView so i can be his assistant and as i learnt about for loop and while loop, i just try to write simple a programming to gain more understanding and this is what i tried to do today. Thank you for your help.

Untitled.png

0 Kudos
Message 8 of 9
(2,682 Views)

@Debrosse wrote:
I struggle with the balance between helping new coders understand data flow and giving them the solution flat out. When I started with labVIEW I always looked for example code to visualize the language. Was that wrong? I’d suggest the best way to help new coders would be to explain the theory/principle OR show the most efficient pattern to solve the problem. This way juniors can get the best of both worlds. It irks me to no end how we tend to pounce on our young for asking basic questions by assuming they are trying to just get their homework done. EVEN IF the OP is a student, showing the solution for a graphical language isn’t a bad thing. I’m sure I’m not the only one who’s stared at LV code and still took time to think through the data flow. Perhaps sharing efficient code could lead to a community of LV devs with less spaghetti code in the ecosystem; and a heck of a lot less refactoring for seniors.

Of course showing the solution to someone's homework is a bad thing.  You learn nothing from copying the answers from the back of the book.  But if you can coax the student arriving at a solution themselves by coaching them, well then they've accomplished the goal of the homework question by understanding how they arrived at the solution.  Providing a solution should only be used as a forensics exercise to dissect exactly where you went wrong if you couldn't actually solve the homework problem.

 

What happens is you end up with a bunch of "developers" who don't think for themselves and are dependent on the forum to provide solutions to simple problems.  You know the old saying about teaching a man to fish, etc., etc.  Code exchanges are for seasoned developers to share code to avoid re-inventing a wheel that someone has already invented and should not be used as a substitute for developing good (LabVIEW) habits.

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 9
(2,606 Views)