LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running many VISA based subVIs over same COM port

Hello to all LabVIEW users,

I am running a project in which I am trying to read values of some certain variables (temperature, current etc.) continuously according to the command send to the device. For this purpose I have written subVIs for each of the corresponding parameters. In this context, when I run them one by one it all works fine. But when I want to run all of the subVIs in the same project only one of them will give me the result. I guess the problem is with the communication hierarchy I am considering. But for the exact solution I will request your kind guidance.

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 1 of 8
(3,411 Views)

I can't look at your code, but make sure you don't have any race conditions, use error wires between your read VI's so one will finish before the other starts. Another solution is to incorporate both function in a single VI and select what to read through an Enum input. Such a VI can only be run as singleton (normally) and thus prevents simultaneous read and writes to the com port.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(3,403 Views)

Hello, thanks for reply. You can't look at the code due to LabVIEW version conflictions? If so I can save it for another version for you.

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 3 of 8
(3,398 Views)

1. You reinitialize your port in each VI.  That does not belong in your command VIs.  You should initialize the port before you start your main loop and close it afterwards.

 

2. You should not be using the Bytes At Port, especially if the instrument is using a termination character.  Just tell the VISA Read to read more bytes than you expect a message to be and it will stop when the termination character is read.  This will also eliminate the need for those waits after sending the command.


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
Message 4 of 8
(3,346 Views)

Thanks for the reply @crossrulz. Yes, for the first remark you are fully right. I already fixed that issue after posting this. My question will be regarding second remark of you. When the program reads termination character it will stop that is true. But do you think it will effect the continuous data receiving? As I mentioned I should continuously measure my parameters.

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 5 of 8
(3,340 Views)

@TITAN-x wrote:

When the program reads termination character it will stop that is true. But do you think it will effect the continuous data receiving? As I mentioned I should continuously measure my parameters.


Just to clarify, does the instrument only sends data back as a reply or does it constantly send data?  Either way, the Termination Character will help you and reduce wasted time (due to the wait), which will help your continuous getting of data.  But if your instrument is constantly sending data without a command, then we need to rethink architecture a little.


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 6 of 8
(3,333 Views)

Actually I am sending command to the instrument so that it responds with the data I have requested. The problem is that, when I connect to subVI as attached in the first command, I sometimes get respond as expected and sometimes does not get a meaningful respond. Than I figured out that, when I connect the subVIs which run over same COM there is kind of crush happening between commands. How can I get rid of this complication?

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 7 of 8
(3,327 Views)

Make the updates that I already told you to do.  I gut feel is that the Bytes At Port was causing your issues (it becomes a very interesting race condition).


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 8 of 8
(3,307 Views)