I am new to Labview and the is basically my first attempt. I am planning to acquire data from two weigh scales simultaneously through two different ports. When I run my attached program with the execution highlighted, the second loop gets a higher priority. How do I prevent this? Also, I get error codes when the execution gets to the step where data from Visa read is passed to Scan from String function. Please suggest the corrections to correct these issues.
PS: I have not yet connected it to the devices, thats why the connection properties for both the Ports are same at this time.
Solved! Go to Solution.
When a program runs differently under execution highlighting, it is usually a sign of some kind of timing problem.
In your case you have several timing problems. You set Milliseconds to Wait on each loop. Since you did not make your values default, the controls reset to zero, so I do not know what values you used. You then use the Tick count output from the Wait function as the Byte Count input to the VISA Read. Did you look at those values? I am getting 3200000 on my computer now and it changes on every iteration of the loops. Do you intend to wait for 3 million characters before the Read completes? The default timeout for the VISA configure is 10 seconds. Since you cannot read 3 million characters in 10 seconds at 9600 baud, you will get a timeout error. Since 10 seconds is probably larger than the milliseconds to wait values, the Wait functions will complete long before the Read times out.
Since you are feeding one U32 value to chart on each iteration, it appears that you expect to receive 4 characters on each read. Do the scales send any framing or control characters (such as a termination character)? Do they send anything besides the numeric values? If the scales do send other information, you need to parse it. If they do not, you need to disable termination characters.
I cannot suggest how to fix your VI until I know more about the communication protocol.
You don't really need 2 different loops. I don't see any problems but then I changed the bytes to read to 0 to avoid the timeout problem. Your wiring the bytes to read to the wait output does not make any sense. You will probably use a fixed byte count.
The error is expected since you don't have a string to parse.
Thank you, unfortunately I am not on the PC that has LV, so I will not be able to implement you suggestions until tomorrow.
Hi, Can I use two Visa timeouts prior to the while loops to override the default 10 second timeout? Attached is a screenshot.
You can. But why do you need to add those? The Serial Config VI has an input to the top side left that is the timeout connector. Just wire your value to that!
(Tip: Turn on Context Help with Ctrl-H and hover over the Serial Config VI.)
I had an issue with the LV software on my PC and finally got it resolved. So now I can connect to the serial port on my Weigh Scale. But, I need some clarification on the error regarding Scan from String command. See attached screenshot for a description. How do I format the string with respect to the data coming from the scale? I have a manual from the scale manufacturer describing serial interfaces for the device, but I am not certain on how to ccorrelate that with LV requirements.
Thanks for all the help.
Why are you requesting zero bytes to read? As a result, you are getting an empty string. And the Scan from String yields an error trying to decode that since it isn't in the expected format.
Since the manual says it sends a linefeed as the termination character (which is how your serial config VI is set up). Just read a sufficiently large number of bytes and the VISA read will end when it gets the termination character. The messages are either 16 or 22 bytes, so read 22 bytes or more.
Hi, Based on all the recommendations, I found a few errors with the communication protocol settings as well and I have fixed those. I have changed bytes to read to over 22. But I still encounter the Scan to String error. I believe I have to specify a format string based on Pg-4 of the interface manual attached below. The problem is my knowledge regarding parsing or setting up a string format is pretty much non-existent. So can any body point me in the right direction or even point me to the sources from where I can learn about this and incorporate the right method?
Unless the balance is set to autoprint, you have to send it a print command! The VI is most likey reading nothing. Put a probe on the ouptut of your reads so you can see what, if anything, you are getting.