LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

structure inside while should work only one time ?

Hi Everyone ,

                  I have coded a program that if i click a button ( switch untill released) . inside that structure should work only one times . 

                  and i have coded and its working fine .. but its looks compilcated..

                   i need some simple solution . Plz help me guys 

0 Kudos
Message 1 of 12
(4,097 Views)

Please attach the code in 2012 version.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 12
(4,074 Views)

Hi saran,

 

yes, using local variables is too complicated when shift register (or feedbacknode) will do the same!

 

THINK DATAFLOW!

 

check.png

- use proper datatypes: when you just need a counter use an integer instead of floats!

- you can connect integers directly to case structure selector input!

Note1: your indicator "F01_***" should be located outside of the case structure…

Note2: there should be a wait function inside of your while loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 12
(4,064 Views)

I agree that it is complicated.  It is also obviously a class assignment.  I'm pretty sure you didn't understand the assignment, but I can't help you with it because you didn't tell us the exact wording of your homework.

 

If your goal is for you to learn LabVIEW, then my advice is to do your own work and talk to your teacher(s) and classmates.  In addition, look at the numerous "Getting started with LabVIEW" tutorials, on-line lessons, etc., and work the examples.  You can also write little programs for yourself, experimenting with different ways of doing things.

 

If you are experimenting, something you might find instructive (particularly for "little programs") is to go to the Block Diagram, turn on "Highlight Execution" (the fifth symbol on the Toolbar, looks like a light bulb), and then run your code while the Block Diagram is visible.  LabVIEW works by Data Flow, and this will illustrate the data flowing through your program (it's kind of fun to watch, too).

 

Bob Schor

0 Kudos
Message 4 of 12
(4,035 Views)

saran1988 wrote:

                  I have coded a program that if i click a button ( switch untill released) . inside that structure should work only one times . 

                  and i have coded and its working fine .. but its looks compilcated..

                   i need some simple solution . Plz help me guys 


Your code has very little to do with what you are describing.

 

  • There is no button with "switch until released" mechanical action. (OK is switch when released, stop is latch when released)
  • A case structure always "works". Are you saying that it should execute e.g. the true case only once whenever the outer case goes from false to true??
  • Your inner case goes true more than once per run of the program (whenever the OK goes true). If it should really only work once overall, use the "first call?" primitive. You need to formulate the problem using less ambiguous words.
  • There is no obvious starting state for the boolean that you read via local variables. How do you ensure that it start with a known value? Does it matter?
  • You seem to entirely deal with integers, so why are you using floating point representation for the numerics?
  • What is the purpose of the orange numeric indicator. Is it just a kludge for your logic or does its value mean anything?
  • Why does your loop not contain any wait?
  • At this point, you should learn about shift registers. It would eliminate all your local variables.
  • ...
0 Kudos
Message 5 of 12
(4,024 Views)

HI , 

 

         is it possible to do without incrementing (+1) , 

         beasuse inside that loop i am going to use three case structures each souldworks only on time when i press button.

0 Kudos
Message 6 of 12
(3,994 Views)

saran1988 wrote:

         is it possible to do without incrementing (+1) , 


Yes, of course.

0 Kudos
Message 7 of 12
(3,979 Views)

@SaranVenkateshS wrote:

Hi Everyone ,

                  I have coded a program that if i click a button ( switch untill released) . inside that structure should work only one times .  


Primary Rule with Boolesns:-

 

If you want something to work once & only once, go for Latching Mech Action (default action when you drop a Bool button like STOP/OK/Cancel). Once the code reads the Bool button's value, the button will automatically return to its original state. But you can't have local variable for Latch action booleans.

 

Another method to make something work once & only once is, to use Event Structures with the Boolean button's Value Change event.

 

So, start reading more about Boolean Mech Actions (Latch & Switch), and about Event Structures using LabVIEW Help. And, try them out by yourself, as already suggested by many of us.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 8 of 12
(3,925 Views)

HI 

0 Kudos
Message 9 of 12
(3,922 Views)

@parthabe wrote:
Primary Rule with Boolesns:-

None of these have anything to do with the problem here. He has an outer case structure connected to a switch action boolean. Inside the true case is another case structure that should only be true whenever the outer boolean just turned true.

 

To possible solutions without using any numerics:

  1.  Use a feeback node on the switch and see if the new value is true while the previous value is false (e.g. using a greater than comparison). If this is true, execute the inner case, else not.
  2. Use a boolean in a shift register. Set it to true in the false case of the outer case structure and set it to false in the true case.

 

 

0 Kudos
Message 10 of 12
(3,908 Views)