Configuration of Arduino USB as a 3D - HID device

Introduction

The Arduino UNO was used as the interface between the ROBOTmaker's 3D HID sensor and a PC. Some main reasons in the first place is because Arduino UNO is... 
  • almost as cheap as a normal  RS232 level translator (e.g. Acroname BrainStem
  • most people probably already have one
  • USB control chipset  (ATmega8U2) on the Arduino is programmable/configurable  

As a practical exercise to test this sensor as a 3D HID device is to emulate a 3D mouse in a free 3D CAD package - such as 123D from AutoDESK -  such as http://www.iospirit.com/products/remotebuddy/  or http://www.3dconnexion.co.uk/products/spacepilot-pro.html?_s=1d92228a2f0073a547f14679d7f058bf.)  which is supported.

The research I did so far I've put on this webpage as a means of discussion and a record of what I've done so far / am doing.

Any help from other enthusiast is really welcome. So if you have anything you'd like to add please just add a comment to this webpage or contact Colin - support@robotmaker.eu

Where are we now?:

After almost a days of frigging around,  I put this project on hold until I get some more feedback and more time to get back to it.  I however managed to demonstrate that it's possible to get the ATmega8U2 chipset  (which is controlling the Arduino UNO's USB port (newer versions use different chipset)) to  load go into programming mode and to reload the  original hex file to the ATmega8U2 chipset using FLIP. I've added some screenshots to remind me how far I've got. If I could get a reliable .hex file build from the supplied makefile in winAVR I can continue.  As time is runnnig out, in the meantime I've decided just to use Teensy which is described here: http://www.instructables.com/id/USB-Game-Pad-With-Tilt-accelerometer-Mouse/step3/Introducing-the-Teensy-with-HID/. The final version will in anycase use it's own USB chipset, probably the same one the Arduino. 

An other option is to use a Teensy which has the native controller already installed. For iPAD see http://web.mac.com/kuwatay/morecat_lab./MocoLUFA.html


 

Background 
OK why are we doing this? I hear you cry! Well the main reasons is that the sensor so far works well through processing sketches, which is fine as a proof of concept but rather limited if you want to use the device within other applications. The device then really needs to emulate a 3D mouse or game controller.

Where's the issue? When you plug an Arduino into the PC / MAC  it recognises it as a USB Serial COM port, which is fine if you want to just read data from the Arduino. 

But if you want to emulate a mouse you need the PC to recognise it as a HID device. Luckly the latest versions of the Arduino UNO are fitted with the ATmega8U2 chipset to control the USB port. This chipset is a regular chip that can be reprogrammed and configured as a different device. Arduino supply all the code to do this -> here 

There has been a great deal of work done in this area such as Dean Camera's project LUFA and Zach Eveland  the 8U2 firmwares. To get this working it seemed that it only mostly required reprogramming the Arduino's USB chip. 


Why stop now?
The main reason why I had to stop working on this is that when trying to  recompile the usb-serial file using the makefile from Arduino the winAVR comes up with compiler errors. It has something to do with the paths and location of the source files. On closer inspection I see that the makefile points to files that no longer exist in the LUFA downloads so there is some general incompatibility between the latest versions or the versions that I've downloaded.  To reprogram the makefile will take me some hours so I therefore have put this on hold for now. If anyone else has cracked this please let me know. 


ATmega8U2 chipset

The AVR USB chipset version I discuss  on this webpage is for the ATmega8U2 chipset version. The latest Arduino USB versions are with a ATmega16U2 

 

The ATmega8U2 in firmware source code is available from the Arduino website. The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:

  • On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy) and then resetting the 8U2.
  • On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode.

One can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer (overwriting the DFU bootloader). See this user-contributed tutorial for more information.



Some Background References to read:

Here is a jumbled list of references that will be sorted out soon. 

http://arduino.cc/forum/index.php?topic=111.0

Upgrading 8U2 Firmware upgrading the firmware of the Atmega8U2 chip on an Uno or Mega2560. This chip acts as the usb-to-serial converter and can be updated via USB.As a backup copy the original and latest Atmega8U2 firmware versions herehttps://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares. Ensure to use the correct one. In my case the Atmega8U2 version. Ensure to copy and paste the hex file into a notepad as downloading just create a .html file for some reason! 




Other relevant search links


The proCONTROLL library allows Processing to communicate with controll devices like joysticks, joypads but also keyboards and mice. Using proCCONTROLL on MacOSX for example allows you to address more than one mouse. proCONTROLL bases on a modified JInput version. To get access to the different devices it has to communicate with native libraries.

