Shop OBEX P1 Docs P2 Docs Learn Events
Working full-speed (12 Mb/s) bit-banging USB Host controller - Page 4 — Parallax Forums

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

1246

Comments

  • Cluso99Cluso99 Posts: 18,066
    edited 2010-06-23 07:30
    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
  • william chanwilliam chan Posts: 1,326
    edited 2010-06-25 05:55
    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
  • ribbotsonribbotson Posts: 7
    edited 2010-06-25 13:47
    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
    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
    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
    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: 370
    edited 2010-07-19 15:54
    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
    @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
    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: 4,620
    edited 2010-07-26 05:33
    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
    @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
    Micah, Great video. I have to run out and get some dongles now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Cluso99Cluso99 Posts: 18,066
    edited 2010-07-26 12:28
    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
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-07-26 12:31
    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
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-07-26 15:02
    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.
  • ke4pjwke4pjw Posts: 1,065
    edited 2010-07-26 16:15
    Micah, that is awesome! Do you have a link to the exact Bluetooth dongle you used?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -- Terry
  • scanlimescanlime Posts: 106
    edited 2010-07-26 17:09
    @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: 8,129
    edited 2010-08-13 08:27
    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,230
    edited 2010-08-13 09:04
    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: 18,066
    edited 2010-08-13 10:50
    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
  • Cluso99Cluso99 Posts: 18,066
    edited 2010-08-25 21:49
    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.
  • TubularTubular Posts: 4,620
    edited 2010-08-26 17:26
    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
    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
  • HannoHanno Posts: 1,130
    edited 2010-09-02 00:22
    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
  • fbeekfbeek Posts: 14
    edited 2010-09-03 18:48
    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: 370
    edited 2010-09-07 09:30
    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,326
    edited 2010-09-19 04:36
    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?
  • william chanwilliam chan Posts: 1,326
    edited 2010-09-19 19:28
    I tried making the services discoverable by adding

    bt.AddService(bt#PSM_ServiceDiscovery)

    but it didn't work.
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-03 20:29
    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.
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-03 20:30
    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.
Sign In or Register to comment.