09-17-2008 09:05 AM
The problem is the mechanical action of the button. Once you've pressed it to True it remains true, which means the VI is always generating data, and ignoring the other controls. If you run the VI with highlighting on you would see this.
If you want to use a button to generate data you should incorporate the button into your event structure rather than the way you're doing. Use a standard rectangular button with the default Latch When Released mechanical action. Create an event for it, and in the event case generate your data. This is a much cleaner way to do it, and it does not require the shift register for the Boolean value.
09-17-2008 09:30 AM
That is what i want. i want to generate data till the Boolean is TRUE. and when i set it to FLASE, it should display the latest vlues on the graph.
Yes, i admit creating an event for generating data is a better way to perform the task.
but still i want to know why my program is behaving so weird.
When the Boolean is TRUE, and if i move the mouse anywhere on the screen else the graph it works Perfect. but, just when i move the mouse over the graph, it stucks.
Thanks,
Ritesh
09-17-2008 09:52 AM
ritesh024 wrote:but still i want to know why my program is behaving so weird.
Did you read what I said? Furthermore, with the Boolean set to True you have a greedy loop.
Place the data generation inside the Timeout case. You still don't need that Boolean shift register.
09-17-2008 03:31 PM
@smercurio_fc wrote:
Did you read what I said? Furthermore, with the Boolean set to True you have a greedy loop.
Ofcourse i looked at what you wrote.
But somewhere i feel you are not getting what i want to convey.
I dont think there is any problem with the Boolean Control. If i switch it to TRUE and to FALSE, it works absolutely fine. Only problem occurs when the it is TRUE and then i move the cursor on the Graph. after that the program just hangs. not just Boolean, i cant even stop the VI using STOP button.
But if i dont move or take the cursor on the graph and keep switching the Boolean from TRUE to FALSE and vice-versa, it works perfectly fine.
I am not getting why only afer taking the cursor on the graph the program hangs.
I hope i have made things more clearer. And if in the previous posts you have been trying to answer the same thing, then probably i am not able to get what you want to say.
and i also hope that if there's any communication gap occuring between us it will be bridged in this post. 
Thanks,
Ritesh
09-17-2008 03:44 PM
I understood what you said perfectly fine.
I saw what was happening by looking at the code. The only way I can convince you that what I'm saying is correct is to have you run the code in highlight mode. Have you tried this? You will see exactly what is happening.
To make it easier, replace the for loop with a few Initialize Array functions. This is so you don't have to watch the loop iterate 50 times.
The reason why it works "perfectly fine" when you switch the Boolean from True to False is that in the False case you have the event structure back, which listens to the buttons. In the True case there is no event structure, and therefore clicking on the Stop button will do absolutely nothing. To you it seems hung, but it's not - it's running the loop as fast as it can (hence my previous comment about the greedy loop).
09-18-2008 03:12 PM
smercurio_fc wrote:The reason why it works "perfectly fine" when you switch the Boolean from True to False is that in the False case you have the event structure back, which listens to the buttons. In the True case there is no event structure, and therefore clicking on the Stop button will do absolutely nothing. To you it seems hung, but it's not - it's running the loop as fast as it can (hence my previous comment about the greedy loop).
Thats what i feel the program should do.
But that is not the case.
Even when the Boolean is TRUE, it is listening to the Controls. See, when the Boolean is TRUE, i can set it to FALSE and then TRUE N number of time provided i dont take the cursor on the graph when the Boolean is TRUE. The program only hangs when "Boolean is True AND i take the cursor on the Graph". This is something which is really Weird to me.
And yes, i know its not Hung. its running very fast as i can see the data getting plot on the graph. But, why i cant STOP it with Boolean.
Why only when i take the Corsor on the Graph, the behaviour changes.
I have tried seeing it with "Highlight Execution" ON, but i aint getting why does the Boolean stops responding when i take the cursor on the Graph.
I hope the things are pretty much clear. If still you think there is some gap, i would upload the video showing u visually what exactly i want to say.
Thanks,
Ritesh
09-19-2008 09:32 AM
OK. Now I understand what you're referring to. Sorry, sometimes my head is too dense.
Everything that I said above is true. The problem you are seeing is something different. The issue is that your event structure is fighting with your loop. Your event structure has registered events. The problem is that when those events occur there's nothing to handle them, and your front panel is locked. It has nothing to do with the graph. In fact, if you delete the event cases dealing with the graph you will see the same thing happen if you have the switch set to True and you try to press the Stop button.
The proper way to handle this is to do what I said: incorporate the data generation within your event structure so your events can be handled properly. The easiest way is to simply put the data generation in your timeout case. In other words, instead of having the case structure around the entire event structure, place it inside the Timeout event.
09-22-2008 07:06 AM
Thanks Smercurio_fc.
atlast you got my words and i got the solution i was looking for. 
i thought that events will occur only if it goes into that event structure. I knew i was wrong, but wasn't getting the right path to look where the fault is. I am glad you answered it perfectly and helped me move to another level of programming in LabVIEW. 
Thanks,
Ritesh