From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delayed Movement For Loop

I know this question has probably been asked and answered before, but after searching/reading in the forums, I'm still confused.

 

So I would like my VI to effectively move a stage a given distance with incremental sizes with pauses of between each step.

Effectively: "Go To" _____ With X step size: causes the VI to: move, pause, move pause...etc until the stage has reached the end.

 

To accomplish this I set up a for loop inside a case structure, and took the "Go To" / by Step Size to get the number of iterations the loop aught to run (labview apparently rounds the double result to the integer form), and then I send the "Step Size" to the MoveAbs VI.

I am not sure if my logic is terribly off, but when I perform the command, the stage at least moves, but not to the correct location.When I inserted probes, they list the correct values being sent to the subvi's etc...

 

Does anyone have an idea why this would not work? Any better ideas to institute this type of motion?

Thanks

0 Kudos
Message 1 of 13
(3,063 Views)

OK having the for loop inside the event was a bad idea on the timed event. I added a state machine structure and cleand up your code. I did not have a chance to get it all done as I have to go home. This should be enough to get someone to help. I will try to help with questions tomorrow.

 

Tim
GHSP
Download All
0 Kudos
Message 2 of 13
(3,047 Views)

Here is a version with comments.

 

Let me know if you have questions. I will show you how easy it is to grow this program from here.

Tim
GHSP
Download All
0 Kudos
Message 3 of 13
(3,008 Views)

You should keep your questions about this code here instead of sending private messages that way others can learn for our discussion.

Tim
GHSP
0 Kudos
Message 4 of 13
(2,990 Views)

HI Tim,

I was having some problems with the code you sent back--specifically about getting multiple commands to function from the control panel. I am attaching it with questions so that others can benefit from this too--other people feel free to weigh in!

As always, thanks for your help!

0 Kudos
Message 5 of 13
(2,969 Views)

Here is the answers. Very good questions. It shows that you do mostly understand what we are doing.

Tim
GHSP
0 Kudos
Message 6 of 13
(2,953 Views)

Hey Tim,

I've got another question for you--I've been working on the program and I think I finally understand the basic outline. I've been trying to add other subvi's to increase functionality and I came across a problem:

 

The error list says that the selector values of the case structure are not unique--which is true of the program I am sending you. So naturally I deleted the extra "VI INI" which was tagged onto the default case. However doing so caused my program to crash--or more accurately cycle in an infinite loop. The program initializes over and over again. The "INI VI" sends another "INI VI" to the array and gets stuck.


I am not quite sure what is wrong, because when I looked at the original program you had sent to me, and earlier versions I had edited, I noticed that they have the same code within the "INI VI" case...in addition, now when I open previous programs--that were functioning perfectly well before--I get the same error message complaining about "not unique selector values". I honestly don't recall ever adding "INI VI" to the default case...

 

I am attaching the program and was wondering your thoughts, especially given the retrospective error...

 

Let me know if I was unclear in explaining the problem etc...and thanks again for your help. Others' input welcomed too!

Nathan

Download All
0 Kudos
Message 7 of 13
(2,915 Views)

Can you post it in 10. I have not upgraded to 11 yet.

 

Tim
GHSP
0 Kudos
Message 8 of 13
(2,911 Views)

Sorry about that--here they are.

0 Kudos
Message 9 of 13
(2,905 Views)

I've noticed that the VI INI is looping around itself, but I am not sure why that's the case--because the original code you sent, and subsequent code I wrote, was the same and was functional. As of now the program begins with a VI INI which then calls itself. Shouldn't VI INI call a different case? I would prefer it to call the first one--but that is currently set as the default case--which is never being reached and cannot be called because it is the default case. Could I call the VI INI case and have it return nothing to the array?

Nathan

0 Kudos
Message 10 of 13
(2,904 Views)