Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:47 05 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : USBID / USB Hosting

Author Message
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 12:36am 09 Jan 2017
Copy link to clipboard 
Print this post

Can I shoot some ideas in the breeze and check I have it right ..

A device (eg PC) can run USB hosting. A usb-client device can then connect,
it will enumerate on the USB host system which then sets it up for data flow.
EG a Windows PC runs as a USB host, a client device like mcp2221a or similar pic1455 connects, and the host then also runs Teraterm etc to display the data.

The Microchip USB stack can be set up as a client. A full MCU like an MZ can also be used to run the stack as a USB host, in fact there is "USB-to-go" which can switch between modes as required. So, to enable the MCU to determine whether host or client mode is necessary, there is a USBID line in the USB wiring and the connectors switch it to ground as required.

It follows that any MCU and board that has the USBID line in place should be able to run as a USB host instead of as a client (apart from several thousand other factors ).

I have put the USBID line in place on the sn-7x pcb so you see I have high
hopes for it .






 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 01:28am 09 Jan 2017
Copy link to clipboard 
Print this post

AFAIK you are correct.

The issue is if you want a device to be able to switch between being a host and a client. This is easy enough in the software (sort-of) but it seems all designs that do this use a USB transceiver between the processor and the physical USB connection. Nothing too bad about that but I have yet to find one that isn't in a tiny QFN package so not possible to hand solder.

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3663
Posted: 02:19am 09 Jan 2017
Copy link to clipboard 
Print this post

Being a host means supplying USB power as I recall.

OTG means doing that only when host, I think.

The good news is the USB specs seem freely available. The bad is they are not very readable and are also rather large.

(They may be even worse if trying to write software to work on crude hardware.)

Various things that seem reasonable are in fact banned, too...

John
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 03:04am 10 Jan 2017
Copy link to clipboard 
Print this post

Hmmm. That is quite a catch-22...a device in usb-client mode must not supply power
back to the usb host - but if it instead runs as a host it must be able
to supply power to client devices and that must be incorporated.
I think there is a base spec of supplying 200 mA as a default.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 04:15am 10 Jan 2017
Copy link to clipboard 
Print this post

This document has a good explanation of all this
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3663
Posted: 06:33am 10 Jan 2017
Copy link to clipboard 
Print this post

Might find LM3526 or SY6280 useful.

John
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 11:29am 10 Jan 2017
Copy link to clipboard 
Print this post

Thanks - much appreciated
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2290
Posted: 07:18pm 10 Jan 2017
Copy link to clipboard 
Print this post

for simplicity, one could just use a jumper to select between USB host and device modes:

1 (left) pin connected to a nominated mode pin on the PIC32 that has a 10k resistor to ground.
2 (centre) pin connected to board's 5v rail
3 (right) pin connected to USB connector's 5v pin

- when 1-2 is jumpered, the 'mode' pin will be pulled high and the PIC32 knows that it should be in device mode.
- when 2-3 is jumpered, the mode pin will be pulled low (via the 10k resistor to ground) and the PIC32 knows that it should be in host mode. at the same time, the board's 5v line is fed directly to any attached usb device.
- when no jumper is fitted, we are in host mode but without power supplied to any attached USB device (that could be useful in some applications).

there should also be a schottky diode fitted between the USB connector's 5v pin and the board's 5v rail, such that whenever 5v is fed into the USB connector it will power the board.

a second (optional) schottky diode in series with any 'external 5v power' connectors on the board with protect against backfeeding 5v from the USB connector into an attached external 5v power supply.


cheers,
rob :-)
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 10:56am 12 Jan 2017
Copy link to clipboard 
Print this post

I am thinking, those connections could be in a powered cable.
(edit - I was thinking of using icsp pins for power somehow but that is not a good idea.)
The mode signal could be set with a pic port resistor. That might also be generically usable by other boards too.
Still cogitating...

Edited by chronic 2017-01-14
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 01:20am 22 Jun 2017
Copy link to clipboard 
Print this post

I have a MMX144pin board with a USB connector (not the console, "USBMZ") what does it actually do? I have searched the MMX documentation but only find a reference to it in the pin descriptions.

Would it not be possible to have this as a USB Host (it is a female connector). This guy seems to have working HOST code for PIC32. This would then solve the problem of connecting HIDs (keyboards etc) it would be REALLY good it it handled hubs - so multiple HIDs.

I am currently playing with a mini usb host shield for arduino and I'm close to having a working USB to serial - remember this is the opposite way to USB-serial using ch340/pic/ftdi solutions because shield acts as a host (like your pc does) but i would like to plug USB devices in directly without this bit of hardware and then using a serial port to get the data (this makes it *very* easy but not like using INKEY$). Went this way because the arduino already has libraries for processing the MAX3421E and I didn't want to do all that mucking about in MMBasic.

Any ideas anyone?
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 03:54pm 23 Jun 2017
Copy link to clipboard 
Print this post

After looking at USB for some time, I think it is resource/maintenance hungry so probably not worth the hassle building it into code unless it is going to be used a lot.
The separate (ed - arduino) USB host chip/board works ok at least for serial but hits the uno resource limit and takes the spi pins, the serial can apparently be reused as another spi port but I haven't tried that yet. I have been using one as a black box for a while, it seems to be working ok..it is good to compartmentalize the usb away from the main processing, arduino has its own benefits and annoyances of course. Edited by chronic 2017-06-25
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024