03-20-2009 11:18 PM
Hi,
What I am trying to do is plot in an XY graph some values where the x axis contains the elapsed time. When the elapsed time reaches a certain value my Y value will be for eg: 5. Rest of the time the value of Y will be '0'. I have attached my VI. But when I run the program the value plotted is always '0'.
Kindly help me with this.
Thanks!
Chathuri
03-20-2009 11:41 PM - edited 03-20-2009 11:50 PM
First, you need to fix the faulty code. If you hit the OK button, things start running, but there is no way to end the program because you have an infinite loop inside the OK Button's event case. The only way to stop the VI is by hitting the abort button. What should cause the OK button event case to stop?
In your Plot Value Event case, you could just replace the while loop with an auto indexing For loop.
Beyond that, I don't know what you are trying to do. It looks like you have some relationship between the two graphs but it just doesn't make sense.
I think the true case of your upper case structure will almost never execute. You are changing the x position of your XY graph based on an elapsed time. In the next iteration, if that new cursor X position matches the cursor X position on the Gait graph, then you execute the true case. But when you are comparing two double numerics, how often do you think those two values will ever be equal. If you want to hit let's say 3. On on iteration your X could be 2.999 and on the next iteration 2 milliseconds later, your new X position will be 3.001
03-21-2009 12:34 AM
Ya I did realise that that the while loop doest not stop executing. What I want to do with the while loop is to run it until the OK button is true. This doesnt work.
As for inside the while loop, the steps for executing the program is as follows :
Step 1 : First read from a spreadsheet to plot some values on the gait phase graph.
Step 2 : Once that plot is plotted, I will move the cursor of gait phase graph to let's say 3.2
Step 3 : I will set the FES magnitude to let's say 5.
Step 4 :Then when I press the OK button,
In OK button event structure, I want to run the cursor of the XY graph through the graph, with the x values equal to the time elapsed. The y values will always be '0' UNLESS that 'x' value of the XY graph cursor is the same as the gait phase cursor.
You can ignore the bottom case structure. But you say that the true condition of the above case structure may never executed. I understand what happened. Thanks for that tip.
So how would i then obtain by objective ? Any ideas would be greatly appreciated.
Regards,
Chathuri
03-21-2009 12:16 PM
For your OK button, move it inside the while loop in the event structure so that is read on every iteration. In general, it is a bad idea to have an event structure where code will run for awhile inside of an event. As long as that OK button is true, the code will stay inside that particular event. Pressing other buttons will queue up other events, but they can't be executed until the event you are in ends. Thus the better move would be use a producer/consumer (with events) structure (Look under File, New.....) to separate the event structure from the rest of your code.
For your conditions for your graphs, perhaps you want to set the condition as either >= or <= instead of just =?