Shop OBEX P1 Docs P2 Docs Learn Events
Interface a RS232 barcode scanner to BS2p24 — Parallax Forums

Interface a RS232 barcode scanner to BS2p24

JRooseJRoose Posts: 2
edited 2006-11-04 13:37 in BASIC Stamp
Dear "Forum",

I would like to interface a RS232 barcode scanner to my BS2p24.

Can you help me with some ressources (hard & soft) ? applications ?

I allready search on the net, but didn't find anythink good.

In advance, I appricate your help.

Note : In attachement, datasheet scanner

Comments

  • John R.John R. Posts: 1,376
    edited 2006-11-02 18:50
    Ich can nicht ferstehen deinen data sheet. (and that is the extent of my German, and it's probably botched as it is).

    You'll need something to confert from RS-232 Voltage levels down to TTL. If you're using something like the BOE or another "development" board, you could probably use the serial connection that is used for programming (assuming you have a "serial" version).

    Once that is present, the scanners usually send ASCII codes down the wire. Depending on the configuration of the scanner (and they are usually programmable), there may be some control characters in addition to the actual characters/digits of the bar code data. You'd use "serial in" to read the data.

    Sketchy, I know, but a start smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • metron9metron9 Posts: 1,100
    edited 2006-11-03 00:50
    Perhaps this English document would be better for those not fluent in German.
    http://www.leuze.de/downloads/log/06/z-3070_e.pdf

    Nothing in the way of timing though, You could use a scope th the TX pin and see what comes out.

    Wow I have never used the word English in a sentence before and it really looks foreign to me. Hmmm so does the word Foreign, Hey this new Firefox spell checker is really going to improve my vocabulary when posting on forums.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • KatyBriKatyBri Posts: 171
    edited 2006-11-03 02:27
    There should be additional information in the datasheet and/or app notes to explain how to program the scanner, and usually tech data on the data stream is available from the manufacturer's technical service folks. This should help you pick apart/or use·the data stream with the STAMP.

    I used many scanners over the years and interfaced them to computers using what are called "wedges". Most had a keyboard wedge available which allowed one to plug the keyboard into one of the scanner's cables, while the remaining cable was plugged into the keyboard's port on the computer. The wedge made the computer think the scanner was the keyboard talking. They worked great.
  • John R.John R. Posts: 1,376
    edited 2006-11-04 01:52
    First, depending on what cable you have, the output from the scanner will need to be handled different. If you have a PS2 or USB cable, the scanner is in essence a "keyboard".

    You also want to get the Quick Setup Barcode Manual
    www.leuze.de/downloads/log/06/users_quick_setup_barcode_manual_e.pdf is the English version.

    If indeed you have an RS-232 cable, then there are two things you'll have to deal with. One is capturing the signal: see my post above on conceptually how to deal with that. According the Quick Setup the default Serial port settings are 9600 Baud, 8 data bits, mark parity and 1 stop bit. This can be changed once the unit is fired up (see power below). You change this, as well as other featurs of the scanner by scanning bar codes from the above manual. Once you have the serial port setting matching your serial port driver connected to your microprocessor, you'll recieve any barcode scanned as a string via a SERIN or similar command. For the RS232 configuration, you also have a choice of "message termination". This is a character(s) that are appended to any bar code that is read (Nothing is also a choice).

    The second (or probalby first) item you'll need to deal with is getting +5 volts supplied to Pin 9 of the conecter. This is the power for the scanner.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • JRooseJRoose Posts: 2
    edited 2006-11-04 13:37
    Hello !

    First of all thanks for your answers and advices !

    I found there enought inspiration to book some results by myself.

    Thanks the· quick-set-up guide programming card,·I config the scanner in RS-232 mode with·9600,8,1,N parameters (+ 'CR at the end). Then I connect PIN 2 (TX from scanner) trought a 22K resistor to input P0 from BS2p and also the GND (pin 5) of course.

    Scanner is powered separately.

    Then with some trial and error and the DEBUG terminal, I reached the wanted result with the command SERIN.

    I recieved ASCII codes and at the end a 'CR' command. I substract 48 from the ASCII command until 'CR', I found de expected decimal values. Then·I just had to concatenate de different digit to gat the scanned value.

    When done I used a LCD display to show the scanned value.

    It's working very well and I'm happy with that !

    Again, thanks for your help (out of the box ...)



    John Roose
Sign In or Register to comment.