LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use "for" loop to output a series of text string one by one?

John,

 

Now your explanation of why this won't work is making sense.

 

If you are talking to instrumentation (the stage controller), there are a number of ways to handle that.

 

You CAN put all of the commands that you want into an array, and then read them out using a timed loop or a do - while using the wait function that Mark has demonstrated, but 2 minutes is a long time....  what you may want to do is create your array of commands, then use another set of code that will send out the correct command from the array at a predetermined point in time (2 minutes).  The nice thing about having the code in an array is that you can build arrays for certain series of movements, or you could have ALL of the known commands available in the array, then just use a sequenced list (or another array) to call (send) each command to the controller.

 

Ex:

(each move is one step)

Command List

Move foward

Move Backward

Move Left

Move Right

 

Then knowing that the commands are in the array as 0 based numbering, use the index function to call the series of commands:

 

0

0

0

2

2

2

2

2

0

1

 

This would then issue the following commands every 2 minutes

Move Forward

Move Forward

Move Forward

Move Left

Move Left

Move Left

Move Left

Move Left

Move Forward

Move Right

 

Hope this helps  guide you.

 

Dan

 

 

0 Kudos
Message 11 of 15
(675 Views)

Mark,

Is it possible to put the Command outside the "for" loop? If I put the command inside the "for" loop, then it is hard to pass out the instrument handle from the "for" loop, please refer the attached program, i am actualy trying to write a for loop to produce the "command" used to write to the Visa.

 

John

0 Kudos
Message 12 of 15
(674 Views)

It is not hard at all to pass out the instrument handle. You just right click on the exit tunnel and select 'Disable Indexing'. You are making it much harder than it should be by not using the for loop correctly.

0 Kudos
Message 13 of 15
(664 Views)

You can but then as you say you need to send the command to the other task. I would use a queue. But there would be no benefit of separating the generation of commands from the communication task unless you simply generate the command list as an array. I would put the command generation and the communications in the same loop. Given teh delay you need between operations I would probably implement this as a state machine. By doing so you could abort the operation mid stream if necessary.

 

Why do you want to have a separate loop create the commands? Why not do it at the same place you are doing your communications? Or why not allow the communications loop to operate on an array of commands?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 14 of 15
(663 Views)

John,

 

Just a note of encouragement.  It sounds like you may be fairly new to LabVIEW and maybe even programming.

 

Keep this in mind. In software for every solution there are ten other ways to approach or solve the problem. As you gain experience, you will collect a bag of programming tricks that you will rely on. The nice thing about software is that you can try a lot of different things just to see what works.

 

Keep at it, keep asking questions ( I  have a question out there now that I think is fairly complicated that nobody has responded to yet) we all need subtle pointers that cause us to slap our foreheads and exclaim, "that's it!!  Now why didn't I think of that?!"

 

Also if we give an answer that you don't quite follow, let us know. 

 

Now the reason I say this. Those of us with experience see a number of ways that we would approach your problem. It's all good information and you may want to experiment with them when you get the time. Your approach may be easier to understand, but in the long run it may take a while longer to program it, whereas using a queue and other like techniques while easy for us with experience, there is a code overhead that comes with it and you may not be at that point yet. You can't be a master of LabVIEW all at once, but it will come.

 

Keep at it.

 

Dan

 

 

Message 15 of 15
(652 Views)