LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reentrant vi and uninitialized shift register

Hello everyone,

 

I'm stuck with the following problem.

 

I use a vi with unitialized shift register to remeber the status of a motion stage, the reason i did this is so that i can call the vi in different locations. Because i want to know the status of the motion stage in different parts of my program. I made a case structure (within a while loop that executes only once) with the following states:

 

1) set moving

Put a boolean with the value "True" into the shift register, this indicates that the stage is moving.

 

2) get

Reads the boolean value from the shift register to see what the status of stage is.

 

3) set status

 Basically this state puts a boolean with the value "False" into the shift register to indicate that the move has ended.

 

I simplified the number of states in this example but basically those 3 states are all i need for the status.

This works well if you have only one stage.

 

I would like to do this for six stages, I thought about making the vi reentrant but the thing is if i do a "get" call how do i know from which stage the returned data is? Is there some sort of reference i can use so that i know that this "get" belongs to stage 1 or 2?

 

Another option i thought about is making a status vi for every axis.

 

What would you guys recommend in this situation?

 

 

Any help is greatly appreciated.

Best regards.

 

0 Kudos
Message 1 of 10
(4,158 Views)

Can u please explain ur application first. Because I believe that this can be done in many ways. Why u used shift register with while loop that executes only once. Any control or indicator with its local variable can do this job.

 

Please explain ur application in details so that some simple logic can be provided.

0 Kudos
Message 2 of 10
(4,146 Views)

You could extend your VI to use one Shift Register for each axis and require an axis input.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 10
(4,141 Views)

It sounds like you are trying to build an action engine. You must not set this to reentrant otherwise, the use of this structure is very different to what Ben describes.

 

Therefore, you should follow the suggestion from Jim.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 10
(4,138 Views)

Sounds like you could use some OOP. See this post for a start (and follow the link there for a specific example. It points to the end of the thread Norbert linked to).


___________________
Try to take over the world!
0 Kudos
Message 5 of 10
(4,124 Views)

@ Kekin

 

What I'm trying to do is the motion control of 6 axes with labiew via RS232.

I have 2 controllers that each control 3 axes. Each controller is connected to a serial port. So i need to manage 2 serial ports.

 

A controller can only move one axis at a time, if an axis is busy executing a move, all incoming commands will be blocked (exept for status requests) and put into a fifo, this is the reason why the choice was made to use 2 controllers. So that it is

possible to move 2 axes at the same time. It is important for me to know the status of an axis because the fifo has no overflow detection, so i need to know when i must stop sending commands to the controller.

 

The controller can "see" that there is an axis moving but it doesn't know which one ot the three. So i would like to make something in my software that keeps track of which axis is moving, hence the uninitialized shift register.

 

I cannot use local variables because the vi that asks for the status is nested deep into the vi hierarchy (a subvi), and i would like to display the status of the axes on the GUI.

 

Another option would be to use globals, but i dont really like them because of race conditions and it can be confusing to find

out where exactly the data is written and read. So i chose to use a uninitialized shift register because it remembers the last value that was written to it, so you could kind of use it as global variable, you can call this vi on different levels in the vi hierarchy.

 

It actually is an action engine as Norbert B mentioned.

 

0 Kudos
Message 6 of 10
(4,114 Views)

@ jcarmody

 

That sounds like a good idea, i dont have all the stages yet to test it. But i'll try to simulate something.

Thanks for the advice

0 Kudos
Message 7 of 10
(4,112 Views)

You can have the non-reentrant vi have a shift register per axis, or have the statuses in an array, the index representing the axis in question. If moving/not moving is a boolean you can perform an OR of the array of statuses to see if any are True before perform your next action. The idea of using the case statement within an uninited shift reg is a good one, and as a previous poster mentions is covered in a nugget by "Ben" about Action Engines.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 8 of 10
(4,097 Views)

@ LV_Pro

 

Thank you for the information.

 

Let's say i would like to acquire the status of 2 axes at the same time (parallell execution), this can be done because i have 2 controllers that work independantly of each other. What design do i use then? I dont think it is such a good idea to make the Vi with uninitialized shift registers reentrant, so if i cant do this it would mean that i have to come up with whole other design of getting the status.

 

0 Kudos
Message 9 of 10
(4,063 Views)

@ynse wrote:

[...] 

Let's say i would like to acquire the status of 2 axes at the same time (parallell execution [...] 


An Action Engine won't be parallel but, unless your application requires super-speed, the serial-ness won't be noticeable.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 10
(4,043 Views)