Discussion:
USB Barcode Event
(too old to reply)
Pablop
2008-04-02 16:40:12 UTC
Permalink
My programs are heavily dependent on Event Structures. Once you start using them though, they are hard to get away from. The User's Test Interface is essentially tabbed panels with buttons on them for launching some activity, so event structures work well. I have some event structures with state machines inside for completing various tasks, etc. Now I want to add a USB barcode reader to input the serial number of the UUT during test. The desired scenario will be something like:1) Test Stand has USB barcode reader installed and positioned to read the label on an installed UUT2) Operator installs a serialized label on UUT3) Operator installs UUT on test stand4) Operator presses Test buttonThen, within the state machine for testing, I would scan the serial number first, a successful scan being required to continue the test.Can a USB barcode scanner be implemented in this fashion, that is, be told to "Read" at a certain time, or does it Read all of the time as soon as a label is flashed in front of it? Is there a way to prod it to read at a specified time?We are looking at the Symbol MS-4407-1000R barcode reader.Thanks,
pallen
2008-04-02 18:40:10 UTC
Permalink
Hello Paul, I'm not familiar with that exact barcode reader, and I couldn't find anything online about it.&nbsp; Still, it's probably similar to many scanners I've used in the past so I'll try. Some readers will read all the time.&nbsp; Some you can control via VISA commands.&nbsp; Check your scanner manual for this.&nbsp; In my experience, most scanners are set to read all the time by default.&nbsp; We try to leave these kinds of peripherals default if we can because it makes things much easier for our customer's maintenance department when things are replace. For a scanner the scans automatically, I just put use a VISA read and read all the "bytes at port" in a quick loop and end the loop when I read zero bytes.&nbsp; I do this to ensure that the "buffer" is clear and that when I make my "good" read, I'll know it's the part currently sitting in front of the reader. &nbsp; <img src="Loading Image..."> Good luck. Message Edited by pallen on 04-02-2008 02:16 PM


barcode01.jpg:
http://forums.ni.com/attachments/ni/170/313194/1/barcode01.jpg
Dennis Knutson
2008-04-02 18:40:12 UTC
Permalink
For USB scanners, most emulate a keyboard and VISA will not work. It's only serial scanners that can use VISA. For USB scanners, you just need a string control for data entry.
I did find a product manual and it appears that by default, it scans when something is nearby or you can optionally send it a trigger.
Pablop
2008-04-02 20:40:06 UTC
Permalink
Thanks Dennis, Do you have any examples of how this would be triggered? How is the USB scanner triggered from within LabVIEW, and how is the emulated key board tied to the string control?Thanks.
Dennis Knutson
2008-04-02 21:10:06 UTC
Permalink
I don't know the trigger mechanism for this scanner. It should be in your manual.
A USB scanner that emulates a keyboard is indistinguishable from the normal keyboard. There is nothing to tie a string control to it. It's not any different from a string control where you expect someone to manually type something in. For an event structure, you can use a value change event. With a lot of scanners, you can also program them to append a character (i.e. CR/LF) and have a front panel 'OK' button mapped (Key Navigation) to that. Long before there was an event structure, a simple while loop would work this way.
Pablop
2008-04-21 23:40:11 UTC
Permalink
I'm experimenting with code for this Bar Code Reader application and I hate re-inventing the wheel. I seem to need the UpdateWhileTyping property node set true to make things happen. I notice that this tends to slow the data entry to typing speed, not sure of that's a problem or not, I just noticed it. I want the program to scoop the serial number out of the control and not have the operator need to "check" off the value. Is there a better way to do this?What I want is for the program to be "waiting" for appropriate serial number data and then acting on it. In this example I equated appropriate to 12 characters.Any suggestions out there?


