Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Trigger serial vi in a case structure

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.

Download All
0 Kudos
Message 1 of 16
(3,649 Views)

You better have a look at action engines. Your case statement (the inner one) is a perfect case for such an engine.

 

http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801/highlight/true#...

greetings from the Netherlands
0 Kudos
Message 2 of 16
(3,648 Views)

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 labviewSmiley Mad

0 Kudos
Message 3 of 16
(3,646 Views)

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.

greetings from the Netherlands
0 Kudos
Message 4 of 16
(3,641 Views)

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.

0 Kudos
Message 5 of 16
(3,641 Views)

It is a vi I'm missing in outer case 0, inner case 1.

probably open visa.

greetings from the Netherlands
0 Kudos
Message 6 of 16
(3,639 Views)

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.

0 Kudos
Message 7 of 16
(3,638 Views)

Hi

I don't see an attachment, forgotten?

greetings from the Netherlands
0 Kudos
Message 8 of 16
(3,632 Views)

Now I understand, sorry. I'm listing most recent above so the vi was in one of the first messages, in my case deep down below.

greetings from the Netherlands
0 Kudos
Message 9 of 16
(3,631 Views)

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.

greetings from the Netherlands
Download All
0 Kudos
Message 10 of 16
(3,625 Views)