USB to send ASCII characters to PC


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default USB to send ASCII characters to PC

    Regarding USB my level is at almost zero.

    I would like to make an RFiD reader and send the card serial number to a PC through USB port. Preferably not as RS232 too USB, so that the user on the PC side will not have to install anything.

    I have a barcode reader that is connected to a USB port. No drivers installed. When a barcode is read, if there is a program open (say word, excel, Notepad whatever) the code is displayed just as if one was hitting the keyboard.

    Very neat and simple. Can this be done with a PIC?

    Thanks,
    Ioannis

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516

    Default Re: USB to send ASCII characters to PC

    It can. What you're looking to do is basically implementing a USB keyboard using USB HID. When connected it will, to the PC, look like any old USB keyboard. I've managed to do it using examples on the forum, the tricky parts are to get the descriptor correct and the various scan codes. I can't get to the code right now but I can probably dig it out later - if you haven't already found examples to work from by then.

    /Henrik.

  3. #3

    Default Re: USB to send ASCII characters to PC

    Do a search for USB keyboard emulator, there are a couple of threads - here is one http://www.picbasic.co.uk/forum/showthread.php?t=8291, once you get the keyboard working you can the take the data from RFID and put it into a modified keyboard routine.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default Re: USB to send ASCII characters to PC

    Thank you both. Those info are enough to get me started.

    Ioannis

  5. #5

    Default Re: USB to send ASCII characters to PC

    Perhaps you could use one of the three 1 bit outputs NumLock, CapsLock and ScrollLock to implement flow control for your hardware.
    George

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default Re: USB to send ASCII characters to PC

    George,
    I do not understand where flow control is needed.

    Ioannis

  7. #7

    Default Re: USB to send ASCII characters to PC

    As you will be creating another keyboard, any output will be sent to what ever window has focus.
    George

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default Re: USB to send ASCII characters to PC

    Yes, the focus is a thing that bothers me and I wish I knew a way to deal with it.

    If for any reason (and windows has a lot, I am sure) the focus is lost, data entry is lost too...

  9. #9

    Default Re: USB to send ASCII characters to PC

    Are you writing a windows app? If so you can use those control lines to allow your hardware to tx. BTW hope I'm not teaching you to suck eggs but although you might assume that pressing CapsLock etc. turn on the LED on the keyboard, in fact all it does is set a modifier bit and the keyboard driver sends a signal to operate the LED.
    George

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default Re: USB to send ASCII characters to PC

    Unfortunately I am not qualified to write PC apps... Too pity that once I started to do things in C (command line environment) and a little Visual Basic 6 but did not evolve on that.

    Thanks anyway,
    Ioannis

  11. #11
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557

    Default Re: USB to send ASCII characters to PC

    I started working with PC apps about 5 years ago. I bought Visual Studio 2015 Professional and 5 books on the subject. Although VS 2019 is out, the books probably update with the versioning. One I recommend to get you functional (at a cheap price) is:

    Visual Basic in easy steps
    www.ineasysteps.com
    My 4th (2015) Edition has ISBN: 978-1-84078-701-6
    I bought it on Amazon. It's only 192 pages and covers only the essentials. It was the cheapest and thinest of the 5 books I bought, yet covers topics like data bases that the thicker more expensive books gloss over.

    As for connecting the PC to a PIC via USB, I have been using HIDmaker; although I have also been able to get Microchip's MLA (in C for MPLABX) templates to work as well.

  12. #12

    Default Re: USB to send ASCII characters to PC

    @Ioannis What would you want an app to do with the data? If some kind code elf were to create an app for you it would make more sense to us Vendor (otherwise known as Custom) which is a variation of HID but needs an app to talk to.
    George

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793

    Default Re: USB to send ASCII characters to PC

    Mike:
    Thanks for the interesting book. It made me look at VB again. The last app I did was in VB6 and liked that I was able to make an exe or an installer. When I check again in VB2015, the IDE was unbelievable huge and there seemed that the installer creator was not there anymore. There was something about manifests... I lost it.

    Towlerg:
    Thanks for the offer. I am collecting the requirements and after that I may need a PC app that would read data from a RFiD card and show on screen, copy to clipboard or enter it in a database, excel file or similar.

Similar Threads

  1. Replies: 4
    Last Post: - 1st December 2016, 13:32
  2. Search needs to allow fewer than 4 characters
    By J. Mark Wolf in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st March 2011, 02:33
  3. Send data to PC USB
    By konter in forum Off Topic
    Replies: 2
    Last Post: - 18th December 2009, 22:57
  4. Only the first 8 characters.
    By timseven in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd September 2009, 02:43
  5. ascii characters to hex
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2006, 05:06

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts