• AVR Freaks

PC as USB device emulator

Author
danp
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2009/03/03 19:58:34
  • Location: Massachusetts
  • Status: offline
2009/03/03 20:47:34 (permalink)
0

PC as USB device emulator



Sorry if my question doesn't make sense.  I'm just getting my feet wet with USB.

 

Would it be possible for a PC to emulate a USB device?  Specifically, I am interested in making a host _think_ that it is connected to a USB device; when it is actually connected to a PC emulating a USB device.
 
Any help is appreciated.
#1

12 Replies Related Threads

    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: PC as USB device emulator 2009/03/03 22:14:01 (permalink)
    0
    This is not possible for most of the commercial off the shelf PCs.They only have host ports and can only act as a host.

    Maybe some embedded PCs have some device port.

      USB_Links and libusb
    #2
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: PC as USB device emulator 2009/03/04 00:03:02 (permalink)
    0
    Agree with xiaofan,
    PC doesn't work as a hardware emulator of USB device.

    WDK has a device simulation tool (DSF), though I don't fully evaluate it yet.
    At a glance, the initial purpose of DSF is developing PC app with a virtual device. But, it can also emulate the device side on the same PC. It'll work for development of protocol handling and data process of the device side.

    DSF doesn't exactly provide the OP expected, but similar one.

    Device Simulation Framework
    http://www.microsoft.com/whdc/DevTools/DSF.mspx

    The Device Simulation Framework (DSF) enables you to create a high-fidelity simulation of hardware in software, which then appears like a real device to Windows.

    DSF Version 1.0 is planned for the WDK release expected in the first quarter of 2008.
    A preview of DSF is provided in the current Windows Driver Kit (WDK) with a USB simulation kit that includes a simulated USB 2.0 controller, a simulated external hub, and some working device simulation samples with complete source code. The source code for sample simulations is installed with the WDK samples under the \src\Test\DSF folder. You can build the samples with the WDK build environment.

    Because the simulation created with DSF does not require any special changes to Windows, the simulation can be used on all versions of Windows supported by DSF. This means that you can create hardware and driver simulations for x86 and x64 versions of Windows Vista, Windows XP Service Pack 2, and all future versions of Windows.


    Tsuneo
    post edited by chinzei - 2009/03/04 00:30:09
    #3
    danp
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2009/03/03 19:58:34
    • Location: Massachusetts
    • Status: offline
    RE: PC as USB device emulator 2009/03/04 07:35:51 (permalink)
    0
    Thanks.  I checked with DSF support and, as you suspect, it doesn't quite do what I would like.
     
    Any idea if this could be done via custom hardware?  Something like: PC1 <-> custom hardware <-> PC2.  In this scenario, PC1 and the custom hardware would emulate the USB device; PC2 would think it was connected to an actual USB device (as opposed to the custom hardware emulating the USB device).  When PC2 issues USB commands to the custom hardware, those commands would be forwarded to PC1 for processing.  Conversely, any responses would be sent from PC1 to the custom hardware which would then forward them to PC2.
     
    Thanks again.
    #4
    muhzd
    Super Member
    • Total Posts : 861
    • Reward points : 0
    • Joined: 2008/05/15 10:43:19
    • Location: Malaysia
    • Status: offline
    RE: PC as USB device emulator 2009/03/04 08:26:38 (permalink)
    0
    Have you looked at proteus?They kinda do that: emulate a usb device written by you that your pc detects(for code debugging purposes?). At least a little of what i understand reading here and there.
    #5
    trudnai
    Super Member
    • Total Posts : 335
    • Reward points : 0
    • Joined: 2006/08/04 05:19:24
    • Location: Reading, UK
    • Status: offline
    RE: PC as USB device emulator 2009/03/04 12:58:25 (permalink)
    0
    Yes, Proteus is good, bit pricey though. Also take a look at Wiz-C:

    Wiz-C USB Library & Simulation

    Regards,
    Tamas
    #6
    GlennB
    Senior Member
    • Total Posts : 158
    • Reward points : 0
    • Joined: 2008/10/31 22:18:52
    • Location: 0
    • Status: offline
    RE: PC as USB device emulator 2009/03/04 17:14:33 (permalink)
    0
    Building an (PCI type) interface board with a suitable USB interface IC will allow you to run LOW/FULL and HIGH speed device simulations.
    Connecting a PIC with a USB module to the PC parallel printer port will allow you to run LOW/FULL speed device simulations.
    Connecting a PIC with a USB module to the PC serial port will allow you to run LOW/FULL speed device simulations with speed limitations.
    Connecting the PC USB port <-> PIC1 USB port <-> PIC1 PMP port <-> PIC2 PMP port <-> PIC2 USB port <-> The USB host to be tested will allow you to run LOW/FULL speed device simulations with possible (minimal, while crossing the PC to PIC1 USB link) speed limitations.

    Glenn




    If it is worth writing it is worth writing in assembler.

    When you have calculated the worst case time needed for a project, triple the numerical value and raise to the next time unit.
    -I.E. a project estimated to 6 days will take 18 weeks.
    #7
    danp
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2009/03/03 19:58:34
    • Location: Massachusetts
    • Status: offline
    RE: PC as USB device emulator 2009/03/05 08:20:17 (permalink)
    0
    You guys are great.  Thanks for all the help.
     
    Any idea what Glenn's PIC1 <-> PIC2 (i.e. USB <-> USB) solution would cost to implement?  Ultimately, this would be part of an end-user product.  Unless the production costs are relatively low, I don't want to invest too much in research and development.
    #8
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: PC as USB device emulator 2009/03/05 09:29:57 (permalink)
    0
    Original: danp

    Would it be possible for a PC to emulate a USB device? Specifically, I am interested in making a host _think_ that it is connected to a USB device; when it is actually connected to a PC emulating a USB device.

    Isn't it better to elaborate on the purpose of emulation?
    For example,
    The idea of back-to-back USB PIC is good for a course material for USB education, but not good for a development tool which requires real time emulation.

    Which bus speed, Low-, Full-, Hi-, (or Super-), should the device emulator support?

    Tsuneo
    #9
    danp
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2009/03/03 19:58:34
    • Location: Massachusetts
    • Status: offline
    RE: PC as USB device emulator 2009/03/05 09:46:22 (permalink)
    0
    The general idea is to emulate USB HID devices.  Like using a laptop as a really expensive wink USB keyboard.
    #10
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: PC as USB device emulator 2009/03/06 00:46:48 (permalink)
    0
    OK, then it's a course material for USB education, with limited process speed.

    [ Hardware ]
    A USB PIC is used for the target USB engine of emulation.
    A second device provides connection between this USB PIC and the emulator PC.

    a) back-to-back USB PICs
    Another USB PIC provides the second device.
    The firmware of the second chip is based on CDC or HID example from Microchip

    b) USB PIC + USB-UART chip
    For this option, the second device is an existing USB-UART chip like FT232R
    http://www.ftdichip.com/Products/FT232R.htm

    c) Low Pin Count USB Development Kit w/ PICkit 2 - PICkit 2 Programmer UART Tool
    http://www.microchipdirect.com/productsearch.aspx?Keywords=DV164126

    "Low Pin Count USB Development Kit" is used for the target USB PIC.
    "PICkit 2 Programmer UART Tool" makes the PICkit 2 a USB-UART converter
    http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805

    I recommend you b) option for easiness of the development


    [ Firmware of USB PIC and Host application on the emulator PC ]
    Just for USB HID keyboard emulation, the keyboard example in Microchip USB framework, MCHPFSUSB v2.3.1, is available for the base code.

    http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537044
    USB Device - HID - Keyboard

    Modify this example, so that a input report sent by the emulator PC is put to the interrupt IN endpoint.

    When the PIC has a bootloader over serial, you can swap the emulated device on the PIC. As the Microchip USB framework has several examples, like CDC, HID keyboard and mouse, MSC and vendor specific, you can make up another emulated devices in this way. Then, you'll provide a couple of pairs of device firmware and PC emulator app.

    In this scheme, the enumeration is done by the USB PIC, without intervention of the emulator PC. The emulator PC supplies just the handling of bulk/interrupt endpoints. If you want to be more general, enumeration over the default endpoint is also brought to the PC side. And then, without firmware download, the PC can emulate most of USB class. But this second scheme means hard firmware development, not just brief modification of Microchip examples.

    Tsuneo
    post edited by chinzei - 2009/03/06 01:12:43
    #11
    danp
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2009/03/03 19:58:34
    • Location: Massachusetts
    • Status: offline
    RE: PC as USB device emulator 2009/03/06 15:17:06 (permalink)
    0
    Wow!  You guys are excellent.  I can't thank you enough.
    #12
    kenk
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2007/03/08 16:22:50
    • Location: 0
    • Status: offline
    RE: PC as USB device emulator 2009/03/06 15:57:41 (permalink)
    0
    Hello Danp,
    Would a design consisting of a 18F4550 that is SPI connected to a 24FJxxxGB110 provide you with the stimulation/sniffing and analysis you are looking for?  I am assuming that the 18F4550 is connected to the PC and the 24FJ can function as the host/device.  If so, contact me privately and I can provide you some help if you want to do some of the development.  I mentioned this on the forum some months back and got no response or interest.
    kenk
    #13
    Jump to:
    © 2020 APG vNext Commercial Version 4.5