USB Host Shield (HCARDU0060)

Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

USB Host Shield (HCARDU0060)

Post by admin » Mon Jan 21, 2013 6:40 pm

Image
Arduino compatable USB host shield

Image
Shield plugged into R3 Uno (Not included)

Description:
Fully compatible with Arduino Uno, Duemilanove, and Mega. Allowing you to control the following devices:

HID Compliant devices such as Keyboard, mouse etc.
Compatible with the Android ADK
Digital SLR cameras such as Canon, Nikon, Powershot, etc.
Game console controllers including Wii controller.
Other USB serial communication devices such as GPS, FTDI etc.


Order Yours Here.


Schematic
MAX3421E.zip

Example HID USB Keyboard sketch:

Code: Select all

/* FILE:    HCMODU0060_USB_Host_Shield_Keyboard_Test
   DATE:    05/07/12
   VERSION: 0.1
   
REVISIONS:

05/07/12 Created version 0.1


This is an example of how to use the Hobby Components USB host shield. This
example is to simply tests the shield is operating correctly. To use this 
example you will need to connect a SB keyboard to the shield. Open up the 
serial monitor window and set the baud rate to 115200. The sketch will report 
any key presses to the monitor window.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, 
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */



#include <SPI.h> 
#include <Usb.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidescriptorparser.h>


 
class HIDUniversal2 : public HIDUniversal
{
public:
    HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
    
protected:
    virtual uint8_t OnInitSuccessful();
};
 
uint8_t HIDUniversal2::OnInitSuccessful()
{
    uint8_t    rcode;
    
    HexDumper<USBReadParser, uint16_t, uint16_t>    Hex;
    ReportDescParser                                Rpt;
 
    if (rcode = GetReportDescr(0, &Hex))
        goto FailGetReportDescr1;
                    
    if (rcode = GetReportDescr(0, &Rpt))
            goto FailGetReportDescr2;
 
    return 0;
 
FailGetReportDescr1:
    USBTRACE("GetReportDescr1:");
    goto Fail;
 
FailGetReportDescr2:
    USBTRACE("GetReportDescr2:");
    goto Fail;
 
Fail:
    Serial.println(rcode, HEX);
    Release();
    return rcode;
}
 
USB                                             Usb;
USBHub                                          Hub(&Usb);
HIDUniversal2                                   Hid(&Usb);
UniversalReportParser                           Uni;
 
void setup()
{
  Serial.begin( 115200 );
  Serial.println("Start");
 
  if (Usb.Init() == -1)
      Serial.println("OSC did not start.");
      
  delay( 200 );
 
  if (!Hid.SetReportParser(0, &Uni))
      ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1  ); 
}
 
void loop()
{
    Usb.Task();
}

Library:


Libraries and sample code

Known working snapshot:
USB_Host_Shield_2.zip


FAQ:

I've tried the example sketch but I don't see any response in the monitor window and my USB device doesn't seem to be powered.

On the host shield there is a set solder-able jumpers for configuring various options. Three of these route power from the Arduino to the shield and to the USB host connector. Check that these pads are links with solder:

Image



Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

rs1962
Posts: 1
Joined: Fri Sep 19, 2014 9:19 am

Re: USB Host Shield (HCARDU0060)

Post by rs1962 » Fri Sep 19, 2014 9:33 am

Can this shield interfere with components plugged into it?

I have mine plugged into a branded Uno, running the example mouse reader sketch it works fine. I decided that I'd like to put my 1602 LCD on it to get some onboard readouts instead of using serial monitor. Unfortunately, the LCD isn't working properly, even with external power; it just continually prints the odd character - looks like an 'n' with a line above it.
If I load a sketch to test the LCD alone it works fine, so it seems that there is a conflict when using the LCD and USB libraries.
I've tried using different data pin assignments but I get the same issue.

Not a massive issue as I'm not using LCD for the final project but I'd like to know why it's happening in case I do want to have this setup in future.

Cheers

Ron.

Post Reply

Return to “Arduino Shields”