LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial and COM Port Communication

Hello,

 

I am looking for any assistance that anyone may be able to provide for successfully reading a pressure standard reading from a COM port.
Background

I am using Labview 2015 and trying to communicate with a Heise PTE-1 2H unit through a Serial to USB cable.  I have the Heise connected to the serial end of the cable and the usb connected to my computer.  As seen on page 40 of their manual, I have the device set to Journal mode, 9600 baud rate, 1 second interval, and the default end character of CrLf.  The resulting data should transmit once every second and appear like the following:

 

+0.005 in.H2O +0.0000 psi

Left Min: +0.0045 Max: +0.0053

Right Min: +0.0000 Max: +0.0000

 

The problem

I am using a program (see attached) called Terminal20141030 which shows me the input values from the COM port of my choice.  When running, it imports data constantly and without any problems.  Labview, however sometimes will read the values and sometimes does not.  I modified the code again and again to try and find the problem part of the code, but with no luck.

 

I have attached my code here.  There are two VIs with the main VI being COM_Port_Read.  The String Conversion is used to convert the string of three lines of code (as seen above) into two values of pressure from that data.  I know the string conversion works just fine.

 
Untitled.png

Please Note: 

1. I have done probes into this program and noticed that the Bytes at Port, when working jump up to about 70 and back to 0 every second or two seconds.  When it does not work, the Bytes at Port remain at 0.

2. I have a double loop here because I want to be able to reinitialize the connection port address during the use of the program.

3. I do not have a very extensive knowledge of Labview.  I am entirely self taught and I do know that I may not approach some of the logic in the most effective or efficient ways.

4. I created this based off of someone else at my company's work.  For example, the value of 34 for bytes at port to be used, was a value that was specified by this other person.  I am not sure why that was chosen.

 

Thank you for your assistance, and please let me know if I can provide you with any other information to make troubleshooting this a little easier.

 

 

 

0 Kudos
Message 1 of 25
(5,043 Views)

Don't use  Bytes at Port!

 

It looks like your data comes in as 3 lines.  I assume that means you have either a line feed character or carriage return separating them.  Go back and enable the termination character (you placed a false constant to disable it) and set the termination character to be either linefeed (decimal 10) or carriage return (decimal 13) depending on which is used.  Then proceed to do 3 consecutive reads of a large number of bytes within the loop.  Each of those reads will give you one line of the data.  Decode them as needed to get the values.

 

You will probably need to do work on your string conversion to be more robust.  You say it works fine,  but supposed those 3 lines come in a different order  Line 3, then 1, then 2?   But first get it working reliably that you get all the data.  Then you can fix decoding using Scan From String Functions.

 

PS:  There is no point to attaching a zip file containing the terminal.exe.  We can't run it.

0 Kudos
Message 2 of 25
(5,016 Views)

Just to be clear, DO NOT USE THE BYTES AT PORT!!!  In 99% of the cases, it is the wrong g choice for telling the VISA read how many bytes to read.  Enable the termination character and just read a large number of bytes 3 times.  With the termination character enabled, the VISA read will stop when it reads the desirable number of bytes to reads the termination character.

 

And you do not need that wait either.  The rate of the data being read will determine your loop rate.


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 3 of 25
(4,999 Views)

Unfortunate, with the following changes I am still not getting any data at probe 6.

Untitled2.png

Regards, Michael

0 Kudos
Message 4 of 25
(4,923 Views)

Are you getting a timeout error?

 

Are you sure your device is still sending data?  That the RS-232 mode is still enabled with a reasonable time interval  (referring back to pages 40 and on in the manual you linked to.)?

0 Kudos
Message 5 of 25
(4,919 Views)

I have that other application running as well and it shows that the data is coming in at one second intervals.

 

What is strange, and really perplexing is that when I first modified this, I got data streaming in on Labview.  I then started tweaking it some more and I was unable to get data to come in again even when reverting back to the initial changes I made.

0 Kudos
Message 6 of 25
(4,912 Views)

At the same time?

 

You still haven't said if you have an error on the error wire.

0 Kudos
Message 7 of 25
(4,910 Views)

I did have the other program open at the same time.  Maybe only one program is able to read from serial at a time?  And could it be that once I have opened the other program, the serial is disabled from labview?  I could try a reboot and not open the other monitor program.

I did not get any error messages, but I will inspect to see if there are any errors on the wire.

 

Thank you

0 Kudos
Message 8 of 25
(4,906 Views)

The default radix for the term character is decimal.

 

Did you change it to hex?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 25
(4,904 Views)

I believe I left it as decimal.  I just used the default constant form for number.  I have always been a little confused between the blue and orange constant.  I suspect it is a different variable type and precision, but I have not researched into it to learn further.

That aside, does a default constant allow for the proper declaration of termination char?

0 Kudos
Message 10 of 25
(4,900 Views)