From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

heed help troubleshooting VI

Hi all,
I have a LabVIEW vi that reads a string from a barcode scanner. If the string starts with letter "L" then it is a wrong item that got scanned. And the LV program will display an error message, and clear string and set cursor at begnning again.
When I run the vi under debug mode, it works fine. But when I run under regular mode then the error shows up and then dissapears right away. Something wrong with my logic that I can't figure out. (see attached vi)
Please help.
Thanks
 
 
0 Kudos
Message 1 of 8
(3,123 Views)
Hey dphan! It appears to run correctly on my machine. What exactly was the error again?
 
Also just a question, have you considered adding a delay, something like 200-500 microseconds, to your while loop? It would run a little smoother.
 
-- Matt
0 Kudos
Message 2 of 8
(3,119 Views)

Hi Matt,

Thank you for quick responding. The problem that I had was the error message will appears for a quick second, then dissappears right away without me clicking on the OK icon.

dphan

0 Kudos
Message 3 of 8
(3,117 Views)

Hi Matt,

It works now after I put a delay on the while loop.

Thanks

dphan

0 Kudos
Message 4 of 8
(3,113 Views)
Typically, if adding timing determines if something works or not indicates a race condition in the code. "Fixing" it with a delay may mask the problem until next time you upgrade your LabVIEW version or computer. This is not a recommended solution. Still, I don't see any potential race condition.
 
I cannot reproduce your error, but a delay is always recommended, else this loop spins millions of times per second, consuming all CPU.
 
In addition to adding a small delay, here are a few more tips..
  1. On the left, you have two property nodes for the same control. Use one property node with two entries instead. Wire the "error out" to the border of the while loop to ensure that the while loop does not start until the initialization has completed. Right now you have no data dependency and it is equally possible that the loop starts first. Here it probably has no ill effects, but it is good practice to ensure proper sequencing.
  2. You do two comparisons linked by AND ("string starts with L" AND "string is not empty"). You can safely remove the "not equal empty" because if the first character is L, the string cannot be empty anyway. 😉
  3. "Update while typing" is a static property. Once you set it it stays that way. It is sufficient to change it once and not every time the dialog box appears.
  4. The inner case structure serves no purpose because the FALSE case can never happen. Delete the inner case structure.
  5. It does not matter in which order you clear the string and set the key focus. You can safely delete the sequence structure. All you need to do in the big TRUE case is probably the following. Reusing the dialog box output automatically ensures that the property write occurs after the dialog has been pressed.

Message Edited by altenbach on 02-13-2007 03:25 PM

Message 5 of 8
(3,107 Views)
Thanks Altenbach! I think I learned a few things from that response as well. I looked his .vi over for any possible race conditions, but couldn't find any but (there always is a but) race conditions I get the feeling are chameleons and I'm still by every definition of the word, an amateur LabVIEWer.
0 Kudos
Message 6 of 8
(3,090 Views)

Thanks Altenbach. I'm glad that this forum has you! I made the modification according to your suggestion. But still there is on minor issue. I did not see the vertical cursor appears in the string box (KeyFocus related) after clicking OK on the pop up message. But it works OK if I run debug mode. Any idea ?

Regards

dphan

0 Kudos
Message 7 of 8
(3,077 Views)
I don't know if it is a good fix. But adding a 50ms delay make it work fine.
Thanks for all the help.
dphan 
0 Kudos
Message 8 of 8
(3,058 Views)