LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous Data Streams Through VISA

Hello. I've had zero experience with LabVIEW before trying to create this block diagram so apologies if what I'm asking is relatively simple. It would also help if answers where in a relatively simple format.

 

I'm trying to create a LabVIEW program which will retrieve pressure and temperature from a pressure gauge which is connected via a 9 pin RS232 cable. Eventually I'll be connecting it up to an arduino for a safety interlock, but at the minute I'm just trying to read the data. I've been able to read both temperature and pressure separately by using the command function and case structures (see photo below). Is there any way to monitor both simultaneously, given that they're both coming in through the same visa block?Block Diagram for PressureBlock Diagram for Pressure

 

0 Kudos
Message 1 of 9
(3,882 Views)

Hi CT,

 

Is there any way to monitor both simultaneously, given that they're both coming in through the same visa block?

Yes, sure!

- use a loop in your VI, put the init stuff before the loop and close the port once after the loop

- get rid of BytesAtPort, you don't need it for your communication

- send the command to read pressure and read the answer

- then send the command to read temperature and read the answer

- repeat the last two steps as long as you like

 

Btw. with your blockdiagram it would be nice to use the AutoCleanup button…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,877 Views)

To elaborate on a point GerdW already made.

 

DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (I need to turn that into a maco since I have been saying that so much).

The deal with the Bytes At Port is that you do not need it.  It is doing nothing but causing weird race conditions.  It looks like your instrument is using an ASCII format and ends with a Carriage Return (0xA, \n).  That ending character is called a Termination Character.  So when configured correctly (which you do by default), the VISA Read will stop reading when it reads that termination character or it reads the number of bytes you told it.  So you can get rid of that 200ms wait and the Bytes At Port and just tell the VISA Read to read more bytes than you ever expect in a message.  50 should work just fine.

 

My suggestion would be to make a VI that just does that query of the instrument (VISA Write followed by the VISA Read) with an input for the command and an output with the data.  Then you can reuse that bit of code.  You can chain two of those VIs to be in series (use the error cluster to serialize), one for each query you are performing.


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 3 of 9
(3,849 Views)

Hi Both,

 

Thanks for your help. Unfortunately I've extremely little experience with LabVIEW, so your answers don't make a great amount of sense to me.To get this far I've basically been copying a block diagram given to me by someone who has used similar equipment.

 

Firstly I've tried removing the bytes at port and replacing it with the 50 as per your suggestion (see below); however that gives me an error message (Error -1073807339). Is this what you meant for me to do, or have I just implemented it wrong?

 

Secondly and more importantly when you suggested use a loop in your VI, put the init stuff before the loop and close the port once after the loop, would you mind (even very crudely) sketching or butchering the block diagram to show me what should go where?

 

Apologies again. I realise this is probably quite simple stuff, but with my inexperience any help is greatly appreciated.

 

Pressure Gauge Controller Photo - 2.jpg

0 Kudos
Message 4 of 9
(3,825 Views)

@CTumilson wrote:

however that gives me an error message (Error -1073807339).

 


That tells me something is configured wrong and/or we are not properly understanding the instrument's protocol.  What is the instrument you are trying to communicate with?

 


@CTumilson wrote:

Apologies again. I realize this is probably quite simple stuff, but with my inexperience any help is greatly appreciated.

 


Ok, just stop what you are doing and take time to learn the basics.

Learn LabVIEW Basics

Training for Students

NI Learning Center

Online Training (SSP Required)

Find LabVIEW Courses

 


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 5 of 9
(3,821 Views)

Am I missing something, or has no COM port been selected?

Message 6 of 9
(3,811 Views)

@Mancho00 wrote:

Am I missing something, or has no COM port been selected?


The VISA Configure Serial Port has a default value of COM1.  But that could still be an issue.


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 7 of 9
(3,801 Views)

Hey CTumilson,

 

Apart what the others already posted I have additional, hopefully helpful pieces of information for you:

 

  1. There is an example VI shippe with LabVIEW showing how to use VISA with instruments. Open LabVIEW, click menu "Help » Find Examples...". Then navigate to "Task » Hardware Input and Output » VISA » GPIB with VISA functions.vi". Note that this example does not match your use case in terms of the exact communication protocol, but it shows how to use the VISA nodes to set up communication. Put the Read/Write node(s) into a while loop.
  2. While loop - LabVIEW 2017 Help
  3. crossrulz already mentioned some resources for online training. There might be one more: NI's Self-Paced, Online Training Courses. If he assumption is correct and you are a student / somehow connected to a university, you might be lucky in means of your university having an Academic Site license. This could give you free access to the Self-Paces Courses: How Do I Access Online Training on an NI Academic Site License? Give it a try, these courses are worth it!

 

 

 


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 8 of 9
(3,785 Views)

I've reworked the VISA as a new VI with set values for COM port, baud rate etc. It was just an tidier way to present it.

 

And thanks for the suggested training. I'll have a look at it and hopefully I'll be able to work it out.

0 Kudos
Message 9 of 9
(3,778 Views)