PIC18xxx to USB device ?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2004
    Location
    Tallinn, Estonia
    Posts
    42

    Default PIC18xxx to USB device ?

    Hi, PIC gurus!

    I have to read a smart-card reader (Estonian ID-card, smth. like a passport). I did find out how to command the reader and how to make it send all unprotected data but...via com port. No i would like to move on to USB readers since comm-devices seem to getting obsolate. After some search i found Microchip's code examples but they all communicate to "the opposite direction" - PIC to PC. I would like to have a PIC talking to USB card-reader.
    Anybody working with similar project? Could there be any code examples available?

    Thnx!
    /Felch

    Some more reading and i found in the data comms forum that this kind of communication is considered impossible. May-be...but PIC has all needed hardware. So perhaps it's Basic that lacks USB routines? Or is it really impossible?

    Sorry for posting to wrong phorum, perhaps admins could move the thread.
    Last edited by Felch; - 19th August 2005 at 18:18.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Hi Felch,

    Not impossible. But as I'm sure you've already read, the PIC must act as a HOST to the USB bus. Not an easy thing to do.

    Check out this device from GHI. Crownhill is now the European distributor for it too.

    http://www.crownhill.co.uk/product.php?prod=1459

    It's still in beta right now, but GHI seems to be working hard on it. I just bought 1 myself (received it yesterday) so I'm not much help for sample code at the moment.

    Last edited by Darrel Taylor; - 20th August 2005 at 20:43.
    DT

  3. #3
    Join Date
    Sep 2004
    Location
    Tallinn, Estonia
    Posts
    42

    Default

    Thanks for advice! I understand that it might be difficult to programm PIC acting as an USB host. I am just wondering, could it be possible at all (does it have needed hardware ?). I know that an AVR processor has been put working with USB (Mycke Predko, the Girder device) but it did not need a host.
    Surely special chips would make life much easier. I will try this chip for sure.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Well, I've learned to "Never say Never", because some 15 year old genius will come along and figure a way to do it.

    However, everything I've found so far, says NO. There are 2 parts to the "Physical Layer" of USB.  Physical layer generaly means hardware, but since we work with PIC's, we know that many types of hardware can be simulated.  But, only 1 of those 2 components are present in any of the current PIC's.
    1. SIE - Serial Interface Engine. This is what is in a USB capable PIC chip. It's the same on both the Host and End device. So in effect, any 2 devices can communicate with each other without having a Host Controller, as long as it is NEVER actually connected to a REAL USB bus.  Being a Half-Duplex system, you are also limited to a Master/Slave arrangement.

    2. HC - Host Controller. This is the part that's lacking in PIC's. It's function goes something like this. "initiates transactions and controls access to the USB. It divides the time into “frames” and issues a start-of-frame (SOF) packet at each frame interval. In addition, it processes requests for data to and from the host and handles errors."
    That makes it sound like you should be able to simulate it in software, but I think that things just happen too fast to be able to do it all in real time. Throw on top of that the "Protocol Engine Layer" and the "Application Layer", and there's just not enough time to do it all.

    Now add the fact that the largest PIC with USB only has 16K words of program space, and you can see why I bought the USBwiz.

    Refs:
    USB Behind the Scenes: Understanding the Technology
    How USB Works


    DT

  5. #5
    Join Date
    Sep 2004
    Location
    Tallinn, Estonia
    Posts
    42

    Default

    Thanks for a very thorough answer. Exactly what I needed.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597

    Default

    Why not read the smart card directly? Don't use a reader at all?

    I've seen an example by Myke Predko (sorry on spelling if wrong), but he used his own BASIC language. He has one example using FAT16, and another just doing generic access.

    I'm still looking for an example using PIC Basic Pro though. I wanted to do this myself.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597

    Default

    Or, an acrobatic way around the PIC limitation of being only a slave:

    - connect PIC to PC as USB slave.
    - connect card reader to PC as USB slave.
    - have PIC tell PC to access card reader and send info back to PIC.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Sep 2004
    Location
    Tallinn, Estonia
    Posts
    42

    Default

    Can't read it directly because ia wanted to have an industrial reader (nice look etc, you know). One option is of course replacing industrial readers electronics with mine (i developed code that reads ID-card directly) but ... i was just wondering if there are easier ways.

Similar Threads

  1. USB Bootloader.
    By HenrikOlsson in forum USB
    Replies: 22
    Last Post: - 2nd May 2013, 02:46
  2. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  3. Replies: 0
    Last Post: - 6th March 2009, 07:52
  4. USB Device Not Recognized ???
    By keymuu in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th October 2008, 00:53
  5. usb - device not recognised
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th January 2007, 17:47

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