Hot!How to receive data from Barcode Scanner (Reader) ?

Page: 123 > Showing page 1 of 3
Author
softlab
Super Member
  • Total Posts : 290
  • Reward points : 0
  • Joined: 2011/03/30 09:26:30
  • Location: 0
  • Status: offline
2018/04/27 07:18:47 (permalink)
0

How to receive data from Barcode Scanner (Reader) ?

Dear friends,
 
PIC MCU : PIC16LF1847
IDE        : MPLAB v8.89
COMPILER: HI-TECH-C v9.83
OS: Windows 7 (32 bit)
 
I have connected barcode scanner (PS2050 - Postektronics - USB2.0 type) to PC and data received on Terminal (notepad) correctly. Now, I have to integrate the scanner into PIC MCU. I have used USB2.0 to TTL Converter board to receive the data from the Barcode. When I connected the scanner, it powered and read the barcode but no data received in PIC MCU. Do I need any more to do to receive the data to PIC MCU? Does anyone have the barcode scanner experience?
Added:
1. Connected to PIC MCU's EUSART TX & RX pins.
2. Scanner set at 9600 baud rate & RS232 output
3. In PIC, set at 9600 baud rate
 
thanks,
pmk
 
 
 
post edited by softlab - 2018/04/27 07:23:25
#1

58 Replies Related Threads

    GoEk
    Senior Member
    • Total Posts : 111
    • Reward points : 0
    • Joined: 2012/09/27 00:32:28
    • Location: Sweden
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 07:42:00 (permalink)
    0
    What is an "USB to TTL" converter? You do realise that USB is nothing like asynchrounous serial communication? For example, a USB host has to initiate a read from a device, data doesn't just arrive like on a serial port receiver.
    post edited by Goran Ekstrom - 2018/04/27 07:43:05
    #2
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 07:43:30 (permalink)
    +1 (1)
    I have connected barcode scanner (PS2050 - Postektronics - USB2.0 type) to PC and data received on Terminal (notepad) correctly. Now, I have to integrate the scanner into PIC MCU. I have used USB2.0 to TTL Converter board to receive the data from the Barcode. When I connected the scanner, it powered and read the barcode but no data received in PIC MCU. Do I need any more to do to receive the data to PIC MCU? Does anyone have the barcode scanner experience?

     
    I did not use such a scanner myself before.
    Sorry for the silly question, but you have to provide a bit more information.  Did you write any firmware for your PIC ? How does your test with the actual PIC look like? Are you sure that the scanner is a USB CDC device (so that you can simply use the converter) ? Are you sure your PIC PCB can "power" the scanner ?
    Notepad is not a terminal, so obviously the PC software for the scanner works a bit different (more complex).
    Did you try a real terminal application to see what happens ?
     
    [ edit: did you succesfully use the PIC UART for other devices before ? ]
    post edited by rodims - 2018/04/27 07:48:56
    #3
    softlab
    Super Member
    • Total Posts : 290
    • Reward points : 0
    • Joined: 2011/03/30 09:26:30
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 09:14:56 (permalink)
    0
    What is an "USB to TTL" converter?

    It is like USB to Serial Converter (Hardware).
    You do realise that USB is nothing like asynchrounous serial communication? For example, a USB host has to initiate a read from a device, data doesn't just arrive like on a serial port receiver.

    Yes. Be frankly saying, I don't have usart commands for that specific scanner. Instead, I send some invalid commands to the scanner to receive at least garbage/error data from the scanner for testing purpose. But nothing happened.
     
    Did you write any firmware for your PIC ?

    No.
     
    How does your test with the actual PIC look like?
    Are you sure that the scanner is a USB CDC device (so that you can simply use the converter) ?

    Not understood.
    Are you sure your PIC PCB can "power" the scanner ?

    Yes. It correctly reads the barcode and beep as the good read.
     
    Notepad is not a terminal, so obviously, the PC software for the scanner works a bit different (more complex).

    Yes. They may have written the driver for PC. It is automatically recognized by the Windows 7 OS when inserted.We only need to open a notepad and read the barcode. The decoded data has been displayed in Notepad.
     
    [ edit: did you succesfully use the PIC UART for other devices before ? ]

     
    Yes of course. I have done many usart aplications.
     
    any suggestions?
    pmk
    post edited by softlab - 2018/04/27 09:25:47
    #4
    KTrenholm
    Super Member
    • Total Posts : 555
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 09:27:17 (permalink)
    0
    Are you using a transceiver to bring the voltage from RS232 level to TTL level?  Your scanner is in all likelihood sending data at RS232 level, which is a swing of at least +6V to -6V (maximum +12 to -12), so you need to step it down to TTL level (0V to +5V or +3.3V depending on your PIC voltage) via a transceiver.
    post edited by KTrenholm - 2018/04/27 09:29:37
    #5
    Sobottech
    Super Member
    • Total Posts : 247
    • Reward points : 0
    • Joined: 2015/12/02 03:32:17
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 09:40:03 (permalink)
    0
    Well, why do you think it is RS232?
    Visiting http://www.postektronics.com it says Interface: RS232,PS2keyboard,USB,Spiral wire.
    But it is nothing about the communication protocol. RS232 is the old big Plug with normally 9 pins. PS2keyboard is the little nice round plug, after the big DIN plug vor Keyboard/mouse..., USB is USB ^^ and Spiral wire, well google should help.
    How did you set 9600 baud?
    Contact postelektronics and try to get information. commands....
     
    What if you are using a real terminal program? Can you select the Scanner? is there the barcode scanner COM device in windows?
    #6
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 09:49:16 (permalink)
    0
     

    Did you write any firmware for your PIC ?

    No.
     
    [ edit: did you succesfully use the PIC UART for other devices before ? ]

     
    Yes of course. I have done many usart aplications
     
    You do realise that USB is nothing like asynchrounous serial communication? For example, a USB host has to initiate a read from a device, data doesn't just arrive like on a serial port receiver.

    Yes. Be frankly saying, I don't have usart commands for that specific scanner. Instead, I send some invalid commands to the scanner to receive at least garbage/error data from the scanner for testing purpose. But nothing happened.
     
    How does your test with the actual PIC look like?
    Are you sure that the scanner is a USB CDC device (so that you can simply use the converter) ?

    Not understood.
     

     
    Well that still leaves too many questions. Also I cannot find any documentations PDF for that scanner. Only some specification (which says it both supports USB and RS232), but it does not answer my questions.
    So apparently you DID write firmware for your PIC to send commands to this scanner? Even if we should assume it does not contain bugs, then it's still a weird assumption that this would be a valid test scenario to send garbage and expect any answer. Until you know better from your documentation you should even assume that the scanner does not respond to anything, but only "outputs" when pressing the trigger.
     
    You need to know which type of USB device your scanner device is.  I think you only have a chance, if it provides USB CDC, otherwise you won't get happy with your USB TTL Serial converter.  USB CDC means, that it provides a serial COM port on the PC.  An indication is eg. (when attached to the PC) in the Windows Device Manager under Ports (COM & LPT). See whether detaching / attaching the cable will show some change there and add a COM Port.
    Of course it would be better if the documentation contains information about that.
     
    If you have some documentation, then provide a link.
     
    [edit: OP did not say that it is RS232, he most likely uses an USB connector/cable, and attaches the converter to get it to TTL level. He assumes the data is suitable for USART, but that's not sure for now]
    post edited by rodims - 2018/04/27 10:14:49
    #7
    Jim Nickerson
    User 452
    • Total Posts : 5553
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:11:40 (permalink)
    0
    What exactly is the end product you are making ?
    How did you come to choose this particular scanner ?
    #8
    jtemples
    Super Member
    • Total Posts : 11018
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:18:39 (permalink)
    0
    Scanners that I have used that claim to be "RS-232" are actually 5V TTL.  But I don't know anything about the OP's scanner.
    #9
    softlab
    Super Member
    • Total Posts : 290
    • Reward points : 0
    • Joined: 2011/03/30 09:26:30
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:24:29 (permalink)
    0
    You need to know which type of USB device your scanner device is.  I think you only have a chance, if it provides USB CDC, otherwise you won't get happy with your USB TTL Serial converter.  USB CDC means, that it provides a serial COM port on the PC.  An indication is eg. (when attached to the PC) in the Windows Device Manager under Ports (COM & LPT). See whether detaching / attaching the cable will show some change there and add a COM Port.

    Yes. I tried to open in Hyperterminal after connecting the scanner to usb, but could not able to establish the connection. So, it does not have USB CDC.
    [edit: OP did not say that it is RS232, he most likely uses an USB connector/cable, and attaches the converter to get it to TTL level. He assumes the data is suitable for USART, but that's not sure for now]

    Yes. you are correct.
    How did you set 9600 baud?

    They have given a barcode sheet for doing setting on barcode scanner for default factory setting, RS232, USB, beep sound on/off, etc. When we read the barcode, it automatically set the feature.
    Note: I have seen many videos on youtube but all are mostly with Arduino but not pic mcu.
     
    Scanners that I have used that claim to be "RS-232" are actually 5V TTL.

    May be, you are correct. Since I don't have the complete manual I am doing only on guessing. I have changed the setting as USB from RS232, but no result received yet.
     
    pmk
    post edited by softlab - 2018/04/27 10:29:09
    #10
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:27:35 (permalink)
    0
    Scanners that I have used that claim to be "RS-232" are actually 5V TTL.  But I don't know anything about the OP's scanner.

    The specifications say "5V".
     
    Yes. I tried to open in Hyperterminal after connecting the scanner to usb, but could not able to establish the connection. So, it does not have USB CDC.

     
    That's not a proof that it does not support USB CDC.  Please check as I suggested, or provide more information / a link to the documentation. Share your knowledge or we can't help.
     
    And possibly also answer Jims question.
    #11
    jack@kksound
    code tags!
    • Total Posts : 2892
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:28:23 (permalink)
    0
    Note: I have seen many videos on youtube but all are mostly with Arduino but not pic mcu.

    Nothing magic about the arduino, the arduino program should give you insight into how it was done although some of the "libraries" can be a bit difficult to navigate.
    #12
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 10:48:56 (permalink)
    0
    May be, you are correct. Since I don't have the complete manual I am doing only on guessing. I have changed the setting as USB from RS232, but no result received yet.

     
    I do not understand. What does that exactly mean ?
    a) why are you guessing /why don't you have a manual
    b) why are you using this scanner for your application
    c) what is "changed setting as USB from RS232"
    d) "no result received yet" -> you still have no valid test method.
    #13
    softlab
    Super Member
    • Total Posts : 290
    • Reward points : 0
    • Joined: 2011/03/30 09:26:30
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 11:06:01 (permalink)
    0
    a) why are you guessing /why don't you have a manual 

    I thought they would send the all necessary manual along with the product. But nothing sent except the barcode sheet for setting the barcode reader.
    why are you using this scanner for your application

    It is for my project. I preferred economy model.
    what is "changed setting as USB from RS232"

    As I said in above post and also mentioned in the above question, I have changed the mode of barcode reader from RS232 to USB using barcode sheet. If we read the barcode, the reader changed the settings automatically, for example, default settings, reset, USB, RS232, etc.
     
    pmk
    post edited by softlab - 2018/04/27 11:07:13
    #14
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 11:17:06 (permalink)
    0
    I guess "bar-code sheet" means "DIP switch settings" ? Or can you really scan this configurations from a sheet. If you are using the scanner with USB cable under Windows and receive the codes in e.g. Notepad, then we can assume the configuration for USB was successful.
    Still we don't know:
     
    You need to know which type of USB device your scanner device is.  I think you only have a chance, if it provides USB CDC, otherwise you won't get happy with your USB TTL Serial converter.  USB CDC means, that it provides a serial COM port on the PC.  An indication is eg. (when attached to the PC) in the Windows Device Manager under Ports (COM & LPT). See whether detaching / attaching the cable will show some change there and add a COM Port.

    How does the Arduino use the scanner ? Does it also use the USB cable ?
    If yes it is likely that they make use of USB CDC[ edit: likely is USB HID] but since you do not give us more information or links to your information it's just guessing, too.
    What is the VDD voltage of your PIC, I assume 5V ?
     
    post edited by rodims - 2018/04/27 12:19:52
    #15
    KTrenholm
    Super Member
    • Total Posts : 555
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 11:20:15 (permalink)
    +1 (1)
    Wonder if it's some crazy configuration like USB Mode gives you a USB HID Keyboard that just sends character keys and RS232 mode is USB CDC to give you a virtual COM port in windows?
    #16
    softlab
    Super Member
    • Total Posts : 290
    • Reward points : 0
    • Joined: 2011/03/30 09:26:30
    • Location: 0
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 11:35:15 (permalink)
    0
    If you are using the scanner with USB cable under Windows and receive the codes in e.g. Notepad, then we can assume the configuration for USB was successful.

    Yes. Exactly.
    You need to know which type of USB device your scanner device is.  I think you only have a chance, if it provides USB CDC, otherwise you won't get happy with your USB TTL Serial converter.  USB CDC means, that it provides a serial COM port on the PC.  An indication is eg. (when attached to the PC) in the Windows Device Manager under Ports (COM & LPT). See whether detaching / attaching the cable will show some change there and add a COM Port.

    For some reason, I could not able to access the MMMC (Device Manager only). I am trying to fix that. But, I have connected the USB to RS232 cable and able to see the COM port when opening the HyperTerminal. But, If I do so with the scanner, nothing happened.
    How does the Arduino use the scanner ? Does it also use the USB cable ? 

    Yes. USB cable connection only.
    What is the VDD voltage of your PIC, I assume 5V ?

    PIC16LF1847 - 3.6V VDD. I used USB to TTL converter between the Scanner and PIC MCU
     
    pmk
    #17
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 12:08:41 (permalink)
    0
    So these are my last guesses:
    I don't think 3.6 V is enough, it seems to work somehow as you said, but just as caveat.
    If I found the right video for Arduino they are using the USB Shield for arduino.
    And it implies that they use USB HID.  This would make sense, since you described that you can use  it on the PC with notepad, i.e. the scanner likely works as a HID Keyboard. 
    The video indirectly refers to here:
    https://www.circuitsathom...duino-usb-host-shield/
    Your USB Serial TTL  converter will not be of any use here.  Provide a link to your converter to be sure.
    I.e. you won't get it running.  You now might try to use the scanners RS232 port.
    -> see KTrenholms post #16
     
    But without any real documentation or proper links to your utilized information  I will stop guessing now ...
    post edited by rodims - 2018/04/27 12:21:44
    #18
    rodims
    Super Member
    • Total Posts : 1377
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 12:33:02 (permalink)
    0
    KTrenholm
    Wonder if it's some crazy configuration like USB Mode gives you a USB HID Keyboard that just sends character keys and RS232 mode is USB CDC to give you a virtual COM port in windows?

    +1
    So since your assumption with HID keyboard seems to be true, it would be great (for OP)  to know if your assumption with RS232 = USB CDC is also true.  But it's difficult to get the right answers ...
     
    [edit:  I think a was mistaken, USB CDC will also be of no use to OP.  I think your last hope would be a real RS232 (serial) mode, which in contrast to the name possibly only uses 5V for this device as jtemples said ( or likely no more than the VDD which you supply to the device) ]
    post edited by rodims - 2018/04/27 12:43:03
    #19
    jtemples
    Super Member
    • Total Posts : 11018
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: How to receive data from Barcode Scanner (Reader) ? 2018/04/27 12:34:35 (permalink)
    0
    Or can you really scan this configurations from a sheet.

     
    Yes, this is typical.  The manual has a series of bar codes that let you set the interface, data format, etc., without needing to communicate with the scanner.
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2018 APG vNext Commercial Version 4.5