12-10-2011 01:08 AM
Good day all,
I am attaching 2 vi. The position2 vi is a subvi which I want to put in a case structure(main vi). The main intention is that the position2 vi should move in the Move motor state in the case structure. please how do I trigger this motion.
Attached are the two vi"s.
Pls Note: I am using the position2 vi to run a motor and it is working fine by just running the vi. All I want to do is that it should automatically run anytime the Move motor state is called in the case structure.
Your advice would be appreciated.
Thanks.
12-10-2011 01:53 AM
You better have a look at action engines. Your case statement (the inner one) is a perfect case for such an engine.
12-10-2011 02:39 AM
This look scary. Does anyone have a simple example for a beginner like me?
I will be definitely happy when my research is completed using labview
From Serial communication to Case structure and now ACTION ENGINES all in a month. and without prior knowledge of labview
12-10-2011 07:22 AM
I agree that Action engines are scaring for a beginner, but I would not have survived without them the last 18 years (wow that long...).
In fact see it as a way to have a one instance object in LV before there was LVOOP. It can make the code more modular and has no racing conditions if implemented correct.
I'll try to work out an example on your inner case if you also supply motortesting.vi;
And another hint. Check out typedef enums before continuing, they are like typedeclarations in Pascal or typedefinitions in C++ and will update all elements in all vi's when you add a state.
12-10-2011 07:58 AM
Good day,
Please really the example would serve a lot of good.It surely leads my way any day any time.
However, please I dont seem to understand what you mean by
if you also supply motortesting.vi;
thanks in anticipation.
12-10-2011 08:10 AM
12-10-2011 08:16 AM
If I understand you perfectly, It is the same vi as position2code. vi. I am using same code throughout, the only difference is that I will change the command position to move the motor to another point e.g. in case 0, the position2code.vi will have LA2000, while in case 1, it will have LA3500.
I hope I am thinking rightly.
Thanks for you quick response.
The position2code is attached above.
12-10-2011 12:47 PM
12-10-2011 12:50 PM
12-10-2011 04:39 PM
Hi
I made a very small action engine.
Call it before your while with init (here you specify the port, only here)
In the while on all necessary places with set and connect the correct value to be set.
After the loop with exit.
An uninitialised shiftregister remembers its value inbetween calls, in this way the visa resource is kept.
So you don't have to connect it inside and after the loop.
You could with another shiftregister remember the position and do calculations inside.
Just what you like.
And the Position Action.ctl is a typedef enum. use it on two or three places and the change one of the commands and see what happens.
And try to explain to me what the logic is trying to accomplish. This should be better readable therwise you won't understand after half a year what is happening.
Use me as the stupid pupil to explain, and you build better software yourself.