10 years, 3 months ago.  This question has been closed. Reason: I have found the solution!

USBMouse example - USB Device not recognised

Hi I have been trying to get my mbed to be recognised as a USB device. I have made the connections as shown in the handbook:

/media/uploads/langster1980/mbed_usb_connection.jpg

If people prefer here is an eagle schematic image:

/media/uploads/langster1980/mbed_usb_device.png

I can see the mbed power LED is illuminated and something is obviously occurring because when I plug and unplug the device I can see an unknown device appearing and disappearing in control panel and device manager. I tried swapping the D+ and D- connections but nothing seems to make things work. Can anyone provide me with a solution?

/media/uploads/langster1980/mbed_mouse_not_recognised.png

Cheers

Alex

1 Answer

10 years, 3 months ago.

Judging by your picture you have the USB Vcc pin connected to mbed Vu (pin 39) rather than to Vin (pin 2). This might still work, but is not recommended because you might damage one of the voltage regulators.

Once you have messed around with an HID device that is not properly recognised you may have to change the VendorID and ProductID parameters in the HID library to avoid confusing windows.

Accepted Answer

I did wonder about the 5V connection. I was following the picture in the mbed USBdevice handbook. I have tried both methods of connection. It makes no difference to the result though I will change it.

/media/uploads/langster1980/lpc1768_usbdevice.jpg

How do I make changes to the HID library as necessary? There is no mention of that in the handbook.

Thank you for responding

posted by Alexander Lang 13 Jan 2014

The second picture above also seems wrong! Looks like you have Vcc wire of USB connected to Vout on mbed, that is even worse than connecting it to Vu! The Vcc wire should go to Vin, that is pin 2 on the LEFT side of the mbed module.

The vendor_id and product_id are parameters of the constructor that have default values, but can be overriden:

class USBMouse: public USBHID
{
    public:
        
        /**
        *   Constructor
        *
        * @param mouse_type Mouse type: ABS_MOUSE (absolute mouse) or REL_MOUSE (relative mouse) (default: REL_MOUSE)
        * @param vendor_id Your vendor_id (default: 0x1234)
        * @param product_id Your product_id (default: 0x0001)
        * @param product_release Your preoduct_release (default: 0x0001)
        *
        */
        USBMouse(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0001, uint16_t product_release = 0x0001): 
            USBHID(0, 0, vendor_id, product_id, product_release, false)
            { 
                button = 0;
                this->mouse_type = mouse_type;
                connect();
            };
posted by Wim Huiskamp 13 Jan 2014

Wim...

The second picture is taken directly from the USBdevice section of the handbook! I think though the picture is suffering from a parallax error and the mbed in the picture with the connector is connected with the +5V pin connected to Vout...it is confusing though and I think that needs updating in the Handbook to pin 2. I am connected as you suggested with the +5V pin of my USB connector connected to pin 2 of the mBed.

/media/uploads/langster1980/mbed_actual_connections.jpg

It makes little difference as I have since found that when Windows detects my 'Unknown Device' the associated VID and PID number as 0000....which suggests that something else is wrong. I don't think I've fried my mBed as it works as a host USB device perfectly well and seems to program correctly. All the other programs I have uploaded have worked perfectly....

/media/uploads/langster1980/mbed_unknown_device.png

I have no idea why it keeps giving a 0000 for a VID and PID number though and there does not seem to be any mention of it anywhere else. Thanks for pointing me towards where the VID and PID number are hard coded though that is useful information.

If you or anyone has any idea why my VID and PID number are always 0000 that would be helpful.

Cheers

posted by Alexander Lang 13 Jan 2014

Wim...I have it working correctly now. Thank you for your assistance. The VID and PID number were set to 0000 in the library and I had not updated it correctly....Found it now, Very much appreciated!

Alex

posted by Alexander Lang 13 Jan 2014