05-09-2018 08:21 AM
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 Pressure
05-09-2018 08:26 AM - edited 05-09-2018 08:28 AM
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…
05-09-2018 11:44 AM
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.
05-10-2018 08:50 AM
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.
05-10-2018 09:02 AM
@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.
Online Training (SSP Required)
05-10-2018 11:36 AM
Am I missing something, or has no COM port been selected?
05-10-2018 01:27 PM
@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.
05-11-2018 02:23 AM
Hey CTumilson,
Apart what the others already posted I have additional, hopefully helpful pieces of information for you:
05-11-2018 04:02 AM - edited 05-11-2018 04:02 AM
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.