08-31-2010 04:34 AM - edited 08-31-2010 04:41 AM
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.
08-31-2010 05:01 AM - edited 08-31-2010 05:02 AM
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.
08-31-2010 06:13 AM
08-31-2010 06:19 AM
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
08-31-2010 07:07 AM - edited 08-31-2010 07:09 AM
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).
08-31-2010 07:35 AM - edited 08-31-2010 07:38 AM
@ 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.
08-31-2010 07:37 AM
@ 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
08-31-2010 08:16 AM
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.

09-01-2010 01:57 AM
@ 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.
09-01-2010 05:37 AM
@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.