LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing "if" statement in labV

HI,

 

I'm trying to convert an arduino code to labV. I understand that the equivalent to an if statement is a case structure, but apparently I don't understand it very well. I made the program but it didn't work. I provided samples of the program in labV and arduino. Any help will be appreciated.

Download All
0 Kudos
Message 1 of 9
(3,380 Views)

The code for your 'if' looks ok to me. Maybe the issue is somewhere else -- do you need to initialize/configure your sensor?

 

Do some unit tests: Take out the sensor reading, range checking and case structure. Just write a constant value to the output. Are you able to make the LED light up?

 

 

P.S. For a simple case like yours, you can also use the Select function (http://zone.ni.com/reference/en-XX/help/371361F-01/glang/select/) instead of a case structure

 

 

Certified LabVIEW Developer
0 Kudos
Message 2 of 9
(3,371 Views)

Thanks for your quick response. I didnt set the false condition correctly, that was the problem. Now when the sensor read 0 or 1 the LED turn on, when it is not between that range it will turn off.

0 Kudos
Message 3 of 9
(3,360 Views)

Hey danypag.
So, I saw your code. Nothing about your question itself, but I feel I can help you somehow.
How familiar are you to LabVIEW? I mean, your code is quite simple, but you can brush it up and make a more readable program and improve your projects in the future.

Writing your program from left to right, for example, is a good development practice.

If you want, check out this link: Getting Started with NI LabVIEW

 

Please don't get me wrong. I never meant to be rude, ok?

Hope this improve your knowledgement.


Regards!

Mondoni
0 Kudos
Message 4 of 9
(3,351 Views)

Thanx joaopam, i'll consider it.Smiley LOL

0 Kudos
Message 5 of 9
(3,348 Views)

Now the only problem is to make a flag, I made a flag in the arduino program and now that is the only part in the lab view program that I can't figure out.

Any answer would be appreciated.

 

0 Kudos
Message 6 of 9
(3,304 Views)

What will you be doing with the flag? How many values can the flag have?  Typically a boolean would be used for a flag an probably passed from one iteration of the loop to the next via a shift register.  Much more complex implementations are possible depending on your needs.

 

Lynn

0 Kudos
Message 7 of 9
(3,265 Views)

@danypag wrote:

Thanx joaopam, i'll consider it.Smiley LOL



Such a small program is a good candidate to try the Automatic cleanup function (ctrl+U) for a fast fix. I often need to modify the result to get satisfied, but it'll rearrange stuff to flow left-to-right and try to gather controls to the left and indicators to the right. It's a good reference.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(3,249 Views)

Continued in this thread as well:http://forums.ni.com/t5/LabVIEW/How-to-make-a-flag/m-p/2410646#M745090


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 9
(3,220 Views)