LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Synchronous / asynchronous --> Confused

Hi All,

 

Have recently written some code as below which i has raised a few questions in my mind.  I have read some articles about VISA read / write Asynchronous and synchronous and I am a little confused.  I know that asynchronous releases the thread earlier etc but can not really see how this translates into code.  Say In my example below, which is essentially reading serial data from serial ports with no terminations and expect unsolicited messages etc.  This is then Queued and used in my application.  I have the following Q's

 

1 - How many Threads is this in Asynchronous Vs Synchronous.

2 - Which method would be better for older PCs running windows.

3 - Do the reads occur simultaneously / overlap when asynchronous (Much like a re-entrant vi)

4 - Do the Reads happen independently when in Synchronous (i.e one then the other) or are they assigned different threads?

 

Anyone who can shed some light will be on my Christmas card list 😄

LabVIEW 2012
0 Kudos
Message 1 of 6
(6,794 Views)

First!

 

See this thread where Dan Mondrik tried to help me with a similar Q.

 

 


craigc wrote:

Hi All,

 

Have recently written some code as below which i has raised a few questions in my mind.  I have read some articles about VISA read / write Asynchronous and synchronous and I am a little confused.  I know that asynchronous releases the thread earlier etc but can not really see how this translates into code.  Say In my example below, which is essentially reading serial data from serial ports with no terminations and expect unsolicited messages etc.  This is then Queued and used in my application.  I have the following Q's

 

1 - How many Threads is this in Asynchronous Vs Synchronous.

2 - Which method would be better for older PCs running windows.

3 - Do the reads occur simultaneously / overlap when asynchronous (Much like a re-entrant vi)

4 - Do the Reads happen independently when in Synchronous (i.e one then the other) or are they assigned different threads?

 

Anyone who can shed some light will be on my Christmas card list 😄


 

1)

LV scheduler could use two.

 

2)

Async

 

3)

Over-lap (read thread I cited above)

 

4)

I think they are sequential.

 

I don't do Christmas so forget the card.

 

The above is my best off-hand. If others know better well straighten me out!

 

Ben

 

BTW: Building a string in a loop will kill your performance after the stirng starts to grow. If you run into that issue, queue of the updates to another loop and let it fight for memory.

Message Edited by Ben on 03-26-2009 10:00 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 6
(6,769 Views)

Hi Ben,

 

Thanks for the link to the other thread, it has cleared things up for me a lot.  However i think i will still be referencing it from time to time untill all that eventually sinks in!  Ok not the cc list but the Pint buying list instead:). 

 

4 - Is in Parrallel according to the other thread  (unless i still misunderstand, which happens a fair amount )

 

The string Indicators are cleared every test iteration and dont go above a couple of hundred lines.  I have checked this and also the queue lengths are cleared etc.  Oh and dont worry, that code will be cleaned up and commented, its just sandbox stuff at the moment 🙂

 

Thanks again

Craig

Message Edited by craigc on 03-26-2009 10:49 AM
LabVIEW 2012
0 Kudos
Message 3 of 6
(6,759 Views)

craigc wrote:

Hi All,

 

Have recently written some code as below which i has raised a few questions in my mind.  I have read some articles about VISA read / write Asynchronous and synchronous and I am a little confused.  I know that asynchronous releases the thread earlier etc but can not really see how this translates into code.  Say In my example below, which is essentially reading serial data from serial ports with no terminations and expect unsolicited messages etc.  This is then Queued and used in my application.  I have the following Q's

 

1 - How many Threads is this in Asynchronous Vs Synchronous.

2 - Which method would be better for older PCs running windows.

3 - Do the reads occur simultaneously / overlap when asynchronous (Much like a re-entrant vi)

4 - Do the Reads happen independently when in Synchronous (i.e one then the other) or are they assigned different threads?

 

Anyone who can shed some light will be on my Christmas card list 😄


Basically VISA has syncronous (viRead, viWrite) and asynchromous (viReadAsync, viWriteAsync) operations. By default LabVIEW uses the asynchronous versions and polls the according session regularly to see if the operation has finished. This is the way LabVIEW has done multithreading in its diagram even before it used OS multithreading. This polling is fairly efficient so should not be a problem.

The problem with using the synchronous version is that VISA can only run one synchronous read and/or write at any one time. So if you have an application using many different instruments and all VISA operations are set synchronous the VISA Read (and VISA Write) function behave really like a non-reentrant VI. No other code part will be able to call into VISA Read or VISA Write while a VISA Read is pending to receive the requested data. It should be clear that this would be usually not what one really wants in a real world test application. When using asynchronous VISA operation LabVIEW will happily schedule various VISA Read and Write operations to run seemingly in parallel, so that you can setup multiple instruments in parallel and don't have to wait for each configuration step of every instrument to return before going to the next instrument.The actual measurement procedure most likely will have to occur sequential, which you can get with proper data flow, but the configuration of multiple instruments can be sped up consideribly when executing them in parallel and when VISA ist set to run asynchronous. If you only communicate with one instrument it won't really make a difference if you run VISA in synchronous or asynchronous operation but it really never has hurt me to do asynchronous anyhow as long as you observe proper data flow where this is necessary for the logical operation of a measurement.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
Message 4 of 6
(6,748 Views)

Thanks Rolf,

 

That has cleared it up and confirmed what i think is going on with the asynch / synch VISA Functions.  I have not experienced any difficulties with either option but have always wondered what they meant exactly.  Especially as i am now deploying code onto older machines.

 

Always good to know

 

Thanks

Craig

LabVIEW 2012
0 Kudos
Message 5 of 6
(6,714 Views)

hello Everyone... i am using VISA read  (async) to read the bytes coming in... currently i am runnging @ a baud of 921600... i am using USB-UART cp2102... i have had troubles with bytes being missed very often... do you think that changin to VISA Read (sync) will make any diff? ter is 1 laptop on which i never had any issues with bytes missing/anything... apart from that laptop, i have had troubles transferring data... i transfer arnd 2GB data from externl flash mem to PC. 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 6 of 6
(6,132 Views)