USBMouse and USBKeyboard with the new Cortex-M0 mbed!


You've probably seen we've got a new mbed Microcontroller on its way, based on the upcoming Cortex-M0 LPC11U24 from NXP.

What you perhaps didn't realise is quite how great this is going to be for building USB devices!

This video shows how to emulate a USB mouse using the new libraries we're creating for it. You can programatically send movement, button clicks and states, and even scroll the scroll wheel, and of course do this dependant on any sensors or logic you like. A really neat feature is the absolute version of the mouse, meaning you can move to a location on the screen; great for direct interaction with program interfaces.

Another example is emulating a keyboard:

In this example, we're sending media keys to control the PC media player, but you could of course type strings or send interesting keycode combinations and sequences. For example, in our "robot racing" setup, we had a laser beam breaker sending a keypress that was picked up by Javascript to start the timer and trigger other behaviour in a standard webpage.

A raw USBHID interface is also available to allow driverless custom interfaces to your favourite USB-capable programming language on the PC. We also have some other interfaces on the way, including USB MIDI (Musical Instrument Digital Interface) and USB Virtual Serial.

The examples are demonstrated on the upcoming LPC11U24 mbed, which is going to be a great platform for prototyping USB devices; the chip it uses is going to be cheaper than a dedicated USB to Serial bridge, and you get a microcontroller included!

To see more about the upcoming mbed NXP LPC11U24, and to get on the mailing list to know when they hit the shops, see:

7 comments on USBMouse and USBKeyboard with the new Cortex-M0 mbed!:

04 Nov 2011

I am experimenting with the mbed NXP LPC1768.

I want to use an optical mouse (no moving parts!) as a shaft encoder to measure displacement as I operate a 12 or 16 dot dotmatrix/inkjet printhead. It prints as the printhead is moved over a surface.

I currently use a digital pot. ( Hewlett Packard part HEDS-5700 F01 ) with direct interrupt/pulses counted for displacement and an 8031 circuit.

Is this possible with the mbed or your new setup ?

04 Nov 2011

These examples should also work with the LPC1768! (you'll still need to be in betamode atm)

04 Nov 2011

Lionel Bousfield wrote:

I want to use an optical mouse (no moving parts!) as a shaft encoder to measure displacement as I operate a 12 or 16 dot dotmatrix/inkjet printhead. It prints as the printhead is moved over a surface. Is this possible with the mbed or your new setup ?

No, this is different. These classes allow mbed to emulate a mouse for the PC, not read another mouse.

04 Nov 2011

The LPC1768 includes a USB Host interface, so in theory it should be perfectly possible to read a mouse over USB, although i'm not sure if anyone has published an example yet?

Out of interest, I once hacked an optical mouse to act as a motion detector (and scanner by reading the sensor + movement!); in that case, the mouse I had was a 2-chip solution and I actually went straight in to the sensor chip via I2C or SPI (can't quite remember) and read the sensor registers directly. Talking directly via USB could be a neater interface however (less control, but more standard).

Simon

04 Nov 2011
09 Nov 2011

The HEDS-5700 has an internal code wheel. This wheel is divided into x number of slits (360 degrees). Two LED shine through these slits as the shaft turns and photodetectors/logic circuit on the other side of the wheel produce the quadrature pulses whcih indicate the direction and amount of the rotation. The number of slits determines the resolution.

The current crop of optical mice are typcally image based. The mouse senor takes succcessive pictures as the mouse is moved and pictures are analyzed to determine the velocity of the move. These pictures are low resolution; can be as low as 16 by 16 pixels. A number of factors determine how well the mouse tracks. One of the key factors is the amount of microscopic features available on the tracking surface. As the surface becomes smoother laser technology is required to track. Such a sensor can be used to track a rotating shaft but will not be able to provide accuracy anywhere close to the optical encoder. Optical mouse relies on hand-eye coordination.

18 Jan 2012

Has anyone measured the delay between handling multiple, simultaneous keypresses?

You need to log in to post a discussion