LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem running two parallel while loops

Solved!
Go to solution

Hi everyone,

       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.

 

Regards,

Avi0111

0 Kudos
Message 1 of 95
(3,065 Views)

avi0111,

 

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.

 

Lynn

Message 2 of 95
(3,038 Views)

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.

Message 3 of 95
(3,036 Views)

Thank you, unfortunately I am not on the PC that has LV, so I will not be able to implement you suggestions until tomorrow.

 

Thanks again,

avi0111

0 Kudos
Message 4 of 95
(3,020 Views)

Hi, Can I use two Visa timeouts prior to the while loops to override the default 10 second timeout? Attached is a screenshot.

 

Regards,

avi0111

0 Kudos
Message 5 of 95
(2,988 Views)

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.)

Message 6 of 95
(2,981 Views)

Hello,

    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.

Avi0111

 

0 Kudos
Message 7 of 95
(2,935 Views)

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.

0 Kudos
Message 8 of 95
(2,931 Views)

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?

 

Regards,

avi0111

 

0 Kudos
Message 9 of 95
(2,913 Views)

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.

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.
Message 10 of 95
(2,899 Views)