LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA framing error with two different COMM ports

I have two different types of measurement intruments (say A and B) that communicate data with my labview program through a USB connection and plain VISA serial, flush buffer, read bytes at port and then read all the bytes available. 

My vi allows you to read two instruments at the same time (two VISA "lines" with each their own COMM port and settings) and when I attach two instruments of the same type (say A + A or B + B) it works fine. But when I take two instruments of a different kind (so A + B),  I always get a "framing error occured during data transfer".

The only thing I can think of that might cause some trouble is the fact that both intruments have a different baud rate (9600 for the first and 115200 for the second). 

Anyone any idea or workaround ?

0 Kudos
Message 1 of 7
(2,080 Views)

@Jan145 wrote:

I have two different types of measurement intruments (say A and B) that communicate data with my labview program through a USB connection and plain VISA serial, flush buffer, read bytes at port and then read all the bytes available. 

My vi allows you to read two instruments at the same time (two VISA "lines" with each their own COMM port and settings) and when I attach two instruments of the same type (say A + A or B + B) it works fine. But when I take two instruments of a different kind (so A + B),  I always get a "framing error occured during data transfer".

The only thing I can think of that might cause some trouble is the fact that both intruments have a different baud rate (9600 for the first and 115200 for the second). 

Anyone any idea or workaround ?


If I had to make a guess - which I do, since I don't have the VI to look at in front of me - I'd say there was something wrong with the code.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(2,063 Views)

What is more likely to be wrong is the way you do the VISA Reads.  There have been numerous posts (and talks at NIWeek by @crossrulz) about not using "Bytes at Port".  You want to set VISA up with the default Termination character, then do a VISA Read with, say, 1000 characters (way more than the message you expect).  Instead of Bytes at Port, you simply do a Read, and check the Error Line -- if there were no characters read (and you timed out, default timeout = 10 sec), you'll get an Error, and can deal with it, otherwise you'll have a complete String from your VISA-sending device.

 

I'd post the link to @crossrulz's video or attachment in this Forum, but don't know it -- I'm sure someone will add it for you to read ...

 

Bob Schor

0 Kudos
Message 3 of 7
(2,056 Views)

@Bob_Schor wrote:

There have been numerous posts (and talks at NIWeek by @crossrulz) about not using "Bytes at Port".


It was actually at VI Week.  VIWeek 2020/Proper way to communicate over serial

 

But I don't think that would be causing a framing issue.  It could be the USB drivers conflicting somehow.  It could be a USB hub power issue, which would reset the devices and causing the framing issues.

 

We just need a lot more information:

  • Let's see the code!
  • What devices are we trying to talk to?


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 7
(2,037 Views)

Apparently this makes little sense. A framing error indicates a malformed character on the wire or alike. Are you using a single USB adapter or two?

The problem may be due to a bad driver. In the past it once occurred to me that this same error was generated but the correct packet was actually received (I used VISA Read directly with no Read Bytes at Port involved), so I simply ignored the error altogether.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 7
(2,034 Views)

@billko wrote:

@Jan145 wrote:

I have two different types of measurement intruments (say A and B) that communicate data with my labview program through a USB connection and plain VISA serial, flush buffer, read bytes at port and then read all the bytes available. 

My vi allows you to read two instruments at the same time (two VISA "lines" with each their own COMM port and settings) and when I attach two instruments of the same type (say A + A or B + B) it works fine. But when I take two instruments of a different kind (so A + B),  I always get a "framing error occured during data transfer".

The only thing I can think of that might cause some trouble is the fact that both intruments have a different baud rate (9600 for the first and 115200 for the second). 

Anyone any idea or workaround ?


If I had to make a guess - which I do, since I don't have the VI to look at in front of me - I'd say there was something wrong with the code.


I would say that is a very good guess 🤣

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 6 of 7
(2,033 Views)

Thanks everyone for the inputs.

I didn't put my code as it was basically the same as the simple serial example. I think the error I made was indeed the "bytes at port" node which I used to read exacly this amount of data. As suggested in the webinar, I removed the node and read way more bytes than I expect (1000 or so) and the vi runs fine (up to now ... ).

0 Kudos
Message 7 of 7
(1,987 Views)