AnsweredAssumed Answered

Integrating a bar code reader

Question asked by VRFuser on Nov 25, 1997
Latest reply on May 3, 2014 by cindy313
Troy Weeks wrote:
>
> Hello,
> Has anyone integrated a bar code reader into their system?
>
> I am considering implementing one and I am curious if there is someone out
> there who has gone through the implementation.
>

Troy,
We use scanners from both MicroScan and Sick Optic. Both are interfaced
with standard RS232. You simply send ASCII commands (defined by the
scanner manufacturer) via direct I/O to the COM port. I use a Repeat
Until Break object connected to the sequence pin of the direct I/O
object. Put a short timeout on the I/O, but something long enough to
have time to read the data (experiment with this). Add an error pin to
the direct I/O object that is not connected to anything. When there is
no data, the error pin fires. To prevent hanging forever, I nest this
with a delay object that causes the parent object to exit with a timeout
error message.

I've included a piece of a program as an example below.

John

------------------------------------------

(saveFormat "2.0")
(date "Wed 26/Nov/1997 14:30:17 ")
(veerev "3.21")
(platform "PC")
(Colors
(Property "Detail View" "Lightest Gray" bwGrayScale 10)
(Property "Panel View" "Light Blue Gray")
(Property "Line Color" "Black" bwGrayScale 100)
(Property "Tool Tip" "Pale Yellow" bwGrayScale 0)
(Property "Tool Tip Text" "Black" bwGrayScale 100)
(Property "Object Title" "Blue Gray" bwGrayScale 30)
(Property "Object Title Text" "Black" bwGrayScale 100)
(Property "Object" "Light Blue Gray")
(Property "Object Text" "Black")
(Property "Object Shadow" "Darkest Gray")
(Property "Object Step Highlight" "Yellow")
(Property "Object Execute Highlight" "Light Green")
(Property "Object Error Highlight" "Red")
(Property "Object Breakpoint Highlight" "Orange")
(Property "Dialog Box Title Bar" "Dark Blue" bwGrayScale 30)
(Property "Dialog Box Title Bar Text" "White" bwGrayScale 100)
(Property "Dialog Box" "Gray")
(Property "Dialog Box Text" "Black")
(Property "Graph Background" "Black" bwGrayScale 0)
(Property "Trace Pen 0" "Black" bwGrayScale 100)
(Property "Trace Pen 1" "White" bwGrayScale 100)
(Property "Trace Pen 2" "Red" bwGrayScale 100)
(Property "Trace Pen 3" "Green" bwGrayScale 100)
(Property "Trace Pen 4" "Yellow" bwGrayScale 100)
(Property "Trace Pen 5" "Blue" bwGrayScale 100)
(Property "Trace Pen 6" "Magenta" bwGrayScale 100)
(Property "Trace Pen 7" "Cyan" bwGrayScale 100)
(Property "Trace Pen 8" "Dark Yellow" bwGrayScale 100)
(Property "Trace Pen 9" "Dark Gray" bwGrayScale 100)
(Property "Edit Field" "White")
(Property "Edit Field Text" "Black")
(Property "Highlighted Edit Field" "Dark Blue")
(Property "Highlighted Edit Field Text" "White")
(Property "Menu" "Gray")
(Property "Menu Text" "Black")
(Property "Disabled Menu Text" "Dark Gray")
(Property "Highlighted Menu" "Dark Blue")
(Property "Highlighted Menu Text" "White")
)
(Fonts
(Property "Menu Text" "Arial" 14)
(Property "Object Title Text" "Arial" 14)
(Property "Object Text" "Arial" 14)
(Property "Object Description Text" "Courier New" 14)
(Property "Terminal Text" "Arial" 12)
(Property "Notepad Text" "Courier New" 14)
(Property "Logging AlphaNumeric Text" "Courier New" 14)
(Property "AlphaNumeric Scalar Text" "Arial" 18)
(Property "AlphaNumeric Array Text" "Arial" 14)
(Property "Bus Monitor Text" "Courier New" 14)
(Property "Dialog Box Title Bar Text" "Arial" 14)
(Property "Dialog Box Text" "Arial" 12)
(Property "Instrument Driver Help Text" "Courier New" 12)
(Property "Instrument Driver 9x15 Text" "Courier New" 15 bold)
(Property "Instrument Driver 15x25 Text" "Courier New" 23 bold)
(Property "Printout Page Header Text" "Arial" 14)
(Property "Printout Object Title Text" "Arial" 14)
(Property "Printout Object Description Text" "Arial" 14)
(Property "ToPrinter Printout Text" "Courier New" 14)
)
(SaveCF yes)
(filterNAN 0)
(component 0 ROOTCONTEXT
(name "Untitled")
(implementation
  (retainGlobals YES)
  (locked no)
  (trigMode deg)
  (nextID 25)
  (component 13 IODEVICE
   (name "BARCODE_SCANNER ( @ (NOT LIVE))")
   (interface
     (output 1
      (type exception)
      (name "Error")
      (lock name constraints)
      (optional yes)
     )
   )
   (implementation
     (transactions 2
       "/NOP/ WRITE TEXT "<Kg1>" EOL"
       "WRITE TEXT "<H>" EOL"
     )
     (comp iopath "BARCODE_SCANNER")
   )
  )
  (component 24 START25
  )
  (component 17 IFTHENELSE
   (interface
     (input 1
      (name "A")
      (optional yes)
     )
     (output 1
      (name "Then")
      (lock name constraints)
     )
     (output 2
      (name "Else")
      (lock name constraints)
     )
   )
   (implementation
     (expr "(strFromLen(A, 0, 1)=="#" AND A!="#35-216001-26" ? A : 0)")
   )
  )
  (component 23 LITERALCONSTANT
   (name "no barcode label detected")
   (interface
     (output 1
      (name "Text")
      (lock name constraints)
     )
   )
   (implementation
     (value Text
      (data  "#NO BARCODE")
     )
     (initValue Text
      (data  "")
     )
   )
  )
  (component 15 IODEVICE
   (name "BARCODE_SCANNER ( @ (NOT LIVE))")
   (interface
     (output 1
      (name "bc_data")
      (lock constraints)
      (optional yes)
     )
     (output 2
      (type exception)
      (name "Error")
      (lock name constraints)
      (optional yes)
     )
   )
   (implementation
     (transactions 1
       "READ TEXT bc_data STR"
     )
     (comp iopath "BARCODE_SCANNER")
   )
  )
  (component 20 IFTHENELSE
   (name "Error Message ?")
   (interface
     (input 1
      (name "A")
      (optional yes)
     )
     (output 1
      (name "Then")
      (lock name constraints)
     )
     (output 2
      (name "Else If")
      (lock name constraints)
     )
     (output 3
      (name "Else")
      (lock name constraints)
     )
   )
   (implementation
     (expr "(strPosStr(A, "ERROR")>=0 ? A : 0)")
     (expr "(strPosStr(A, "ERROR")<0 ? A : 0)")
   )
  )
  (component 21 EXITCONTEXT
  )
  (component 19 JUNCTION
   (name "JCT")
   (interface
     (input 1
      (name "A")
      (lock name constraints)
     )
     (input 2
      (name "B")
      (lock name constraints)
     )
     (input 3
      (name "C")
      (optional yes)
     )
     (output 1
      (name "Data")
      (lock name constraints)
     )
   )
  )
  (component 14 REPEATUNTILBREAK
   (interface
     (output 1
      (name "Continuous")
      (lock name constraints)
     )
   )
  )
  (component 22 DELAY
   (interface
     (output 1
      (name "Done")
      (tag "Done")
      (lock constraints)
     )
   )
   (implementation
     (delay 2)
   )
  )
  (component 16 IFTHENELSE
   (name "Not Timeout ?")
   (interface
     (input 1
      (name "A")
      (optional yes)
     )
     (output 1
      (name "Then")
      (lock name constraints)
     )
     (output 2
      (name "Else")
      (lock name constraints)
     )
   )
   (implementation
     (expr "(A!=811 ? A : 0)")
   )
  )
  (component 18 FORMULA
   (name "Vee Error Text")
   (interface
     (input 1
      (name "A")
      (optional yes)
     )
     (output 1
      (name "Result")
      (lock name constraints)
     )
   )
   (implementation
     (expr 1 ""ERROR: Barcode scanner - HP VEE ERROR CODE "+A")
   )
  )
  (configuration
   (connect D1:0 D0:0)
   (connect D4:1 D2:1)
   (connect D9:1 D3:0)
   (connect D8:1 D4:0)
   (connect D7:1 D5:1)
   (connect D5:0 D6:0)
   (connect D3:1 D7:1)
   (connect D2:1 D7:2)
   (connect D11:1 D7:3)
   (connect D0:0 D8:0)
   (connect D1:0 D9:0)
   (connect D4:2 D10:1)
   (connect D10:1 D11:1)
  )
)
(viewFor -1
  (active detail)
  (detail
   (geometry 0 28 1280 958)
   (configuration
     (viewFor 13
      (active icon)
      (icon
       (geometry 78 346 317 51)
       (iconImage "io.icn")
      )
      (detail
        (geometry 233 509 293 74)
       )
      (terminals on)
     )
     (viewFor 24
      (active icon)
      (icon
       (geometry 313 272 34 16)
      )
      (detail
       (geometry 282 221 49 20)
      )
      (title off)
     )
     (viewFor 17
      (active icon)
      (icon
       (geometry 564 498 93 25)
      )
      (detail
            (geometry 289 605 453 50)
           )
      (terminals on)
     )
     (viewFor 23
      (active icon)
      (icon
       (geometry 420 383 201 15)
      )
      (detail
               (geometry 250 208 237 29)
             )
     )
     (viewFor 15
      (active icon)
      (icon
       (geometry 212 505 317 51)
       (iconImage "io.icn")
      )
      (detail
            (geometry 318 679 263 74)
           )
      (terminals on)
     )
     (viewFor 20
      (active icon)
      (icon
       (geometry 941 493 119 34)
      )
      (detail
               (geometry 806 339 269 62)
             )
      (terminals on)
     )
     (viewFor 21
      (active icon)
      (icon
       (geometry 941 543 119 15)
      )
      (detail
             )
      (terminals on)
     )
     (viewFor 19
      (active icon)
      (icon
       (geometry 896 493 28 34)
      )
      (detail
               (geometry 1059 739 12 62)
             )
      (terminals on)
     )
     (viewFor 14
      (active icon)
      (icon
       (geometry 197 415 86 51)
       (iconImage "loop.icn")
      )
      (detail
             )
      (terminals on)
     )
     (viewFor 22
      (active icon)
      (icon
       (geometry 418 353 45 15)
      )
      (detail
               (geometry 230 535 81 31)
             )
     )
     (viewFor 16
      (active icon)
      (icon
       (geometry 575 548 110 25)
      )
      (detail
               (geometry 472 415 137 51)
             )
      (terminals on)
     )
     (viewFor 18
      (active icon)
      (icon
       (geometry 717 543 126 15)
      )
      (detail
               (geometry 448 414 464 32)
             )
      (terminals on)
      (titleBg "Red")
      (titleFg "White")
      (titleFont "lucida" 14 bold)
     )
     (connect D1:0 D0:0
      (points 4 330 290 330 310 236 310 236 343)
     )
     (connect D4:1 D2:1
      (points 4 531 520 540 520 540 510 561 510)
     )
     (connect D9:1 D3:0
      (points 3 465 360 520 360 520 380)
     )
     (connect D8:1 D4:0
      (points 3 285 440 370 440 370 502)
     )
     (connect D7:1 D5:1
      (points 2 926 510 938 510)
     )
     (connect D5:0 D6:0
      (points 2 1000 529 1000 540)
     )
     (connect D3:1 D7:1
      (points 4 623 390 690 390 690 500 893 500)
     )
     (connect D2:1 D7:2
      (points 4 659 500 680 500 680 510 893 510)
     )
     (connect D11:1 D7:3
      (points 4 845 550 870 550 870 520 893 520)
     )
     (connect D0:0 D8:0
      (points 2 236 399 240 412)
     )
     (connect D1:0 D9:0
      (points 4 330 290 330 320 440 320 440 350)
     )
     (connect D4:2 D10:1
      (points 4 531 540 550 540 550 560 572 560)
     )
     (connect D10:1 D11:1
      (points 2 687 550 714 550)
     )
   )
   (stackingOrder 0 8 4 10 2 11 7 5 6 9
      3 1)
  )
  (titleBg "Gray")
  (titleFg "Black")
  (numberFormats
   (realFormat standard)
   (realSigDigits 4)
   (realRadixSpec 4)
   (integerBase decimal)
  )
)
)

Outcomes