05-13-2018 11:36 AM
Hello,
I’m using the VISA Read to read data from 3 sensors, and occasionally, the graph is plotting sensor output of 0. I believe the issue has to do with timing in my Labview 2017's while loop (see attached pic 0 for my Labview block diagram). Has anyone experienced this issue and how to solve it?
-----------------
Here is a detailed description of my issue:
Hardware configuration:
Problem:
Other Troubleshooting techniques:
05-13-2018 11:48 AM
I think your first problem is you are using Bytes at Port.
Does your incoming data have a termination character? I would guess it does since you have enabled the termination character in your VISA Serial Configure. Take advantage of it! Get rid of Bytes at Port and wire in a constant that is larger than the longest message you ever expect to receive. That way you know you are getting complete messages. Right now, you might be getting incomplete messages which would cause some to channels to be interpreted as zero.
Also, Index Array is resizable. Just drag down the bottom border. The indices will automatically be 0, 1, 2, 3, ... without wiring up any constants. That saves you lots of extra Index Array nodes, wires, and constants.
05-13-2018 12:04 PM - edited 05-13-2018 12:19 PM
In addition to what Ravens Fan pointed out.
Use join numbers to convert 2 U8s to a U16. that will simplify your 2's complement vi Better yet use split array to return the 0th element and the array of sensor data then cat the sensor data array of U8s to an array of I16s (as Altenbach will point out - there is way too much code there you could fit it on a postage stamp!)
The VISA Close is unnecessary but the way you are using it is "Wrong" Did you know you are tring to close a Session with the name of the read buffer?
Try something like this:
The chart is set to "Stack Plots"
05-15-2018 01:25 PM
Thank you for all of your help. We found out the issue is that VISA READ may be misinterpreting my sensor output as a new line of data, and therefore, VISA READ is sometimes grabbing incomplete transfers, and Labview is graphing the incomplete data as 0's.
We solved this issue by creating a while loop, adding shift registers, and making sure I always get 9 bytes of data before plotting them. See attached block diagram for my solution.
05-15-2018 02:05 PM - edited 05-15-2018 02:07 PM
Hi amyle,
there seems to something wrong with your "solution"…
We found out the issue is that VISA READ may be misinterpreting my sensor output as a new line of data
Because YOU explicitely enabled the TermChar at SerialPortInit, using a default LF termchar!
When your communication protocol doesn't use a TermChar then DISABLE it…
Get rid of BytesAtPort! When you want to read exactly 9 bytes then set VISARead to read 9 chars (after disabling the TermChar)! No loop needed, no shift register, no ConcatString, no StringLength…
Are you sure you want to build an array containing a timestamp and 4 zero values when "write to file" is FALSE?
05-16-2018 10:49 AM
@amyle wrote:
Thank you for all of your help. We found out the issue is that VISA READ may be misinterpreting my sensor output as a new line of data
Lesson to learn here: If you are using binary/hex data, turn the termination character off.
And since you know every message is 9 bytes, just tell the VISA Read to read 9 bytes. You are making life way too difficult on yourself.
05-17-2018 11:38 AM
Thanks, I definitely have to clean up my code a bit, but the 0 issue has not returned.
06-22-2022 10:17 AM
hello,
Can you share your final VI???