Jump to content

an Arduino USB HID controller, composite USB controller


overpro

Recommended Posts

This is an arduino Mega2560R3 based USB joystick controller,

I have successfully made it as a composite USB device lol.gif,

that means one arduino = two usb joystick controller, the reason to do this is DCSW only recognize 128 keys per USB joystick controller. If we have 2 then there will be 256 keys

attachment.php?attachmentid=90983&stc=1&d=1385408909

attachment.php?attachmentid=90984&stc=1&d=1385408909

 

 

program your Mega2560

download Arduino IDE from arduino.cc and download the arduino sketch from here:

https://github.com/calltherain/ArduinoUSBJoystick/tree/master/arduino

open the .ino file in Arduino IDE and upload it to your mega2560.

 

program the USB firmware

The 2nd step is to program the USB firmware, you need to use Atmel Flip:

http://www.atmel.com/tools/FLIP.aspx

 

Download and install flip, you need to make your Mega2560 enter DFU mode: with your mega2560 plugged, just simply shortcut the 2 pins momentarily at here:

attachment.php?attachmentid=90985&stc=1&d=1385409173

Windows will recognize it as a new device, and you need to manually install the driver by using this file:

C:\Program Files (x86)\Atmel\Flip 3.4.7\usb\atmel_usb_dfu.inf

 

After the driver is installed, run Flip and select the chip type: ATmega16u2

then Open the USB port ( ctrl + u, click OPEN ) and load the usb controller firmware, see attached cvpJoystick YYYY-MMM-DD.zip file.

 

====1HID with 256 buttons is also available====

If you want a single joystick with 256 buttons please use this firmware instead.

http://forums.eagle.ru/showpost.php?p=2522938&postcount=142

But note that most of the Flight sims doesn't support such a joystick.

FSUIPC is the only one which has been confirmed works good for now.

----------------------------------------------------------------

 

Click "RUN" button at the lower left corner and it only takes 1 second to program the chip.

Unplug and replug your mega2560 and you are good to go.

 

If you want to make it back to a normal Mega2560 then repeat the above step but load the original mega2560 USBSerial firmware from here:

https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial

Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex

 

Pin config on Mega2560

Pin 22~37 are row pins and 38~53 are column pins, you might need to build a keyboard matrix by your self, Row 0~3( pin 22,23,24,25) is reserved for rotary encoder, you need to wire the common pin of the rotary encoder to mega2560 22~25, and wire the A, B pin on the encoder to 0,1 or 2,3 or 4,5 ..... column pins ( mega2560 38,39 or 40,41 ..... )

 

Known Issue

The firmware might have some issue and if you encounter any problem please provide your comments on github or at this thread.

github.com/calltherain/ArduinoUSBJoystick

http://forums.eagle.ru/showpost.php?p=1934885&postcount=5

If you want to build the firmware by yourself you need a Linux machine.

 

License

The code is released to Public Domain

 

Source Code

https://github.com/calltherain/ArduinoUSBJoystick

I hope you enjoy it.

 

ps. this firmware is inspired by Darran's project: Arduino UNO Big joystick HID firmware: http://hunt.net.nz/users/darran/weblog/15f92/

with out Darran's code I will never make this work. Thanks Darran.

 

 

---------------------------------

Firmware compilation instruction

---------------------------------

 

This is a simple instruction to guide you compile the firmware in ubuntu.

 

1. Make sure you have these packages installed on Ubuntu

build-essential
avr-libc
c-compiler
make

you can use this command to install these packages:

sudo apt-get install avr-libc c-compiler make build-essential

2. download the firmware source code from github

cd ~
git clone https://github.com/calltherain/ArduinoUSBJoystick.git

3. download LUFA library

cd ~/ArduinoUSBJoystick
wget https://lufa-lib.googlecode.com/files/LUFA-130901.zip
unzip LUFA-130901.zip -d LUFA

4. by the end of step 3, you should get a folder structure like this:

attachment.php?attachmentid=111071&stc=1&d=1420810443

 

now go to /ArduinoUSBJoystick/firmware/cvpJoystickTest/ and execute

make

the compiled binary is cvpJoystick.hex, you can use FLIP to flash it into your Mega2560's atmega16u2 chip under it's DFU mode.

 

 

---------------------------------------------

Flash the original firmware to your Atmega16u2

---------------------------------------------

 

If you are unable to go to DFU mode it's possible that the firmware within your Atmega16u2 doesn't have a proper bootloader code within bootloader section in the flash.

 

You will need an USB ISP programmer to flash a correct firmware.

 

I attached a working version firmware (atmega16u2.zip) which includes a proper bootloader here just incase you can't find one.

 

connect your USB ISP programmer to the atmega16u2 ISP pins, you might need some Dupont Line to do this.

attachment.php?attachmentid=111077&stc=1&d=1420811626

 

There are many ISP programmer software available out there, I personally use Progisp.exe, downlod atmega16u2.zip and extract it to .hex file, load it into progisp.exe and flash it, all done.

1461638052_2013-11-2603_13_00-GameControllers.png.1b7781b82a6196ee689f5fdcbab7cf4b.png

DualController.jpg.bd037ca41f5edd740f724e24550faf4f.jpg

gotoDFU.jpg.26fbdfff96f181d79f4b08e48e1d6d25.jpg

cvpJoystick 2013-Nov-29.zip

1805337731_2015-01-0921_30_14-UbuntuD6402(1204preupgrade)Running-OracleVMVirtualBox.jpg.1fbcb8574d85c079054fe908059ecdba.jpg

