Pages: [1]   Go Down
Author Topic: Microcontroller as USB host and device  (Read 3268 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have read plenty of articles on using ATTiny and similar micro controllers as a USB device (many phantom CapsLockers, etc). I want to make one that can read keyboard input and then pass on keyboard input (some changed and some unchanged) to the computer. Do you have any recommendations for microcontrollers that can do this (hardware or with firmware) easily? I'd prefer something: cheap, small, and preferably Atmega or similarly popular in the open source hardware community.
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Connect a USB host chip and a USnooBie http://frank.circleofcurrent.com/usnoobie/ , which is actually just the ATmega328P that you are used to, and using mostly the same code as the ATtiny projects you've already seen.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 133
Posts: 6752
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know of any cheap, popular, easy-to-use USB host solutions.  The closest I think I've seen is the FTDI vinculum2, which is cheap (one out of three?)  It's also pretty weird.

For your particular application, you might be able to get away with talking PS/2 protocols to the keyboard, and USB device to the PC.  Many USB keyboards are still capable of working on a PS/2 plug as well (with only some wire re-routing), and a microcontroller can pretty easily implement the host side of PS/2...
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this looks like it'll do the job

http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini/

Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

West palm beach, FL
Offline Offline
Sr. Member
****
Karma: 1
Posts: 325
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The fez Domino has usb host and device capabilities and plenty of example code to set you on track
http://www.ghielectronics.com/catalog/product/133 @60 dollars its not too bad ,

or if your able to, you can just get their Nxp chip pre loaded with .netmf and build your own board for a lot less.
http://www.ghielectronics.com/catalog/product/116

oh thank heaven for open source
Logged

I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The fez Domino has usb host and device capabilities and plenty of example code to set you on track
http://www.ghielectronics.com/catalog/product/133 @60 dollars its not too bad ,

or if your able to, you can just get their Nxp chip pre loaded with .netmf and build your own board for a lot less.
http://www.ghielectronics.com/catalog/product/116

oh thank heaven for open source

Watch out, I think that chip, LPC2388, only has one USB OTG, I don't think you can handle both host and device at the same time. It is capable of both but only one at a time.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Sweet!  Thanks - now I have a cool new shield / microchip to buy and a cool site to read!  This definitely looks like it will do it.  I had actually planned on doing this project with USnooBie before you posted here, but may drop this on my Arduino mini to prototype and then convert over to a dedicated board to combine both things.  We'll see what shakes out.  I'm still definitely getting a USnooBie at some point very soon.

The fez Domino has usb host and device capabilities and plenty of example code to set you on track
http://www.ghielectronics.com/catalog/product/133 @60 dollars its not too bad ,

$60 - too high

or if your able to, you can just get their Nxp chip pre loaded with .netmf and build your own board for a lot less.
http://www.ghielectronics.com/catalog/product/116

Thanks for the tip.  Unfortunately I'm not interested in .net at all.

oh thank heaven for open source

Now that we agree on!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Frank, I haven't used SPI yet (even with arduino) and didn't see any SPI examples with USnooBie. So, how hard would it be to interface your USnooBie with the USB host shield sold at circuitsathome? Seems like it should work. It's just five pins. Thoughts?
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it's just an ATmega328P, it should be directly compatible with whatever library you throw at it as long as it doesn't occupy the USB D+ and D- pins.

Read http://www.circuitsathome.com/usb-host-shield-hardware-manual and also the schematic http://www.circuitsathome.com/chome_downloads/UHS_mini_10.pdf

Read http://frank.circleofcurrent.com/usnoobie/arduino.php , pay special attention to pin mapping

The SPI signals are obvious

As the webpage said, INT goes to pin 9 (meaning PB1)

Now you should be able to figure out how to wire it all up. The MAX_RST signal can go to any unused pin on the ATmega328P, I suggest you perform a reset of the MAX3421 upon resetting the ATmega328P just because it'll ensure that your firmware starts from a fresh state every time.

Set USnooBie to run at 3.3V using the jumper

The 5V pin from USnooBie is still available and you need to connect that to "RAW" on the USB host shield. Also read their site where it says
Quote
Mini shield lacks flexibility of its full size brother; however, here is one simple way to get 5V to VBUS using Arduino Pro Mini’s 3.3V on-board LDO. Power the board with 5V on RAW pin, cut the trace inside VBUS jumper, provide 5V from RAW to VBUS and get 3.3V from Arduino to the shield in the usual manner via 3.3V pin. While making this mod be extra careful and don’t short VBUS pad to USB connector shield. Also, this mod is easier to make when Arduino board is placed beneath the shield. Picture on the left shows necessary wiring.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Sr. Member
****
Karma: 2
Posts: 360
I'm 15. I like making things. I like breaking things better.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could just use a Teensy / other AtmegaXU2 dev board or an arduino uno with a usb host shield. They can all enumerate as USB HID with the proper firmware. If you want a one chip solution, the At90USB1287 supports host and device, but im not sure if it can do both simultaneously. Any of the devices listed here will work with LUFA as a usb device and a host shield for usb host: http://www.fourwalledcubicle.com/files/LUFA/Doc/091122/html/page_devicesupport.html

Good luck!
Logged

Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The fez Domino has usb host and device capabilities and plenty of example code to set you on track
http://www.ghielectronics.com/catalog/product/133 @60 dollars its not too bad ,

or if your able to, you can just get their Nxp chip pre loaded with .netmf and build your own board for a lot less.
http://www.ghielectronics.com/catalog/product/116

oh thank heaven for open source
I could not find any example code there - I think this might be spam
Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are no

Pages: [1]   Go Up
Jump to: