Working full-speed (12 Mb/s) bit-banging USB Host controller

1246

Comments

  • Cluso99Cluso99 Posts: 14,828
    edited 2010-06-23 - 07:30:41
    Micah: What is the hardware interface to the USB required? You mentioned 4 resistors earlier in the thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • william chanwilliam chan Posts: 1,315
    edited 2010-06-25 - 05:55:53
    Does the 2 data pins have to be adjacent prop pins?
    Do they need pull ups, or series resistors?

    The obex code doesn't mention this....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
    There is no such thing as bad news.
  • ribbotsonribbotson Posts: 7
    edited 2010-06-25 - 13:47:18
    The file usb-fs-host.spin gives the interface circuit and also describes the range of data pins that can be used.
  • scanlimescanlime Posts: 106
    edited 2010-07-19 - 05:53:30
    I had some more time to work on this code over the weekend. RFCOMM transmit/receive should be "feature complete", and it's working well with my Android phone.

    So, in short, all the code is in place for this to be a generic Serial Port Profile implementation using no hardware other than a cheap USB bluetooth dongle. But it still needs some more debugging- I've had this working with both Windows and Mac OS too, but right now both OSes are having trouble establishing RFCOMM connections.

    --Micah
  • heaterheater Posts: 3,370
    edited 2010-07-19 - 06:16:37
    Micah Dowty:

    Over here http://forums.parallax.com/showthread.php?p=923042 we started looking at all the possible ways of connecting a Prop to mobile phone, specifically an Android based phone.

    Well, wow, you've made the first such connection for us!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • heaterheater Posts: 3,370
    edited 2010-07-19 - 08:18:07
    I'm not sure I understand the repercussions of this.

    A typical Android phones USB port is set up as "device" only. There are methods to get "host" mode on some models with hacked cables and or custom made OS installations.

    It would be grate if the Propeller would be the USB host, as you have done, and the phone were the device and hence not need any complicated hacking or configuration.

    Now I'm totally new to Android so I'm wondering: Is possible to get the phone to be the device end of the USB/serial link with your USB host controller at the Prop end? That is make the serial link without the Bluetooth dongle in between? Just a USB cable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • FredBlaisFredBlais Posts: 367
    edited 2010-07-19 - 15:54:33
    I would like to get started using the bluetooth object, I could not find documentation or short tutorial for using it, where should I start? All I need is the bluetooth dongle (is there a wiring diagram)?

    So if I understand well, we can use this object to replace the serial port, and have a wireless one?

    Thanks!
    Fred
  • scanlimescanlime Posts: 106
    edited 2010-07-19 - 22:46:52
    @heater: The thing I was doing specifically was connecting to an app on my phone over a bluetooth RFCOMM connection. I have my Bluetooth stack implementing the Serial port profile (SPP). But if you don't want to use bluetooth, you can definitely use the USB host to talk to the phone's USB port directly. I tried this a while ago, and I think I still have an example for this in my svn repository.

    @Fred: Right now the code is really bleeding-edge, and it isn't really ready for casual users. If you're savvy with the guts of the Bluetooth protocol stack (or you want to learn), take a look at the test app and the object source code and have at it. But otherwise, it'd be best to wait until myself and/or others debug it a bit more and write some examples/tutorials. Once this code is "ready for prime-time", I'm sure it'll make its way to Obex [noparse]:)[/noparse]

    --Micah
  • scanlimescanlime Posts: 106
    edited 2010-07-26 - 04:38:29
    Whew! It took a bit longer than I thought (pesky Real Life getting in the way for the past few months...) but I have a fairly complete and easy-to-use Serial Port Profile object working.

    I made a quick bloggy-post with a demo video [noparse]:)[/noparse]
    micah.navi.cx/2010/07/propeller-bluetooth-stack-demo/

    The source code to the sample that I'm showing in the video is at:
    svn.navi.cx/misc/trunk/propeller/usb-host/serial-demo.spin

    That "bluetooth-serial" object is really just a convenience wrapper around some lower-level objects that let you create services, sockets, etc. Right now only RFCOMM sockets are implemented formally, but there's some infrastructure in place for raw L2CAP sockets (which you'd need for protocols like HID). So right now it's still a bit rough, but the basic SPP server functionality should be feature complete at least, and it seems mostly stable so far in my testing. I've successfully connected to it from Mac OS, Windows 7, Linux, and Android.

    For those of you who bought the cheap Bluetooth dongles, give it a try and let me know how it goes!

    --Micah
  • TubularTubular Posts: 3,514
    edited 2010-07-26 - 05:33:25
    All I can say is wow! So simple yet powerful. Many thanks for the video too

    I've been collecting $1~2 bluetooth modules off ebay and can't wait to give this a go. Just gotta not mix them up, they all look kind of similar.

    Micah how difficult would it be to move the pins from P0-1 to P24-P25 or 26-27? I only ask because sometimes P0-7 are used for speed, not sure if it applies here or not. I'm designing some boards to use "PS2 over USB-A connection", but being able to "spend 4 cogs" to get USB host on the same pins would be truly excellent

    very well done
    tubular
  • scanlimescanlime Posts: 106
    edited 2010-07-26 - 05:48:06
    @Tubular: Thanks!

    About the pins: It should be easy-ish to move the USB host to anything from P0 through P8. There are some masks that it assumes will fit in a literal at the moment. It also uses the video generator, so you'd need to change some other bits (vcfg, palette). Right now it would involve some extra work to make it configurable at runtime, but you could probably do it without sacrificing anything other than some RAM.

    --Micah
  • heaterheater Posts: 3,370
    edited 2010-07-26 - 08:31:55
    Micah, Great video. I have to run out and get some dongles now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Cluso99Cluso99 Posts: 14,828
    edited 2010-07-26 - 12:28:24
    Excellent video Micah.
    Next headline... "Bluetooth dongle demand goes up fuelled by propeller users" LOL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-07-26 - 12:31:09
    Great work!

    Note to self... buy some bluetooth dongles...
    Micah Dowty said...
    Whew! It took a bit longer than I thought (pesky Real Life getting in the way for the past few months...) but I have a fairly complete and easy-to-use Serial Port Profile object working.

    I made a quick bloggy-post with a demo video [noparse]:)[/noparse]
    micah.navi.cx/2010/07/propeller-bluetooth-stack-demo/

    The source code to the sample that I'm showing in the video is at:
    svn.navi.cx/misc/trunk/propeller/usb-host/serial-demo.spin

    That "bluetooth-serial" object is really just a convenience wrapper around some lower-level objects that let you create services, sockets, etc. Right now only RFCOMM sockets are implemented formally, but there's some infrastructure in place for raw L2CAP sockets (which you'd need for protocols like HID). So right now it's still a bit rough, but the basic SPP server functionality should be feature complete at least, and it seems mostly stable so far in my testing. I've successfully connected to it from Mac OS, Windows 7, Linux, and Android.

    For those of you who bought the cheap Bluetooth dongles, give it a try and let me know how it goes!

    --Micah
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
    www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / @Mikronauts on Twitter
    RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,089
    edited 2010-07-26 - 15:02:42
    Question: (I haven't used bluetooth yet, I'm still stuck in the serial days)

    I just got my adapters..

    Your video shows you connecting the Propeller as a "computer" -- How much more would be required
    to make the Propeller the host device for things like a bluetooth keyboard? (Don't buy this one! The shipping is nuts!)

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Feature Projects: PropellerPowered.com
    Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
    <br>
  • ke4pjwke4pjw Posts: 358
    edited 2010-07-26 - 16:15:38
    Micah, that is awesome! Do you have a link to the exact Bluetooth dongle you used?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -- Terry
    Terry's Workbench

    Feel the need for speed between your PC's com port and Prop?
    Try the FTDI 245 and the FullDuplexParallel Object.

    Check out my spin driver for the Parallax "96 x 64 Color OLED Display Module" Product ID: 28087
  • scanlimescanlime Posts: 106
    edited 2010-07-26 - 17:09:58
    @Oldbitcollector: The "computer" thing is just the device class, it doesn't have much meaning other than what icon you'll see when you discover it from other devices. There are specific class codes for things like laptop computers, desktop computers, phones, generic peripherals. You can set this yourself if you're using the lower-level bluetooth-host.spin object directly.

    As for hosting input devices, that's certainly possible! Ribbotson already used a modified version of this code to talk to a Wiimote, which is very similar to communicating with a keyboard or mouse. To do this cleanly, we'd need support for L2CAP sockets and for creating outgoing connections, but if you don't mind a little hacking you can already coerce the lower-level code in bluetooth-host to do this kind of thing.

    @ke4pjw: The dongles I have are http://www.dealextreme.com/details.dx/sku.11866

    I also tried a few others, they all seem to work okay. If you get a bunch of these $2 dongles, though, beware that they all use the same Bluetooth address. You won't be able to use more than one of them simultaneously in the same area.
  • BeanBean Posts: 7,969
    edited 2010-08-13 - 08:27:11
    scanlime,

    I'm working on a project that needs to communcate with a PC but I cannot afford to put a FTDI chip on it.

    Can this be used in place of an FTDI chip on a propeller board ?

    I realize you wouldn't be able to program the propeller, but could you communicate with the PC as a serial port.

    Would windows automatically see it or would you have to manually load a driver on the PC ?

    Bean
  • Heater.Heater. Posts: 21,213
    edited 2010-08-13 - 09:04:38
    Bean,

    If all you want to do is communicate with a PC as if from a USB/serial adapter I think all you need is BradC's USB toys. That makes the Prop into a USB "device" rather than a "host".

    See here: http://forums.parallax.com/showthread.php?t=97328&highlight=USB*+toys

    Another possibility for slow speed USB serial is to us an AVR chip as the USB device. Not sure if it's any cheaper but a few years back I built stuff based on the AVR USB software stack from here http://www.obdev.at/products/vusb/index.html Check out the projects derived from that software. Worked quite well.
  • Cluso99Cluso99 Posts: 14,828
    edited 2010-08-13 - 10:50:46
    Bean, like heater said, certainly possible. Not sure how many cogs it uses though.

    I have been thinking a little further... I'd like to add some mechanism that would allow special downloading. Maybe by changing the baudrate on the pc or some break mechanism. That way, we only have to get boot code into the eeprom once.

    The other thing I am looking to see is if mini-USB(A or B) to USB female cables (i.e. like on a PC) are readily available and reasonably priced. That way we could connect to a PC with the usual phone/camera cable or using this cable connect a USB device such as Bluetooth, Keyboard, mouse, etc
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Cluso99Cluso99 Posts: 14,828
    edited 2010-08-25 - 21:49:17
    Time to bump this thread to see where it is up to...

    Can the USB Bluetooth dongle support more than one connection simultaneously? I am thinking about a keyboard and mouse initially.

    Can two USB Bluetooth dongles connect to each other? I am thinking about the prop and the pc both having a dongle and doing comms between the prop and pc.

    As you can see, I currently know nothing about Bluetooth.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • TubularTubular Posts: 3,514
    edited 2010-08-26 - 17:26:57
    It works!! Finally had a chance to get this running with some $1.09 dongles, and that included shipping

    I'm very impressed
  • KaosKiddKaosKidd Posts: 296
    edited 2010-08-31 - 11:53:56
    scanlime wrote: »
    This is something I've been wanting to try for a while, but I finally had an excuse...

    I've been wanting to build more devices that can communicate wirelessly. Sensors, ambient information displays, that sort of thing. To reduce the infrastructure needs, I'd like to use Bluetooth, or preferably Wifi. Problem is: I want these things to be cheap, and it's still fairly expensive to buy a Bluetooth or Wifi adapter that's microcontroller-friendly. I'd much rather stick a $5 USB bluetooth dongle on my Propeller and have a solution with simple/cheap hardware and software which is merely not impossible to write :)

    Wow. This is real nice. I was looking at using your USB driver to drive one of the Parallax inc USB robotic boards. Not sure if it's feasible or not, but the idea being to use a simple un-powered hub to add as many as needed and write a little routine for it. I only just started looking at how it's controlled, but I'm sure it would make a "quick and clean" connection between any propeller controller and any number (within reason) of robotics controllers. What do you guys (and gals?) think?

    KK AKA Fred
    Hope this helps. I can tell what time it is, but don't always know how to make a watch.
    KB3VYZ
  • HannoHanno Posts: 1,130
    edited 2010-09-02 - 00:22:48
    Good work Micah- and excellent video demo. Looks like you're up to 9600 full duplex. Does it go any faster? 115kbps would be nice!
    Hanno
    Professional IDE to edit, debug, and run SPIN, PropBasic and C: ViewPort
    Visual programming language: 12Blocks
    Multi-function Oscilloscope/LSA/Function Generator: PropScope
    500 page book of Propeller Projects:Programming and Customizing the Multicore Propeller
    Blog:http://onerobot.org/blog
  • fbeekfbeek Posts: 14
    edited 2010-09-03 - 18:48:37
    Hello,

    i have a problem with the USB HOST STACK.

    I connect a USB port to my Propeller as described in the source code.
    The Propeller is working at 96MHz.

    I tried several USB Bluetooth dongles an USB flash sticks but i get every time i try to enumerate the Device the error code 151.

    Can someone help me please?

    Florian
  • FredBlaisFredBlais Posts: 367
    edited 2010-09-07 - 09:30:43
    Hi Micah,

    I was wondering if a device like the one you bought on deal extreme, that boast class 1 (100m, 100mw) really is this class... did you tried your setup at a good distance?
    I want to try to pair a dongle with your stack with a WT device from Blugiga, is there any chance you know if it's easy or not?

    That way, I would be able to replace the PIC (with software to interface to a bluetooth module) in my project by a propeller.

    Thanks,
    Fred
  • william chanwilliam chan Posts: 1,315
    edited 2010-09-19 - 04:36:42
    Hi all,

    I use Micah's latest "bluetooth-serial.spin" object.
    I managed to get the Propeller discoverable and I can pair with it using pin 0000 from my Windows PC.
    I can also view the bluetooth adapter address correctly.

    Here are the return values i got.
    bt.Start => returns 0
    bt.SetName(string("Propeller")) => returns 0
    bt.SetClass(bt#COD_Computer) => returns 0
    bt.SetDiscoverable => returns 0
    bt.SetFixedPIN(string("0000")) => returns 0
    bt.AddService(@serialService) => returns 0
    bt.ListenRFCOMM(RFCOMM_CHANNEL, rxr.Ring, txr.Ring) => returns a pointer

    Everything seems to be ok except my PC cannot discover the Virtual Serial Port service on the Propeller.
    I use BlueSoleil windows software to scan the services available.
    So I am unable to connect to it using the Virtual Serial Port.

    1. How to make the serial port service discoverable/browesable?
    2. Is there a way to connect to it without first discovering the serial service is available?
    3. Is there something i missed out?
    There is no such thing as bad news.
  • william chanwilliam chan Posts: 1,315
    edited 2010-09-19 - 19:28:58
    I tried making the services discoverable by adding

    bt.AddService(bt#PSM_ServiceDiscovery)

    but it didn't work.
    There is no such thing as bad news.
  • william chanwilliam chan Posts: 1,315
    edited 2010-10-03 - 20:29:00
    I finally found that by changing the start up sequence,
    i am now able to detect the Serial Port Service when using Windows XP's Bluetooth stack.

    bt.start
    bt.AddService(@serialService)
    bt.ListenRFCOMM(RFCOMM_CHANNEL, rxr.Ring, txr.Ring)

    bt.SetName(@strDeviceName)
    bt.SetClass(bt#COD_Computer)
    bt.SetDiscoverable
    bt.SetFixedPIN(string("2382"))

    but still unable to detect the service when using IVT BlueSoleil stack or if I try to detect the services using my Sony Ericsson K770i phone.
    There is no such thing as bad news.
  • william chanwilliam chan Posts: 1,315
    edited 2010-10-03 - 20:30:52
    Micah,

    What is the easiest way to change pin P0 and P1 to P4 and P5 besides changing the pin constant definitions?
    Where are the masks located?

    Thanks.
    There is no such thing as bad news.
Sign In or Register to comment.