274287605_2015-01-0921_51_05-1Board-D__Parts_arduino_arduino-mega2560_R3-reference-design_Arduino_MEGA.jpg.0e9a8e326f6ca2c091c4b5039d30967b.jpg

atmega16u2.zip


Edited by overpro
title change
  • Thanks 1

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Known issue:

 

Issue#1 ( Fixed ):

after several hours, the button ID might drift to a new position, for example, the button 1 press might be changed to button 57 press.

I'm still investigating the issue, it might be caused by the RingBuffer manipulation in the USB firmware.

update: if Computer sleep (STR) and resume, the button id will drift.

update: Submitted a fix on github and updated the compiled .hex file in the main post.

 

Issue#2 (Fixed on 2013-Nov-29 )

With the controller attached, the computer will be blocked at POST, unless unplug it then computer will continue to boot:

The fix: The HID report will send to host only if the button status changed or the defined idle time has elapsed.

 

Issue #3 (Fixed on 2013-Nov-28 )

The Row8 ( digital pin 29) key scan code has an issue. It's a bug in arduino sketch.

https://github.com/calltherain/ArduinoUSBJoystick/blob/e091929ceb7bc5b7a2c39cb4fb719003b74b1e05/arduino/CVP_JoystickController/CVP_JoystickController.ino

Now fixed.


Edited by overpro

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

If you have programmed your MEGA2560 yesterday please flash the USB firmware back to normal MEGA2560 and reprogram the arduino sketch by downloading the sketch from github page.

And use the latest USB firmware in the top post.

 

Some error were fixed.


Edited by overpro

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

This looks great and just what i was looking for,

 

im trying to make the two MFCD's for the warthog, although i dont quite understand how i would wire this up, could you maeby post a picture or explain the physical connection of the buttons to the board? :) also can it support the 48 buttons needed for 2 mfcds?

Link to comment
Share on other sites

This looks great and just what i was looking for,

 

im trying to make the two MFCD's for the warthog, although i dont quite understand how i would wire this up, could you maeby post a picture or explain the physical connection of the buttons to the board? :) also can it support the 48 buttons needed for 2 mfcds?

 

This diagram is borrowed from MJoy16 document, the schema is almost identical, except we have 16 rows and 16 columns, and Row 1~4 are reserved for rotary encoders.

attachment.php?attachmentid=91043&stc=1&d=1385519789

Please note that the diode is 1N4148, and this is REQUIRED to eliminate the ghost effect.

 

 

If you just want to perform some basic test, just wire the button's two pin to row / column pin:

Please note the row 5 ~ 16 should be used for button / toggle switch.

attachment.php?attachmentid=91045&stc=1&d=1385519789

 

or you can test your rotary encoder as well, please note Row 1~4 are used for rotary encoder.

attachment.php?attachmentid=91046&stc=1&d=1385519789

903493911_2013-11-2710_18_32-MJoy16-MJoy16-C1_Users_Manual_v1_pdf.thumb.png.e6bfb6236836bf5f84a73a6e9c878758.png

IMG_20131127_103402s.jpg.e4a82c1705a5319ee1b7d8fbb8ef2d80.jpg

IMG_20131127_103458s.jpg.3441327fc396213d51244752e9e34145.jpg

  • Like 1

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Nice work

What is your encoder?

With FLIP, I can't load the cvpArduinotest-131126.

 

Hi usul, you need to extract cvpArduinotest-131126.zip, and use flip to load the extracted file: cvpArduinotest.hex, Flip will report "HEX file parsed".

attachment.php?attachmentid=91066&stc=1&d=1385603271

1647056856_2013-11-2809_46_32-D__cvpArduinotest_hex.jpg.bba0c0c3b16a972ed8b6ad91d7873111.jpg

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Hi overpro and thank you

I try it but Flip send me this message : cannot open file

Other thing : im looking for encoders as yours. where do i find them?

Well, this is weird, I haven't had this issue before.

Are you using Flip 3.4.7 build 112?

 

 

Regarding the rotary encoder, it's just the normal type: 20 pulse per round,

like this:

http://www.ebay.com/itm/20pcs-lot-12mm-Rotary-Encoder-Switch-W-Keyswitch-HQ-New-free-shipping-/261299009115?pt=LH_DefaultDomain_2&hash=item3cd6a2765b

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Thanks for share this but i can´t convert my MEGA 2560 into DFU mode, I touch both pins but this back to the normality

Hi Trueno, here is a detailed instruction from Arduino.cc website:

http://arduino.cc/en/Hacking/DFUProgramming8U2

 

You might want to check this first.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

  • 1 month later...

Thanks for the info in this thread. I am new to the simpit building and would like to follow this route to build my first panel. I am Ok with the software side of things but ignorant with the hardware side. How would I wire switches to the arduino? If someone could point me in the right direction I would be obliged. Examples of how to wire a switch or a button in simple terms would be great. Thanks.

Link to comment
Share on other sites

Thanks for the info in this thread. I am new to the simpit building and would like to follow this route to build my first panel. I am Ok with the software side of things but ignorant with the hardware side. How would I wire switches to the arduino? If someone could point me in the right direction I would be obliged. Examples of how to wire a switch or a button in simple terms would be great. Thanks.

 

Hi Sifhanar

Please have a look at the message at 8th floor :

http://forums.eagle.ru/showpost.php?p=1935590&postcount=8

  • Like 1

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Hi overpro, thanks for your reply. I did look at the diagram but unfortunately my knowledge of electronics is severely limited. I was hoping someone could point me in the direction of an idiots guide on how to connect to the device. The only electronics construction I have done is to build kits that have instructions showing me where to place components on a board! Thanks

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...