02-18-2016 12:33 AM - edited 02-18-2016 12:36 AM
Hello,
I have been developing an VI to control the x-y coordinates of a platform using two motors. A somewhat psedo version of xy-plotter.
The detail I could use help in is the following:
1. I have 469(or 400~ish, there are two modes) discrete points to be initialized/logged into an x-y graph such that a cursor on the x-y graph can snap to the discrete points. This far is done.
2. I have to keep track of the current x-y position. This is done as well
3. I have to keep track of old x-y positions, where I was able to extract data properly. This is done by a switch.
4. pretty much the entire VI is under a one giant while loop, properly sequenced by 0's being passed from one case structure to another until it reaches the final "global dummy".
Now, the signals that are being processed to the motor is through a USB Digital signal generator, I don't think specifics are necessary. Essentially I needed to bit-mask each individual movement, so the "motor movement" portion is embedded in the giant while loop. This means that each time I add a new function to my VI, the motor movements slow down, everytime the OS on the computer decides to run an automatic update, the motors slow down. I don't think I have the luxury of multi-threading or a microcontroller just yet.
At this point, my motors are moving dreadfully slowly, and I'm trying to find a way to make them run faster. I am certain that the bottleneck actually comes from data handling for my X-Y graph.
My XY graph is handling 3 sets of data,
a. 469 discrete points (2x469 array) or 400~ish discrete points (2x400~ array)
c. current position (x, y)
d. "saved/captured" positions(2xincreasing up to 469 array)
all a,b,c are inside the while loop. A switch determines which "a" is being used.
the arrays are clustered then sent into the xy graph inside the while loop. I need the graph to be interactive for the cursor and data.
Now, this is how I would like things to run.
1. From selection either a or b is loaded to the x-y graph(by a switch).
2. c is refreshed constantly.
3. d is refreshed everytime some data has been captured(by a switch).
Basically, I need a and or b to run only ONCE at the initilization(and when I decide to swtich from one to the other), and remain constant. Similarly D only updates when a switch has been pressed.
I haven't been successful at finding too much resources on plotting a set of data to the xygraph, and plotting a live-data on top selectively.
I have attached an outdated version of my front panel as a reference. I would appreciate any suggestions. Thank you in advance.
-SJL
Solved! Go to Solution.
02-18-2016 01:34 AM - edited 02-18-2016 01:34 AM
Hi SJLPHI,
Basically, I need a and or b to run only ONCE at the initilization(and when I decide to swtich from one to the other), and remain constant. Similarly D only updates when a switch has been pressed.
Easy answer: your graph shows 3 plots. One plot is generated at INIT state, the other two while measurement. You have to create them just this way…
General hint: showing your VI helps us more (to help you) than just showing an image of the front panel.
At this point, my motors are moving dreadfully slowly, and I'm trying to find a way to make them run faster. I am certain that the bottleneck actually comes from data handling for my X-Y graph.
I don't think the bottleneck is slow graph handling due to plotting 3 plots of less than 500 points…
pretty much the entire VI is under a one giant while loop, properly sequenced by 0's being passed from one case structure to another until it reaches the final "global dummy".
I think this is the core problem here…
02-18-2016 02:00 AM
Hello GerdW,
I am accusing the graphic portion for slowing things down because the VI ran much faster, over 10 times faster without the graphs being added to it, and also I had similar issues running MatLab a few years back. The difference is that I find myself much more effective at coding rather than graphical programming and I was able to make quick modifications. I am moving at about 2m/min with graphs disabled, I'm moving at less than 10cm/min with the graphs enabled.
I will take screenshots of the related portions in the back panel, because the whole backpanel is very messy and hard to follow at least for now.
Regarding the one giant while loop, I agree that this is nowhere the efficient way to sequence things, but I started off on LV2009 and this method was encouraged by an experienced colleague.
To clear it up, So, is it possible to have two different stages of input for one xy graph? INIT state, and "running" state? I've tried different methods. I'm finding that from what I've been doing, the moment when new data gets fed into the graph, it makes all old data to be null. Which means, the "INIT" state gets eliminated completely.
-SJL
02-18-2016 02:23 AM - edited 02-18-2016 02:25 AM
Hi SJL,
I find myself much more effective at coding rather than graphical programming
"graphical programming" is no "coding"? 😄
I was able to make quick modifications.
Quick and dirty? 😄
I am moving at about 2m/min with graphs disabled, I'm moving at less than 10cm/min with the graphs enabled.
Sounds like a bad program design…
I will take screenshots of the related portions in the back panel, because the whole backpanel is very messy and hard to follow at least for now.
It's called "block diagram". When the block diagram looks "messy" you should clean up - using a proper program design would probably help too.
Taking screenshots is just "nice", attaching the VI would be much better!
but I started off on LV2009 and this method was encouraged by an experienced colleague.
In LV2009 you can also create VIs with proper program design schemes!
I guess the collegue wasn't that "experienced" when he suggested a bad programming style…
To clear it up, So, is it possible to have two different stages of input for one xy graph? INIT state, and "running" state?
As written before: your graph shows several plots. You can create a "static" plot at INIT and "dynamic" plots at RUNNING state.
I've tried different methods.
Which methods? Please show code…
I'm finding that from what I've been doing, the moment when new data gets fed into the graph, it makes all old data to be null. Which means, the "INIT" state gets eliminated completely.
Then you did something wrong! Please show code…
02-18-2016 07:15 AM
Hello, I just wanted to try something, how do you type-cast a static input to the graph? You're right, I'm probably doing something wrong.
02-18-2016 07:21 AM
02-18-2016 07:29 AM
I'm trying to distinguish the input method for static and dynamic mode.
I cannot provide the .vi until I get to work, because I don't have a copy of LabView on my personal computer, and my backups are always outdated.
02-18-2016 07:33 AM
Hi SJL,
you create one plot in INIT state and one plot in RUNNING state. Then you use BuildArray to create an array of plots, that is wired to the graph.
Did you read the context help for the graph? It explains the datatype expected by a graph…
02-18-2016 07:22 PM
quick question, is there a support line phone number for NI LabView help?
I have written a long description, and it wiped out my post and refreshed to blank post, and I think what I am trying to achieve would be done much efficiently if I could speak to someone live.
I did use the context help for xy graph a while back, it didn't contain the specifics that I'm looking for.
I have tried making plots, and then building them into an array of plots, it didn't work, because a "plot" is apparently 1D and XY graph only takes in 2D data. I'm currently using 2D arrays to arrays then into a single graph.
Also, say INIT plot is made in INIT portion, RUNNING plots are made and refreshed in the while loop, where should the connection from plots to build array to graph should be?
Should the graph be outside of the while loop? Again, I need it to be interactive.
02-18-2016 07:30 PM - edited 02-18-2016 07:37 PM
As for coding, I've always told my colleagues, programming in C, C++, Java, and python is like writing in English, and programming in LabView is like drawing ancient Egyptian and Chinese symbols.
http://whatis.techtarget.com/definition/code
I will upload my file after I clean it up a little bit. It is a big mess, currently, it'll take much longer for anyone to know what each component does than to actually provide an insight, other than the fact I should design my program differently.