To use a device with proCONTROLL you should ensure that it is properly installed first. Often a joystick has to be calibrated to work correctly. Use the printDevices() function to get a list of the available devices. There are two ways to use proCONTROLL you can access an device and ask for the current state of its buttons and sliders or you can plug methods that handle the events of buttons.


proCONTROLL is tested on Windows but should also work on Linux and MacOSX. http://creativecomputing.cc/p5libs/procontroll/  

LUFA (Lightweight USB framework for AVR by Dean Camera) & USB-HID Projects

Object Development
V-USB is a software-only implementation of a low-speed USB device forAtmel’s AVR® microcontrollers, making it possible to build USB hardware with almost any AVR® microcontroller, not requiring any additional chip. V-USB can be licensed freely under the GNU General Public License or alternatively under a commercial license. A comprehensive set of example projects demonstrates the wide range of possible applications. 
Arduino
Teensy
3DConnexion Sensor Driver for Windows 7

Using WiiRemote driver 
RMX AutomationREPRAP related links



Other sources (needs sorting out)

The following text has been taken from here: http://arduino.cc/forum/index.php?action=printpage;topic=111.0 (and here http://arduino.cc/forum/index.php?topic=111.0) and modified with some of my own texts.


http://arduino.cc/en/Main/ArduinoBoardUno
http://arduino.cc/blog/2010/09/27/arduino-0020-released-for-windows-and-mac-supports-uno-and-mega-2560/
http://www.ladyada.net/library/arduino/unofaq.html
http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf

Software

Hardware:
There are two modifications to do:
  • Solder 2 jumpers: one on the HWB line and one between pin 5 & 6 on ISP1 for RESET



How to put the Uno on DFU mode:
  • 4. put the 8U2 into USB DFU mode:
  • 4.a. assert and hold the 8U2's RESET line
  • 4.b. assert and hold the 8U2's HWB line
  • 4.c. release the 8U2's RESET line
  • 4.d. release the 8U2's HWB line
  • The device became USB DFU

Hardware, drivers installation:
  • Arduino Uno: drivers are on arduino-0020\drivers

Arduino Uno DFU: drivers are on Atmel\Flip 3.4.2\usb
  • Verify the board
  • Upload blink program on your uno to check that the board is working fine.

Compile firmware
To be sure that's working  change a line in Descriptors.c:UnicodeString = L"Arduino Uno" by UnicodeString = L"ArduINo UNO"
  • Open WinAvr/Programmer Notepad
  • Load makefile
  • I modify LUFA_PATH => LUFA_PATH = ../../   (ensure to download LUFA http://www.fourwalledcubicle.com/LUFA.php and make the path to point to where you put these libraries)

You should have to modify ARDUINO_MODEL_PID if you use MEGA
  • Do Tools[ch8594]Make clean
  • Do Tools[ch8594]Make allUpload Arduino-usbserial.hex on the board

  • make sure the board is in DFU mode
  • Start Flip
  • Select the device AT90USB82 (not the ATmega8u2!!)
  • Open usb communication
  • Select Load Hex file

Program target device memoryTest
  • Unplug the board and re-plug
  • The Name of the board should have changed : it becomes “ArduINo UNO”

Verify the board
Upload blink program on your uno to check that the board is still working fine.

 



The way I did it is as follows:
1. Install Flip to update the ATmega8U2 on the Arduino

To setup the project and upload the Arduino usbserial application firmware to an ATMEGA8U2 using the Arduino USB DFU bootloader:
1. unpack the source into LUFA's Projects directory
2. set ARDUINO_MODEL_PID in the makefile as appropriate
3. do "make clean; make"
4. put the 8U2 into USB DFU mode:
4.a. assert and hold the 8U2's RESET line
4.b. assert and hold the 8U2's HWB line
4.c. release the 8U2's RESET line
4.d. release the 8U2's HWB line
5. confirm that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU"
6. do "make dfu" (OS X or Linux - dfu-programmer must be installed first) or "make flip" (Windows - Flip must be installed first)

Check that the board enumerates as either "Arduino Uno" or "Arduino Mega 2560".  Test by uploading a new Arduino sketch from the Arduino IDE.


2. Open the Device Manager and right-click the Atmel USB device in the Jungo section.  Select the driver in the Program  Files /Amtel/Flip/Driver directory 


In the pop-up menu, select Update Driver.

AT90USB128 is an example; the actual device name is the one you are working with.


Programming the Freeduino

http://www.ftdichip.com/Drivers/VCP.htm

http://www.florian-leitner.de/index.php/2007/08/03/hid-usb-driver-library/

msinfo32.exe

Comments