12-01-2015 09:41 AM
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?
12-01-2015 11:57 AM
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?
12-01-2015 12:27 PM
A few things that will help us help you:
Sorry if that sounded grumpy
12-01-2015 01:19 PM
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
12-01-2015 02:08 PM
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.
12-01-2015 02:13 PM
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!
12-01-2015 02:22 PM
@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!
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!
12-01-2015 02:24 PM
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.
12-02-2015 08:12 AM
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?
12-02-2015 09:07 AM
Discussion continued here: http://forums.ni.com/t5/LabVIEW/Reading-Serial-and-DAQ-in-Same-While-Loop/m-p/3224140#U3224140