Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple barcode scanner RS-232

Solved!
Go to solution

Hello All,

I will be using 5 RS-232 barcode scanner with RS-232 to USB converters.

I want to read the barcodes/string only when the operator triggers the barcode scanner, i.e. dont want to read the port all the time.

how can I do it ??

 

Thanks

0 Kudos
Message 1 of 3
(3,240 Views)

How does this trigger look like?

 

20 years ago the rs232 scanner where always connected to the PC/controller and just send data when the operator pulled the trigger AND there was a successful scanning. Has that changed?

 

While you can monitor all 5 serials in parallel , I assume the some ms delay doesn't hurt.

So all you need is one producer loop with an event and 5 registered (bytes at port) events ...

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 2 of 3
(3,199 Views)
Solution
Accepted by topic author james_p_martin

James,

 

I sent you a reply to the PM you sent me.  If I have your email address, I'll send you a framework based on what I described in the other forum thread you referenced.  It's not that complex, but it does use a few techniques a beginning LabVIEW programmer might stumble over.  It's the most elegant solution (IMO) to allow a variable number of barcode readers to all be processed efficiently.

 

For anyone else following:

  • an array of VISA refnums for the variable number of virtual com port barcode devices, passed to a for loop, launches (via asynchronous call by reference) a reentrant handler;
  • each handler instance does a VISA read (with short timeout) on its port, in a while loop; if it doesn't time out, it generates a user event with the port ID and scanned data;
  • an event structure (which presumably handles lots of other application activity) is registered to process the user events;
  • closing down the application destroys the user event, so the handlers quit looping and go out of scope on event invalidation.

VISA reads are fully reentrant and consume almost no CPU while waiting for data to show up.  The consuming event structure presumably sleeps (or does other useful work) and gives immediate attention to the arrival of scan data.  The code doesn't need to be revisited whether you have two ports or two dozen - that's handled at runtime.

 

Best regards,

Dave

 

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 3 of 3
(3,192 Views)