LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Constructing an XY graph based on a pre-determined number of coordinates

I know what I am trying to construct, but I just cant quite imagine what the script will look like

 

I want the user to be able to enter a set of coordinates and each time they are entered they are instantly plot onto an xy graph.

Then two new numeric controls are accessable to enter another pair of cordinates. This will keep looping until the final coordinates

match the initial coordinates.

 

Plotting the points isnt the problem, its just this data entry problem.

 

Any advice greatly appriciated! Thanks

0 Kudos
Message 1 of 9
(3,698 Views)

Hi Woody2230,

 

From what I understand from your statements it should be something as below?:

  1. Since it is to be looping in an iteration, a while loop is needed
  2. Within the while loop, there is a input for you to enter the XY coordinates. The XY coordinates is to be entered to the XY graph only if you press the enter push button. 
  3. If push button is pressed to enter the coordinates, the current coordinates you enter is append together with the previous coordinates to the XY graph. Else, the previous value is to be inherited to the next loop.
  4. Since I need to inherit the previous data and the current data between loops, I need to use shift registers.
  5. At the mean time, I used a Search 1D array to search if the initial coordinates is the same as the final coordinates. Usually from my point of view, the initial coordinates should be at the index 0. If it is not within the array, it should show the value as -1. 
  6. I have added an additional condition to specify further if the coordinates I entered is the final coordinates.
  7. If the final coordinates is the same as the initial coordinates, should stop the loop. You can also manually stop the loop.

plot xy coordinates.JPG

plot xy coordinates2.JPG

 

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 2 of 9
(3,679 Views)

Hi Lennard,

 

Thank you so much for your help! Thats a great solution

 

I now want to employ a previous program I wrote into this one. The previous program relied on only three coordinates and then

when the program was run a small marker would smoothly move between the points

 

I want to now try and make a marker smoothly run between the users many inputted points

 

I have attached the vi's of both programs to make my explanation clearer

Download All
0 Kudos
Message 3 of 9
(3,636 Views)

Hi Woody2230,

 

You're welcome. I'm currently looking at the 3 coordinates.vi. May I ask if you can explain how the code (3 coordinates.vi) works? Which part of the function do you want to inplement the plot points.vi into the 3 coordinates.vi? What does the change direction supposed to do in the code (3 coordinates.vi) operation?

 

Thanks

 

Warmest regards,

Lennard.C

 

Learning new things everyday...
0 Kudos
Message 4 of 9
(3,621 Views)

Hi Lennard,

 

The change direction alters the case structure, in which there is the same stacked sequence however it is stacked in the reverse order.

 

I have almost managed to create a full solution to my problem. I have used a stacked structure to allow the user to first set all the coordinates and then in the next frame the function draws them. Everything should works, however I have my source and sink in the wrong format and am unsure how to solve.

 

Please take a look and let me know. No doubt the solution is glaringly obvious

 

 

Many Thanks

0 Kudos
Message 5 of 9
(3,616 Views)

Hi Woody2230,

 

Does the change direction function is to be used during the vi's execution (ie. you can change direction when the vi is still running)? May I ask what LabVIEW version you're running on? And what are X1, X2 and X3. Which is the latest coordinate and the initial?

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 6 of 9
(3,602 Views)

Woody,

 

You do not need local variables or sequence structures and you should learn to program in LabVIEW without them. While there are places where they need to be used, those places are rare and very specific.

 

Next, indexing the points cluster with the last value of i is not what you want. Put an indicator on that wire and see how many iterations that loop has run while you are entering a few points! What you should do is to add another shift register with an integer (I32) datatype. Inside the True case (where new coordinate is appended to the array) you increment the integer value. When you exit the loop, the value will be one greater than the index of the last element in the array. Arrays in LabVIEW use zero based indexing. When you index an element that does not exist from an array you get the default value for the element datatype, (0,0) in this case.

 

You may also want to do the search for initial point inside the True case. If the user accidentally enters the initial value while the Final Coordiante? button is pressed, the loop will terminate. 

 

Initializing the shift registers may be a good idea as well unless you want the values saved from one call to the next.

 

Lynn

0 Kudos
Message 7 of 9
(3,599 Views)

Hi Woody,

 

I have tried to integrate the plot points.vi and the 3 coordinates.vi. The result is the attached vi (I saved it as LabVIEW 2012). I believe the screenshots below of the code could explain how it works.  

 

 

Change coor 1.jpg

Change coor 2.jpg

Change coor 3.jpg

 

 

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 8 of 9
(3,585 Views)

This solution needs a 50ms delay in the loop to prevent it from using all the processor time and starving the UI thread, making data entry difficult.  A much better solution would be to use an event structure for entering your data.  Check the LabVIEW examples for details.

0 Kudos
Message 9 of 9
(3,565 Views)