BarCodeRead.vi:
http://forums.ni.com/attachments/ni/170/317829/1/BarCodeRead.vi
TMC-NI
2008-04-23 04:10:05 UTC
Permalink
Hi Paul,
&nbsp;
I'm a bit unclear about that last post.&nbsp; Does "appropriate serial number" mean appropriate based on the number of digits or appropriate as in the serial number is in a list (therefore exists in a database or array or sorts)?
&nbsp;
Can you expand on what you'd like to do?
Pablop
2008-04-24 20:10:09 UTC
Permalink
Hello Tolga, I've made some progress, see attached VI. This VI represents my Main VI in that it uses an Event structure and a tab control, both of which are key essentials in my existing main porgram. Things that I want to do with bar code read of serial numbers in my main program include:Enable or disable the requirement for serial numbersEnable or disable the Test buttom based on valid serial number or whether or not a serial number is requiredThese issues I seem to have addressed, but...The main issues I'm having are centered around the fact that the reader is easiest to employ as a USB keyboard emulator. There may be programtic methods of controlling the device, but I'm hesitant to delve into that at this time if I can make the emulator method work satisfactorily.As a keyboard emulator though, there are some drawbacks.1) A string Control requires the Key Focus in order for the code to be input to it. Therefore, I have to programatically give the string control the focus, this has ramifications.2) Since I need the focus in the control string, I'm having trouble getting to other pages of the Tab control. See attached VI which so far fails to do this.3) Any input feature on the panel may react to the act of "reading" if that feature has the Key Focus. Similar to pressing the Space Bar or&nbsp; Enter button on the keyboard. So, if my "Test" button has the focus, and someone places a readable serial number in front of the reader and it beeps, its tantamount to pressing the Test button. That's a bummer :(4) Giiven item 3) above, its ironic that the beep on the reader isn't suffcient impetus to complete the string control input, the only way I have found around this is to enable the UpadateWhileTyping propoerty of the string control. If I don't enable this, the string size is zero in the loop of the attached VI.Any advice would be appreciated. Kind of a long post. I may end up having to the control the reader as I would a serial device. Not sure how to do that, but a previous post in this thread may help there.3) I haven't come up with a way to tell what's in the input control string without enabling UpdateWhileTyping.


BarCodeRead.vi:
http://forums.ni.com/attachments/ni/170/318856/1/BarCodeRead.vi
Pablop
2008-04-28 18:40:11 UTC
Permalink
Hello Pallen,Well, I've about exhuasted the keyboard simulator use of the bar code reader, too many downsides as can be seen by my last post.I've decideded to proceed with using the reader as a serial port device thinking it will be more controllable. I'm trying to impliment your scheme, see attached jpeg.I've configured the reader as "Simple COM Port Emulation" and verified that Windows installed the device on COM 2, but no luck geting the read buffer string indicator to show anything yet.Have I interpreted your scheme correctly? Doesn't the loop as shown just fill the read buffer string control with 0 bytes everytime around?Message Edited by Pablop on 04-28-2008 11:37 AM


serialread1.jpg:
Loading Image...
lmtis
2008-04-28 20:10:05 UTC
Permalink
Hi Paul,
It looks like your VI will onlt exit the while loop if the string length is=0, therefore if it ends, there was no data to display.&nbsp; Also, you do not show how you are triggering the scanner.
Pablop
2008-04-28 20:10:06 UTC
Permalink
The scanner is always reading, I can hear it beep when I place a label in front of it, even though it definetly no longer emulates a keyboard. I realize there is something not right about the loop, I was wondering how pallen intended its use. I'll just fudge around and see if I can come up with my own method.
Pablop
2008-04-28 20:40:08 UTC
Permalink
Hi Jim, Yes, I just implemented it as I saw pallen's example, didn't understand how he inteded its use.I've revised it to the state shown. Works much better now. I've got a starting point for building up the program, should work fine.Thanks again.


