Shop OBEX P1 Docs P2 Docs Learn Events
USB emulation with the Propeller — Parallax Forums

USB emulation with the Propeller

Cluso99Cluso99 Posts: 18,069
edited 2011-11-09 07:37 in Propeller 1
I now have the USB device software written by BradC partially working with Windoze XP SP2. It is recognised as a communications device.

However, communications is not really working properly. Sometimes I manage to get a few characters echoed.

For anyone wishing to try it, I have attached the code and the avrcdc.inf file (as used with the avr usb emulation). The circuit is described in the source files (2 series resistors 68R-100R and 1 series resistor 1K5).

I am still learning USB so at the moment I am at a loss as to what to try next to get this working better. Any ideas anyone???

Windoze install: When the prop is connected to the USB port Windows will request an installation file. Point it to the avrcdc.inf file. You will then be able to see a new com port on PST (or other comms program).

BradC's thread and code (usb device) is here http://forums.parallax.com/showthread.php?97328-USB-toys-to-play-with
Micah's thread and code (usb host) is here http://forums.parallax.com/showthread.php?97328-USB-toys-to-play-with
I designed a small pcb for the purpose http://forums.parallax.com/showthread.php?135296-Modular-board-for-USB-host-and-device-testing-with-P8X32A-Propeller-microcontroller

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-07 02:37
    just raising this again...
    Any interest?
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-07 02:55
    Yes I am interested!

    If the prop can emulate a USB device you could use this for rapid downloading of big programs (eg C programs).

    Say you were running Catalyst or Kyedos, your PC program 'runs' the program to enable a USB link (a precompiled program which is on an sd card) and that program takes the download and puts it onto the sd card.

    Then you can run the downloaded program.

    But if you can't get it working...
  • BeanBean Posts: 8,129
    edited 2011-11-07 04:56
    Cluso99 wrote: »
    just raising this again...
    Any interest?

    I need someone to write a slow-speed HID driver for the Propeller (to allow the propeller to use a USB keyboard, when the USB keyboard does NOT do PS/2 emulation).
    From what I have read there is a special simple protocol that the computer BIOS uses to talk to USB keyboards, but I haven't the time or knowledge of USB to write it.

    I have about a hundred miniature USB keyboards that I would like to sell to for Propeller use, but they are USB only (no PS/2 emulation).

    I would gladly send you a couple keyboards for you to play around with if you want to try it. It would have to work on a standard Propeller setup (80MHz clock).

    Send me a PM if you are interested.

    Bean
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-07 16:38
    As soon as I get the USB slave (prefer CDC? = comms mode like the FT232 but only low speed to start with) I can get on with trying to get FS working.

    I have a specific purpose in getting this running... I will be using it to replace the FT232RL chips in some of my future products (sssh!)

    Bean: Micah has done master mode that works with a number of slaves including Bluetooth and HID. I would expect that there would be some shortcuts that could be done with the USB keyboard but the big problem with USB is that it requires multiple cogs. Even if we could get away with 2 cogs (Micahs code currently uses 4) I would not see that as being a nice solution. Have you looked inside the keyboard? Perhaps you could post a pic of the pcb.
  • TubularTubular Posts: 4,712
    edited 2011-11-07 16:49
    Cluso

    It might pay to get in contact with BradC about what's possible.

    I seem to remember the HID, while it did work, was relatively slow (an order of magnitude slower?) than ftdi.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-07 18:46
    I have not spent a great deal of time on actually getting it running, but it does seem to have some problems with sneding/receiving characters. I have looked at lots of other implementations too. I am sure I can get the LS version running and 1.5Mbps is not that bad really. It would be nice to get FS working too, but the objective is to get LS running and working with PST and other terminal programs. The ultimately, I hope to get downloading working, but not in the way you might expect.
  • AribaAriba Posts: 2,690
    edited 2011-11-08 08:15
    Cluso99 wrote: »
    As soon as I get the USB slave (prefer CDC? = comms mode like the FT232 but only low speed to start with) I can get on with trying to get FS working.

    I have a specific purpose in getting this running... I will be using it to replace the FT232RL chips in some of my future products (sssh!)

    CDC needs a fullspeed device. Yes it works on Windows with lowspeed by accident, but for example not on newer Linux kernels. And I don't know if it also works on Win7. So I would not rely on a lowspeed CDC implementation.
    And fullspeed in software need a lot of cogs and a 6MHz crystal.

    Years ago I had the same idea to replace the FT232 first with an AVR and later with a Propeller software slave, but with the help of libusb on the PC side (exists for windows and linux). The problem is that the PropellerTool supports no external Downloader, and that you need the USB slave driver in the EEPROM of the Propeller. If you overwrite the EEPROM there is no way to connect to a PC and reprogram it.
    Bean: Micah has done master mode that works with a number of slaves including Bluetooth and HID. I would expect that there would be some shortcuts that could be done with the USB keyboard but the big problem with USB is that it requires multiple cogs. Even if we could get away with 2 cogs (Micahs code currently uses 4) I would not see that as being a nice solution. Have you looked inside the keyboard? Perhaps you could post a pic of the pcb.

    A Keyboard needs a lowspeed Host, but Micah's software only supports fullspeed. I'm pretty sure it is possible to make a lowspeed host with one cog, but it needs the detailed knowledge about USB, that Micah has, but not me .

    Andy
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-08 14:38
    I know very little about USB but I think Cluso is onto something very interesting here. Re Ariba
    Years ago I had the same idea to replace the FT232 first with an AVR and later with a Propeller software slave, but with the help of libusb on the PC side (exists for windows and linux). The problem is that the PropellerTool supports no external Downloader, and that you need the USB slave driver in the EEPROM of the Propeller. If you overwrite the EEPROM there is no way to connect to a PC and reprogram it.

    That is a good idea.
    1) I wonder if you could leave the ft232 in place, and have a couple of jumpers that switch between "direct USB" and "USB via ft232". Then if you did accidentally wipe the eeprom you just change the jumpers over.
    2) The propeller tool may not support an external downloader, but if one existed as a command line program, BST etc could be easily modified to shell out to that command line program.
    3) A USB slave driver could exist in eeprom, but generally I would suspect the main use for USB downloads is for big programs, and big programs imply a SD card and if you have an SD card then any USB driver program could be stored on an SD card and run as needed.
    4) Re multiple cogs, if the sole purpose of a download program was to take data from USB and store it on an SD card, then that program could use all 8 cogs and it would not matter. Once it has run, it then goes back to an operating system (catalyst/kyedos etc) and/or runs the program that has just been downloaded.

    I don't know about the 6Mhz xtal. Is there code that runs for us slow 5Mhz xtal people?

    Thinking in general terms, if you plugged this into a PC, what does a PC think has just been plugged in? A USB to serial device? A USB memory stick? Something else?

    I'm thinking that if the PC thought it was a memory stick, that is the one device that is likely to cause the least compatability problems as every PC would have a memory stick driver in the OS. Would it be possible for the propeller to interpret the command set that go to a USB memory stick ("directory listing, send a file, receive a file, change directory") and translate those to the SD command set that Kye wrote in Spin? Then the SD card on the propeller would appear to the PC as if it was talking directly to an SD card. That would make 'downloading' simpler too, as that is just a simple DOS (or whatever) 'copy' command in a batch file or any language you like.

    So some problems here are solvable. None of this helps though with Cluso's missing characters. Sorry.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-08 19:42
    I have all the problems discussed covered (in my mind at least) except for the actual USB implementation ;)

    I am not concerned about downloading to eeprom, nor the downloader code - they are all doable. I will be using a 6MHz xtal (96MHz) minimum.

    BradC's code does run at 5MHz. It is just eluding me to get the basics working properly. I cannot just reliably send or receive characters. I currently have 2 USB ports connected - the FT232 on P30/31 and my direct USB on P0/1/2/3 where P2 & 3 set the LS or FS 1K5 pullup.

    I do have a pretty good set of USB writeups but it is finding the time to fully examine the protocol. I was trying to jump start my code.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-11-08 21:23
    Hopefully someone who has done this will chime in soon.

    I found this http://www.ftdichip.com/Support/Documents/AppNotes/AN232B-05_BaudRates.pdf - it doesn't solve your problem but it seems the ft232 can go a lot faster than 115k, and maybe almost up to USB speeds?
  • SapiehaSapieha Posts: 2,964
    edited 2011-11-09 01:16
    Hi Dr_Acula.

    I have one PDF that claims that on FT232 speeds up to 3Mbits can be achieved.
    Will find and post it
    Dr_Acula wrote: »
    Hopefully someone who has done this will chime in soon.

    I found this http://www.ftdichip.com/Support/Documents/AppNotes/AN232B-05_BaudRates.pdf - it doesn't solve your problem but it seems the ft232 can go a lot faster than 115k, and maybe almost up to USB speeds?
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-11-09 01:43
    I know that, on AVRs, the multiples of 6MHz (usually 12MHz) is so that for the 1.5Mbs it is an easier/given starting point.

    The COGs would be going at 20MHz for a 5MHz rock but a magical 24MHz with a 6MHz one (assuming PLL * 16 and 4 cycles per instruction).
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-11-09 07:37
    Dr_Acula wrote: »
    Hopefully someone who has done this will chime in soon.

    I found this http://www.ftdichip.com/Support/Documents/AppNotes/AN232B-05_BaudRates.pdf - it doesn't solve your problem but it seems the ft232 can go a lot faster than 115k, and maybe almost up to USB speeds?


    I've tried up to 2Mbit using code from this thread on propeller side:
    http://forums.parallax.com/showthread.php?102696-HighSpeed-Serial-Tx-(3Mbps)-Rx-(2Mbps)-autobaud-for-FT232R-Prop-GPL&highlight=propcan

    on Windows it required "aliasing" of baud rates, as described on FTDI application notes.
    I replaced 600bps and 2400bps speeds for 1Mbps and 2Mbps, saving the other speeds that might even remotely be needed (including an improbable serial mouse at 1200, GPS at 4800, etc.).

    For lower speed the driver will do "fractional" rates (i.e. I used 92100bps) on the fly, asuming the application allows to specify it (TeraTerm does).

    Also tried on Linux, and the driver seems to manage anything you throw at it, including 2Mbits.

    I didn't try 3Mbits as I seem to recall that Hanno had problems trying to get it to work.
Sign In or Register to comment.