LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with second frame in flat sequence, it is not taking boolean inputs in to the while loop

sir, i understood it. its a local varaible you have created for those indicators. but what is the need for 3 Invoke nodes you have placed outside while loop

0 Kudos
Message 11 of 26
(1,070 Views)

the nodes i mentioned outside while loop are required to initialize the variables when program is executed. when you stop a vi and then start it again the values of varaibles if not intialize properly will be last one you stop your vi. i hope you understand my point.

0 Kudos
Message 12 of 26
(1,064 Views)

Tirmizi: You have been told this before, but don't use sequence structures when instruction new LabVIEW users.

Also try not to use local variables, use data flow. 

 

So I took your VI and made it without the sequence structure and without local variables.

Can you see the difference?

 

There is one more problem in your VI that you have, and that I didn't fixed. You have 2 controls with the same name.

Don't do that. Are you trying to confuse the OP?

0 Kudos
Message 13 of 26
(1,058 Views)

so then what is the use of flat sequence, if you answer my query in simple manner  then it will help me alot instead of refereing me to launch my query in other forum.

 

in your modified vi , the case struct dealing with  gate 1 and 2 will also run in parallel with other structs in while loop. in case if oone of these two sensors malfunctinoed and give you boolean 1 when the train is crossing start sensor (this means far behind) what will happen. these sensors are used to operate servo value. please refer to the vi orignally attaached by the app.

 

so why i put them in last of frame to get confirmed that if train has crossed start and stop buttons and speed has been calcualted  then after this we check these sensors.


the similar name of these two varialbes named start (one is control and other is indicator ) is by mistake .

 

one more thing you removed the reinitialization of variables outside the while loop. i would be appreciated if you also give me the reason for this as i have faced these problems of reinitialization of variables during my development alot and i found this solution of reinitialization of variable at the start of your code once.

 

i run the vi you modified and it is not giving me speed output.the sequence of my vi as i understand from the orignal one is as follows

 

1   as train passed the start button/sensor , generate start boolean=1

2. this will start the counter

3. when train passes stop sensor , the start boolean set to 0. this stops the counter, the count value is mul with value of delay and time in sec calculate and from there speed as well

 

but your modified vi is not working as i pressed the stop button the speed value should be calc but it is showing nothing

snapshot of front panel is attached for your ref

 

 

reagrds

0 Kudos
Message 14 of 26
(1,053 Views)

Okay, I was a bit to fast, didn't check the function of the VI. Made the correction so it is working in the same maner as yours.

 

Now to all your questions


@Tirmizi wrote:

so then what is the use of flat sequence, if you answer my query in simple manner  then it will help me alot instead of refereing me to launch my query in other forum.

 


When you have the posibility to use the data flow / data going on the wire, to ensure that functions are used in a order, you should use the data flow.
Sequence Structures can help you on that, yes. But in most cases for new users, a simpel wire can and will do the trick.
When you get used to using wires and data flow most of the other problems you have in the code goes away.


@Tirmizi wrote:

in your modified vi , the case struct dealing with  gate 1 and 2 will also run in parallel with other structs in while loop. in case if oone of these two sensors malfunctinoed and give you boolean 1 when the train is crossing start sensor (this means far behind) what will happen. these sensors are used to operate servo value. please refer to the vi orignally attaached by the app.

 

so why i put them in last of frame to get confirmed that if train has crossed start and stop buttons and speed has been calcualted  then after this we check these sensors.

 


I think you are not understanding your own code and the way the sequence structure works.
In your code, the gate 1 and 2 controls are check every while loop iterration, no matter if the speed has been calculated or not.
You can check that with a little debuging with the Highlight Execution turned on.

The original code from the OP is doing that, correct. But in that code there are two while loops. The first while loop has to complete before the second while loop is runing.

The problem with that code was the Event structure, nothing else. But your code DO NOT use two while loops or an Event structure.

 


@Tirmizi wrote:

the similar name of these two varialbes named start (one is control and other is indicator ) is by mistake .

 

one more thing you removed the reinitialization of variables outside the while loop. i would be appreciated if you also give me the reason for this as i have faced these problems of reinitialization of variables during my development alot and i found this solution of reinitialization of variable at the start of your code once. 


I removed the reinitialization because I don't need it. There is no Local variables in my code.
As part of using Local variables there are some downsides. One downside is that the control or indicator can start with an old or unexpected value. This can cause your code to behave bad, as you have faced in your code.
One way to fix that is to use the reinitialization function, or write the expected start value to another local vairable of the control.

 

As a new user, you should forget about local variables and learn to code without them. Use the data flow/wires for storing data, as this is the propper way in LabVIEW.

As a new user, you offen don't know the downside of using Local and Global variables, and if you are not carefull they can hit you.

The same goes for sequence structures. If you as a new user starts to use them as a standard, you will never learn the "right" way to code LabVIEW/Data flow programs. 


In most of my programs that is with 500+ VI's and classes, I have zero local and global variables and a limited number of single frame sequence structures. It is possible to program large application without them.

 

I hope this answers some of your questions.

0 Kudos
Message 15 of 26
(1,038 Views)

thanks for your reply. can you send me some examples which deals with the usefulness of flat structures. Smiley Happy

 

regards

0 Kudos
Message 16 of 26
(1,034 Views)

 

This is a quick example.

 

Single Frame Wait.png

 

To be able to use the power of data flow, we need to use a single frame sequence structure.

As the Wait has no Error cluster in and out, and we want to force the wait between two writes to file, this is one of the options.

 

An other option would be to put the Wait(ms) function in a sub-vi with Error cluster going in and out of the sub-vi.

 

But a more correct way could be:

Error Frame Wait.png

 

This will prevent a long wait if there was an error before.

But it all depends on what you want to do.

Message 17 of 26
(1,025 Views)

tirimiz, dkfire:  thanks for your suggestions , i will try your methods and and continue my task. i will avoid using event structure and flat sequences. but i didnt get why many tell to avoid using flat sequences.

0 Kudos
Message 18 of 26
(1,001 Views)

sir i tried to implement the same which u suggested in labview 7.1 but when stop button is pressed the "calculated speed and time value are not holding values" what mistake am i doing. what should i do to hold the values

0 Kudos
Message 19 of 26
(982 Views)

when i run in the debug mode its showing fine i.e the calculated value is holidng and when i observed it with probe its shows not exected, but when i run as normal its calculating the speed but updating to infinity again. why so ?

0 Kudos
Message 20 of 26
(976 Views)