06-18-2009 06:44 PM
Hello,
We are using labVIEW for implementing receprocating motion of a motor controlled stage for a user defined cycle number.We have a few different built-in subVIs(provided by the company).There is one subVI that "Run Command" which basically takes a message input as some pre-defined commands as a string as an input for moving a certain distance in one direction.When we used this subVI to implement the reciprocating motion.But now we want to keep track of the current cycle number that is running and for that we implemented a while loop which uses the Get Position subVI and whenever the position is within 10% of the one end of the track it adds one to the current half cycle number variable and then waits for a certain time(which is estmated to be time for one half cycle i,e amplitude/small x velocity) and then again start checking if it's within 10% of the other end of the track and adds 1 accordingly.The whole process is implemented under the event loop in the case named as "Take measurement".
Now the problem is when the stage starts moveing the user interface gets frozen and we cant access the pause or stop or terminate buttons.
Anyone has any idea why it does so?Or any possible suggetsions.Any help will be appreciated.
(Note:Iwas trying producer/consumer loop but it seems I dont see any data to be put in the queue and to be consumed,probably because it is not very suitable.)
To open the file please open
06-18-2009 07:35 PM
Your code suffers from a severe case of localitis and squenceitis. It is written like text based code, with frames used as lines and local variabel used as locals. This is not that great to begin with. (see also)
Still, here's your main problem:
All you events are set to lock the front panel until the event completes, and it seems that some of your event cases have a hard time completing in a reasonable time (some contain e.g. while loops, etc.).
You need to decouple the background operations and the UI, e.g. with a queued state machine architecture or similar.
06-18-2009 09:40 PM
Here are some good launching off points:
06-21-2009 10:43 PM
Thanks a lot to both of you for your replies.I still find the JKI QMS a bit confusing so I used QMS template from functions palette.Now my user interface is not frozen anymore (I can access the stop and pause buttons) but my cycle count does not work (the value of the current half cycle number indicator doesnt update anymore once one half cycle is complete).As can be seen from the highlighting ,I think the message generator loop doesnt work at all.
I would greatly appreciate any suggestions.
Thanks a lot
Aru
06-21-2009 11:00 PM
You never update the Current Half Cycle indicator.
On your block diagram, you have terminal at the top with nothing wired to it. Do a right click find with it. Select Local Variables. It finds a single local variable that has a zero wired to it. (And backwards at that.) It runs once at the beginning of the program.
Nowhere else do you ever write to a local variable or property node of that indicator.