LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

It's better or necessary open and close communication with instrument every loop?

I must communicate with my instrument, but I must change its value, for example temperature, every loop. See the Figure to understand:

 

strumento comunicazione.JPG


I think that it is better if I open communication with my instrument out of while loop so I many operation: if I put Open VISA in While loop I open VISA session every loop, instead I think it is not intelligent. Can I open VISA SESSION out of the while loop or it is an error for EXCELLENT LABVIEW VI and I must open and close VISA SESSION every times I must talk (and set) with instrument? What is the better way?

Message Edited by Michelle1892773 on 02-22-2010 02:00 PM
0 Kudos
Message 1 of 8
(2,720 Views)
Open once, outside the loop like you have done. Then close once, after you finish the loop. Remember to use a shift register for your errors, and some sort of wait function in your while loop so it doesn't eat up CPU.
Message 2 of 8
(2,708 Views)
So it's good my VI?
0 Kudos
Message 3 of 8
(2,705 Views)
You need to close the VISA session outside your loop.
0 Kudos
Message 4 of 8
(2,699 Views)

for(imstuck) wrote:
.... Remember to use a shift register for your errors, ...

Be careful with using shift registers on errors.  It is not always a good idea.  One minor error in a while loop iteration like a timeout error could mean that your later iterations will never run properly again because the error gets propagated to later loop iterations preventing things like a VISA read from executing.

Message 5 of 8
(2,694 Views)

Ravens Fan wrote:

for(imstuck) wrote:
.... Remember to use a shift register for your errors, ...

Be careful with using shift registers on errors.  It is not always a good idea.  One minor error in a while loop iteration like a timeout error could mean that your later iterations will never run properly again because the error gets propagated to later loop iterations preventing things like a VISA read from executing.


 

I completely agree. In fact, I ran into this the other day. I was using a queue to pass errors to a loop that only handled errors. However, because i was using a shift register for errors, an error was being passed to the enqueue vi. Therefore, nothing was queued up! Good comment.
0 Kudos
Message 6 of 8
(2,689 Views)
Can You do a simple example (using maybe only icon write of a generally instrument) VI for LW8 in which do what you tell that It's better to do. If I see I understand better, thanks.
0 Kudos
Message 7 of 8
(2,662 Views)

 

 

Something like this?

 

I do have to say, i don't know what is happening in the false case of yours, but if nothing happens with the 100 that is wired to the shift register, once you enter the true case, the value in the shift register will always be great than "i". You might as well do what I have done then. However, if something does happen with that number in your false case, then keep it the way you have it.

 

That being said, why is the condition there to see if it has looped 100 times before doing the visa write??

Message Edited by for(imstuck) on 02-22-2010 04:45 PM
Message Edited by for(imstuck) on 02-22-2010 04:46 PM
0 Kudos
Message 8 of 8
(2,654 Views)