10-12-2012 10:24 AM
Hello,
I have a program that scans a serial number and gives an output.
Rightnow, I scan the serial number and hit run on the laview toolbar.
But, I want to program it so that when the user scans a number it would automatically output results, without me hitting run or an OK button continuously.
I have attached my vi below.
So, does anyone have any tip for me on how I could go about that?
Thanks a lot in advance,
Yeshani
Solved! Go to Solution.
10-12-2012 11:42 AM - edited 10-12-2012 11:45 AM
Just some feedback. Your VI needs a timeout inside the while loop or it will use up most of your cpu.
I can't see from the code where the scanning is done, so I assume that you are inputting the values of the serial number. In this case, you would just add an event structure and create a case for the serial number and exit button as shown below. You still have to hit the run button to execute the code, which is true for any VIs in editor mode. The code will not terminate unless the exit button is pressed. Everytime the serial number changes, the code will automatically output the results.
If you were using a barcode scanner, you would have to create a case to read from the the barcode scanner then process the information.
10-12-2012 01:37 PM
Hi,
Here is a version that uses polling. The input has it's properties so that it doesn't update untill you hit enter.
The reference is actually a local variable.
Polling and local variables are not often smiled upon, but for "just a text entry" app, it should work well.
10-12-2012 02:38 PM
Mark The event structure now ships with all versions of LabVIEW. polling is now passe!
10-15-2012 10:08 AM
Hi Jeff,
I agree, and I always put some notification to that effect in my posts. I generally assume that folks with issues that post VI's without event structures just want a simple solution for a short term problem. Hopefully they are continuing to use LabVIEW and will move up to event structures.
10-23-2012 10:49 AM
Hello Mark,
Thank you very much! I am still learning labVIEW and quite new to this. I tried to understand your modifications but still have trouble. Would you please explain the use of shift regieter here and what kind of node you have there for String.
I really appreciate it.
10-24-2012 03:21 PM
Hi nikk07,
There is a good example about the concept behind a shift register here. Essentially they give you the ability to retain data through different iterations of a loop.
There is also some information about string constants here. I believe this is what you were referring to in the second part of your question.
10-25-2012 10:46 AM
Thank you!!