serialread1.jpg:
Loading Image...
TonP
2008-04-28 20:40:09 UTC
Permalink
Would a key-down event (in keyboard emulation mode) on a front panel do the trick? Ton
Pablop
2008-04-28 20:40:10 UTC
Permalink
Hi Ton, Ive moved on do to other problems using keyboard emulation, such as the fact that the system does infact have a keyboard as well!I'm also very dependent on Events in my main program and I've heard that mouse and keyboard events can introduce instability, I'd hate for that to happen. I'm kind of a plin jane event guy, it has to be value change for me to use it.The serial port method looks like its going to work out fine. I can have a While Loop running outside the event structure that handles it well.Interesting note to other would-be-event structure users. You haev to wire a constant to the Event Structure Timeout terminal in order for loops outside the structure to be executed. Otherwise, with the default (-1), these outside loops never execute.
nrp
2008-04-28 23:10:04 UTC
Permalink
I agree with TonP, It is quite easy to work with a scanner using the key down event. As the data probably comes from the scanner in a burst or many chars in a second, its painless to use the event structure to buffer the incoming chars, and then periodically check your received string for something you would typically expect from the scanner (i.e. a certain length of data, and then if this length is reached you can search the string for tokens you expect in it). This only requires the main VI front panel to have focus, not an individual string control.I am not sure where you heard that using keyboard and mouse events can cause stability problems? This is certainly news to me.
Pablop
2008-04-28 23:10:05 UTC
Permalink
OK, Sounsd good, I'll investigate the keydown Event. I love event structures.I can't find the thread I was thinking about RE: mouse event, but maybe its a bad rumor and I should forget it!
ASTDan
2008-04-28 20:40:09 UTC
Permalink
I just implemented a bar code reader that read data over the serial port.&nbsp; I triggered my program using VISA events (see attached).
There is also a USB interupt event that you can chooser from.&nbsp; Don't know if that would work for your application.
DanMessage Edited by ASTDan on 04-28-2008 03:26 PMMessage Edited by ASTDan on 04-28-2008 03:28 PM


VISA Event1.vi:
http://forums.ni.com/attachments/ni/170/319629/1/VISA Event1.vi
Pablop
2008-04-28 20:40:11 UTC
Permalink
Hi Dan, Nice code, but how does it work? When I run it, there's no loop or event structure, so it just finishes.Is it supposed to wait at the Visa Wait on Event VI?I can't get anything into the read buffer string indicator. :(
Pablop
2008-04-28 21:10:04 UTC
Permalink
Hi Dan, OK, I put sometime in on the Timeout terminal so it would wait. Now I can read it in.Interesting technique. I'll have to work with it a bit. I wonder how other loops are affected while waiting for this event?
ASTDan
2008-04-28 21:10:06 UTC
Permalink
The magic is you can put the "Wait for event" in another loop.
When&nbsp;that fires you can send the data to another loop using a queue or user event.
DanMessage Edited by ASTDan on 04-28-2008 03:54 PM


VISA Event1.vi:
http://forums.ni.com/attachments/ni/170/319642/1/VISA Event1.vi
dave_helmut
2008-05-01 16:40:07 UTC
Permalink
Howdy,
&nbsp;
I need to do "Simple COM port emulation" as well.
&nbsp;
I put my scanner in that mode, but did not see any COM ports in my device manager.
&nbsp;
I need to use multiple scanners per PC so keyboard emulation doesn't work for that.
&nbsp;
Are you able to see the virtual COM port? How do you know which COM port your scanner receives?&nbsp; Are you able to change the port settings?Thanks!Dave
Pablop
2008-05-01 17:10:10 UTC
Permalink
Hello Dave, I was using a Symbol Technologies (Motorola) scanner, with a USB cable, hence the "virtual" com port. If you have a scanner that has a serial port connector on it, you want to connect it to an existing hard wired serial port on your computer, it will not be a virtual port.If yuo are using a USB connection and want serial port opeeration, you will need to get driver software from the scanner supplier. And most likely set the scanner to emulate a serial port device by scanning in the correct setup code.What scanner are you using?
Continue reading on narkive:
Loading...