07-06-2012 12:34 PM
Hey everyone,
So I want to keep my code as modular as possible so I'm designing everything ni sub VI's.
One of the SUB vi's consists of continously polling incase a different output is detected. I don't want to do this polling at the main level because I don't want to have a huge loop in my main.vi and don't want to worry about sending shift register valuse to my subvi for it to function.
Essentially I have designed this sub Vi and am now trying to continously control it from a main.vi
This main is simply.
Input Cluster --> Sub VI
Sub VI keeps looping waiting for a change to prompt it to do an action. Unfortuantely when I change the vale in main.vi the avlues in subvi don't update. I guess this makes sens, in C for example when you call afunction you need to wait until the function call is complete for it to update. Still, given that Labview is so heavily focused on making SUB vi's to pretty much do everything for you, I can't imagine labview isn't able to update these values. I've looked around and the answer seems to be global variables. I really don't want to use the because my application is going to get really large, but I'll use them if I need to.
Unforunately, when I tried to use my gobal variable trick, it didn't work.
1. Global Var = Cluster
2. It is in both the subvi and the main VI.
3. When I run my code the global variable doesn't update on both front panels when I modify one of them. Am I doing something wrong?
Solved! Go to Solution.
07-06-2012 12:36 PM
One more thing.
My application is essentially looking at controlling 4 motors simultanously. Thus I'll need 4 Sub Vi's to run at the same time. Can I simply accomplish this by not having any data linked between them and dropping them all on 1 main.vi?
Also, on my early question, is there antoher way to trade data between sub Vi's and main.vi when sub.vi is looping? I'd like to use that approach since i'll be callng the same SubVI 4 times which would make this global variable trick really bad.
07-06-2012 12:38 PM
Please show us some code. Thanks.
07-06-2012 12:58 PM
Here is my code.
Go to Full is my main.
It is calling on Go To Single Control.
Go to single control in turn just calls on a large case structure that I wanted to seperate out just to tidy things up.
The links between Go to Single and Go to Sub work fine. If you step through the code, you'll notice that Velocity and Acceleration do update once and then go back to being null. I don't care much for having the value still displayed as in a real application I would send the Velocity and Accel Clusters (which are in an appropriate format) straight through to RS232 via another VI I have already developped which takes in a cluster array.
My question is when I step through my Go to full code, the values inside Go to Single aren't being updated based on what I change in go to Full. This is because go to control is still looping. How do I get a global variable to fix that? I tried used global variables but it only updated my value the first time I hit run and not as I was running.
Also, I guess property nodes with references might work, but I haven't yet started to use them or references so some sample code would be nice.
second question.
Sine I'm trying to control 4 axises at the same time. I want to use 1 VI but the onyl different is a different "Address" or "Axis" is being sent. That address reference actually controls my motors (1, 2, 3, 4). The only problem is I need them all to run at the same time and I need to be able to hit Go To and have them all be running (potentially) at the same time.
07-06-2012 01:02 PM - edited 07-06-2012 01:11 PM
-How do I delete this extra reply?-
07-06-2012 02:44 PM
After reading up some stuff on the forums. I found my answer and am now using references and property nodes.
Labview is kick ass.
I'm still having trouble figuring out how to run multiple instances at the same time. But I'll figure it out!
07-06-2012 03:20 PM - edited 07-06-2012 03:22 PM
A few comments.
Good luck!
07-06-2012 03:45 PM
Thanks for this!
Yeah, I don't quite know all of the labview pre built functions yet. So I just make my own contraptions and replace them as I learn new things.
Thanks!
07-09-2012 10:41 AM
Hey,
Thanks for this. I got all the code I wanted to work today and I cleaned it up so it doesn't look like a mess anymore 🙂