LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA resource name

How it is different to use shift register with visa resource name and not using shift register with visa resource name when using VISA read inside while loop? I am asking with respect to data acquisition, would it cause the incomplete data acquisition missing packets ?

Another question is what If we don't close the visa outside the while loop for each data acquisition, would it cause visa read to take more or less bytes than specified byte number during next data acquisition?




 

0 Kudos
Message 1 of 5
(1,398 Views)

@77hybbr wrote:

How it is different to use shift register with visa resource name and not using shift register with visa resource name when using VISA read inside while loop? I am asking with respect to data acquisition, would it cause the incomplete data acquisition missing packets ?


If the resource cannot change, then I tend to use tunnels.  If all you have is a VISA Ready inside of the loop, it doesn't really make a difference if you use the shift register.  If you have case structures or event structures, then it makes it easier to use tunnels (forget to wire the reference through a case and your reference could be gone).

 


@77hybbr wrote:

Another question is what If we don't close the visa outside the while loop for each data acquisition, would it cause visa read to take more or less bytes than specified byte number during next data acquisition?


If the resource is not closed, then the buffer will keep filling up with anything that comes through.  So you could be dealing with old data.  But the way you worded this question throws up a red flag in my brain.  Maybe you could show an example (ie code) with the exact situation you are facing?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(1,371 Views)

Nothing to add to what crossrulz said other than to say I prefer to use a shift register just because it's more of a habit to me, and the downsides are minimal (probably a small speed loss in very high speed loops). Basically, if I always use a shift register, I don't have to think about it 😄

 

The only thing I'd like to bring up regards For loops, which the OP didn't ask about but it may be relevant...

 

A resource wire is basically the same as a shift register for a While loop but it may behave differently for a For loop in edge cases. A While loop is guaranteed to run at least once. A For loop may run zero times (if, for example, it's autoindexing and something upstream generated an empty array). A For loop that runs zero times will output the wire's default value on an output tunnel, but it will pass a value through with a shift register. Usually you're using a While loop with a VISA reference (and is in fact what the question is asking) but it's a good thing to keep in mind.

 

Example_VI.png

 

For something like a VISA reference, this means that upstream errors may cause you to hang a port. Take the following code:

 

BertMcMahan_0-1694793565721.png

 

 

The For loop runs a number of times equal to the number of commands read from a file. If that function errors (like if the file doesn't exist, or is configured improperly), then the For loop will run zero times, meaning the VISA Close function gets an empty VISA reference at its input. Thus, running this code will open your port, but will not close it in the case of an error, and your port will be stuck open until you fully exit the program. Switching to a shift register ensures that you'll always pass the VISA ref through the loop, even if it errors, and your port won't hang open:

 

BertMcMahan_1-1694793668200.png

 

Message 3 of 5
(1,364 Views)

Actually I cannot show the VI because I don't have it right now . I can give u idea. I am pressing the button from labview which is actually sending command to Com port. In return on the same com port a data at rate of 500K Sampling rate is send which in total are 65536 data packets and each packet is of 8 Bytes. Then what I am doing is extracting 2 information data bytes from each 8 byte packet and storing it in a buffer. Lastly after running while loop for 65536 times I plot the buffer and also take the Sinad and thd of that buffer. That buffer contains some data points of waveform. Now what happens is each time snr and the varies alot but I am expecting that they should not vary alot . One time it is 63 and other time it is 53 which is very change . I can expect the change of almost 1 like 63 to 62. What I think is issue is in data acquisition because I have seen the data in other softwares also where is give expected results but on labview it is not. Maybe it is because I have not closed the visa after acquiring data. But I am confused about it because the data which I receive at visa port is not continuous. I receive data only when I send the command and receive 65536 data packets. So how can closing the visa resource make any difference? What could be any other possible issues with this data acquisition? 

0 Kudos
Message 4 of 5
(1,323 Views)

It's almost certainly an issue with your code, so we can't help until you show it.

 

I doubt it is opening and closing the port that may cause an issue, though it certainly COULD be.

 

Are you reading in two bytes at a time? If so, you may not be reading fast enough to keep the Read buffers empty. Try to read about 1/10th of a second worth of data at a time and process it that way.

0 Kudos
Message 5 of 5
(1,275 Views)