LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Motion Reconstruction using LabVIEW

Solved!
Go to solution
Solution
Accepted by topic author Nabil208

I've not done much with 3D plots in LabVIEW, so I thought I'd give this a try.  Your CSV, as you describe, has 7 columns.  The first we ignore, the next three are X, Y, Z for line 1, the last three are X, Y, Z for line 2.  So we want to do the following:

  1. Read Delimited Spreadsheet, remembering to change the Separator character to a comma.  Connect output temporarily to Indicator to make sure we have 7 columns, multiple rows.
  2. Use Delete from Array to get rid of the first Column.  Again, use temporary indicator to check.
  3. Pass through a For Loop and a six-element Index Array to create 6 1D arrays that will be X1, Y1, Z1, X2, Y2, Z2.
  4. Drop 3D Plot on Front Panel.
  5. Connect X1, Y1, Z1 to Plot Line function.  Verify we get a 3D line.
  6. Drag new copy (Ctrl-Drag) of Plot Line, wire X2, Y2, Z2 to its inputs.
  7. Break the Class Wire connecting first Plot Line function to 3D Plot.  Wire output of first Plot Line function to input of second Plot Line function, wire output of second Plot Line function to 3D Graph.
  8. Run.

3D Graph.png

 

Bob Schor

Message 11 of 32
(1,453 Views)

Hi SaileshK,

 

For the XY graph, I tried to replace it with it, it doesn't connect and it shows the source is 2D array and the sink is 1D array of 2 cluster element.

Plus, the XY graph only shows static plot. I need the plot that are moving base on the values of X,Y,Z in the spreadsheet file.

Column 1 in the spreadsheet is the number of frames. Each frame shows the X,Y,Z value of each object. I need a graph that updates the plots base on the value of each frame.

0 Kudos
Message 12 of 32
(1,450 Views)

Hi Bob Schor,

May I see the block diagram, a screenshot should be fine.

 

 

0 Kudos
Message 13 of 32
(1,449 Views)

Hi Bob Schor,

This is what I got after following the steps you give.

Download All
0 Kudos
Message 14 of 32
(1,443 Views)

That's very close.  Do us all a Very Big Favor and do not attach pictures, but attach actual VIs (that we can edit, correct, test, etc.).  I can't tell what version of LabVIEW you have (but I could from the VI, hint, hint), but I'm guessing it is several years old, as the Read Delimited Spreadsheet function looks different, but should work.

 

In Step 3, normally when you bring an Array into a For loop, the Input tunnel, by default, is an indexing tunnel.  That's what you want -- it will take your 2D array of Rows and Columns and give you just a Row-at-a-time.  When you bring the Row into an Index Array function (similar to what you did), it will break the 1D array into six Dbls, which you bring out of the For Loop (again, through the default Indexing Tunnels.  You now have the six 1D (X1, Y1, Z1, X2, Y2, Z2) arrays you need.  The For loop does not need a Wait -- it will take microseconds, which is just fine.

 

So you now have 6 1D Arrays.  You've almost wired the two Plot Line functions correctly, but Step 7 says that the Class output of the first one goes to the Class input of the second (you've wired input to input).  This last step occurs outside the For loop.

 

Did that Solve Your Problem?

 

Bob Schor

 

0 Kudos
Message 15 of 32
(1,416 Views)

Hi Bob Schor,

 

Sorry for not giving the VI, and my labVIEW version is LabVIEW 2013.

 

It is now works, thank you. However, there is one more little thing that I need. I want it moving to show how the line created,  to know where it starts and ends. Or maybe that looks like a video of motion.

 

Attached is the VI that maybe you can check for me if it is correct.

0 Kudos
Message 16 of 32
(1,408 Views)

I checked it for you.  It is not correct.  I told you exactly how to fix it, but you apparently didn't know about Arrays, For Loops, and Indexing Tunnels.  Please read this, from the "Getting Started with LabVIEW" Introductory material at the beginning of this Forum.  You really need to spend a little more time learning the simplest, most basic parts of LabVIEW before trying to do 3D plotting, especially 3D plotting where Time in involved.

  • What is the purpose of the For Loop, with 1 wired to the Count ("N")?  
  • Suppose you removed the For Loop, but left all the rest of the code there.  How would the Program change when you run it?
  • Once you understand the answer to the second point, think again about the first point.
  • How many points do you expect to be plotted?
  • What does the Wait function do in your code?  What difference would it make if you removed it?

Bob Schor

 

P.S. -- The code I described draws the two 3-D Graphs "as fast as possible", i.e. "all at once".  I thought it would be trivial to make the routine into a Movie -- it isn't really difficult, but it is also not trivial, and one can easily go astray (as I did twice).  Once you master the "All-at-once" (by following the directions I provided, thereby learning about For Loops, Arrays, and Indexing Tunnels), we can discuss how to turn the code into a Movie.

Message 17 of 32
(1,399 Views)

Hi Bob Schor,

 

Sorry I sent you the wrong VI, my mistake. Attached is the one I have been working on.

 

 

0 Kudos
Message 18 of 32
(1,393 Views)

That looks like what I was describing (my code is on my laptop, at home ...).  Does it give you a 3D Plot that "looks OK"?  If so, mark one (or more?) of my suggestions as the Solution (only you, the Original Poster, can designate a Solution, which helps other Forum users "know" that an Answer exists).

 

Bob Schor

Message 19 of 32
(1,379 Views)

Hi Bob Schor,

 

Yes, it shows the same output as yours. Thank you!!.

However, maybe we can discuss on making the drawing like a video as soon as possible.

0 Kudos
Message 20 of 32
(1,366 Views)