LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A real time graphing using boolean keys

Solved!
Go to solution

Hi, I'm generating XY values from (up,down, right,left) booleans (which have predefined values) and plotting them into  XY Graph where I want to draw something like squares etc and I want to define the starting point in the graph itself. I have created an event structure that is triggered when the booleans are pressed, but this results in peaks and troughs only and it plots it with TIME ! which I don't want. I know this is not that hard but I think I'm missing something, if any more details are needed just inform me. Any illustration or help would be appreciated . 

0 Kudos
Message 1 of 11
(3,679 Views)

Well, I certainly don't understand what you want to do!  As I see it, you want to do the following:

  • Record key presses of the up, down, left, and right arrow keys.
  • "Do something" when each key is pressed.

What I don't know is what the "Do something" is supposed to be.  I know that the time of key press is not important (you said so), and I also know that you want to (presumably) "put a point on a graph" each time a key is pressed, but what isn't clear is :

  • The location of the point (absolute, relative to other points, etc).
  • The characteristics of the point (size, color, shape, just points or connected lines, etc.)
  • Any special formatting.

Of course, as I was writing this, the thought occurred to me that you might be using the Arrow Keys as instructions like "Put the next point (left, right, above, below) relative to the previous point".  But I'm not sure, and this also begs the question of where Point 0 goes.

 

Bob Schor

0 Kudos
Message 2 of 11
(3,661 Views)

Hi Bob, sorry for my bad explanation. what I want to register CAN be the arrow keys or some booleans that I created. The motion that I want is actually relative so it starts at the place where the other one finished at and they should be connected so that they can form a sort of a path. One more thing is that I want to specify the starting point in the graph where always starting from (0,0) is not what I want. Hope thins clears it a bit more, thanks.

0 Kudos
Message 3 of 11
(3,648 Views)

@AHmedalnahdi wrote:

 but this results in peaks and troughs only and it plots it with TIME ! which I don't want. 

It Is not clear what you mean by "peaks and troughs" and "time". Instead of telling us what you don't want, you should tell us in detail what you want. Show us pictures. Attach your code.

 

All you need is an event structure to append data to a complex array that stores the data to be graphed and update the graph wenever the data changes. Append a new value that increments/decrements by a delta in either x or y, depending on which arrow button is pressed. Then you also need other events to e.g. add a new plot or move the pen without drawing (e.g. by inserting a NaN before appending the new target point. All this should be trivially easy to do in LabVIEW.

 

However, it might be even simpler to use a intensity graph. Now the 2D array of desired size is fixed (no new memory allocations needed at run time) and if you do the z ramp correctly, you can even change colors. I would try that.

 

Also, what is your LabVIEW version? (if you had attached your code, we would already know!)

0 Kudos
Message 4 of 11
(3,634 Views)

Ah, much clearer.

  • First, you want a Graph, not a Chart -- you will be plotting a connected series of X,Y points that changes as you press the Arrow Keys to add new points.
  • I suggest keeping the points in an Array.  Read about Graphs and decide on the best structure for your array.  Note that you'll be plotting all of the points in your Array each time you add a point.
  • Figure out how you want to choose your first point.  For simplicity, I'm going to assume that all the points are integers, and the Arrow Keys increment or decrement the X or Y coordinate, as appropriate.
  • The algorithm is (almost) obvious, and will be easier if you keep the "Last Point" in a Shift Register.  When an Arrow Key is being processed, take the Last Point and increment or decrement the X or Y coordinate, depending on the Arrow Key pressed.  Make this new Point the new Last Point, add it to the (growing) Array, and replot the Array.
  • Continue until you say "Stop".

Bob Schor

Message 5 of 11
(3,633 Views)
Solution
Accepted by topic author AHmedalnahdi

Maybe something like this? It would be easy to add event cases to move the starting point and such, so this is just to get you started. You could also add a button to undo, e.g. to remove the last added point whenever it is pressed.

 

 

Download All
Message 6 of 11
(3,620 Views)

Thanks 

0 Kudos
Message 7 of 11
(3,608 Views)

XY graphs accept a variety of datatypes. Simply wire the complex array directly to your graph terminal and it will magically turn orange and adapt. Try it!

 

(And please: don't attach a VI with the same name as my VI. If you make changes, be respecful and give it a new name! ALso, what's with the disorganized whitespace you added in the right side of the loop and with the autoidexing output tunnel that goes nowhere?)

0 Kudos
Message 8 of 11
(3,606 Views)

Ohh how did I miss that xD. Thanks a lot you're a life saver 😄

0 Kudos
Message 9 of 11
(3,600 Views)

.

0 Kudos
Message 10 of 11
(3,599 Views)