LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication: VISA Reading too fast

Hi all,

 

I'm trying to read from weight measurements using a serial connection.

 

In my VI, I can store the scale in string format to a build a text file. But when I try to parcel the information, I found that the "read" loop is reading data before the serial port can send it. 

 

Is there a way to have my read loop only perform only when all 20 bytes of data are ready to be sent?

 

 

0 Kudos
Message 1 of 10
(4,924 Views)

bytes at port.png

 

This is what you're asking for, but I am not sure it will solve your problem.  Is the hardware you're talking to just supposed to send 20 bytes of data in chunks on a regular basis? 

Message 2 of 10
(4,894 Views)

A few things that will help us help you:

  1. Backsave that vi!  2015 is wonderful but, we all don't have it installed yet, Smiley Embarassed or use a snipett so we can see your code.
    Spoiler
     
  2. Tell us what the device on the other end is!  "Weight Measurments" will give us all a clue- but, What are you using for a gauge? Manufacture.r and Model would help us help you a lot.  Golly Gee! you could post a link to the user's manual for the "Mystery" device!  we have experience reading the friendly manual (RTFM) and could help you better interperate the serial protocol if we knew what was on the other end!

Sorry if that sounded grumpy


"Should be" isn't "Is" -Jay
Message 3 of 10
(4,888 Views)

If you specify End Read on Termination Character and you correctly specify the Character, you should set up your VISA read to read 1000 bytes (assuming that your device sends bytes in, say, "approximately 20 byte" packets).  It should wait patiently (you should also specify a Timeout, or use the default 10 seconds to detect Something Really Wrong) until it has a complete string for you, and simultaneously present that string.  Process, rinse, repeat ...

 

Bob Schor

Message 4 of 10
(4,869 Views)

Even some sample data of typical messages from the instrument would help us out here.  But a good link to the instrument you are using would be the biggest help.



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 5 of 10
(4,849 Views)

The data sheet stated that this myWeigh i601 scale uses sends 20 data points, but it is actually 22. I got the program to work. Thank you all for your response!

scale cap.PNG

Message 6 of 10
(4,842 Views)

@smat123 wrote:

The data sheet stated that this myWeigh i601 scale uses sends 20 data points, but it is actually 22. I got the program to work. Thank you all for your response!

scale cap.PNG


We could probably get that to work more robustly.  Let us know if you need a bit more help in the future.  Functional code is nice to have and, a darned lot better than broken code!  Congrats!


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 10
(4,836 Views)

That Flush I/O Buffer is not something you normally want to happen repeatedly.  It is usually ok to have as part of initialization, but not after every read.  You are likely going to be throwing away data because of that.



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 10
(4,831 Views)

Hello everyone, 

 

So I have a follow up question:

 

I'm trying to incorporate another reading from a DAQ device in this while loop. The DAQ is slowing down the read while loop, which is causing the serial com to not iterate as the bytes are being read one by one, and therefore it skips over iterations and never lands on (when bytes at port = 22 ).  

 

Is there a way to line up / sychronize the readings ? 

 

Should I use a queue for incoming weight data and dequeue it once the array is at 22 bytes? 

 

0 Kudos
Message 9 of 10
(4,781 Views)

Discussion continued here: http://forums.ni.com/t5/LabVIEW/Reading-Serial-and-DAQ-in-Same-While-Loop/m-p/3224140#U3224140



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 10 of 10
(4,763 Views)