quick key adapter, 10 button hid keyboard - chromation …€¦ · this instructable covers...

12
http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/ Home Sign Up! Browse Community Submit All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech Quick Key Adapter, 10 Button HID Keyboard by ChromationSystems on June 23, 2011 Table of Contents Quick Key Adapter, 10 Button HID Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Intro: Quick Key Adapter, 10 Button HID Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 1: Parts and Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 2: Construct PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 3: Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Step 4: Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Step 5: Flash Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 6: Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Step 7: Enjoy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Upload: haquynh

Post on 15-Apr-2018

233 views

Category:

Documents


5 download

TRANSCRIPT

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Home   Sign Up!   Browse   Community   Submit

   All     Art     Craft     Food     Games     Green     Home     Kids     Life     Music     Offbeat     Outdoors     Pets     Photo     Ride     Science     Tech

Quick Key Adapter, 10 Button HID Keyboardby ChromationSystems on June 23, 2011

Table of Contents

Quick Key Adapter, 10 Button HID Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro:   Quick Key Adapter, 10 Button HID Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1:   Parts and Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2:   Construct PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 3:   Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 4:   Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 5:   Flash Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Step 6:   Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 7:   Enjoy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Intro:  Quick Key Adapter, 10 Button HID Keyboard

This Instructable covers creating a USB connected Human Interface Device Keyboard that has 10 button inputs which are mapped to key combinations in the firmware.Key combinations can be quickly accessed without using the keyboard which may be inconvenient to use. Such as with a MAME or similar machine where the keyboardmay be stored or certain keys may be used frequently but aren't mapped to any of the arcade buttons. 

Such as: Alt+F4 for Close Program, Windows+D to Show Desktop, Minimize Window, Maximize Window, Multiple Launch Program or Emulator, Alt+Ctrl+Del, CoinButtons, 

The custom hardware(circuit) is based on Microchip Solutions sample "USB Device HID Keyboard" firmware for the Low Pin Count USB Development Kit which uses a18F14K50. The development kit is not required to recreate this as included here is a schematic, PCB layout and firmware to build one from scratch.

It does not require any external power supply, it draws from the USB host. All the keycodes are set in firmware and are for Windows based OS's, additional OSs could beused but the keycodes would have to be changed from firmware.

This device is similar to U-HID or similar but with a lot less keys and no software to change or set key combos.

If someone would like to send me key codes for a different OS, I will put together the firmware and post it to this Instructable.

Included in the ZIP below is PCB Layout, Schematic, diagrams, MPLAB project files, HEX file, readme, and the datasheet. Or you can view the Datasheet Here

DISCLAIMER: Recreate this project at your own risk. There is always risks when building your own electronics, be careful. Damage to the computers USB bus ispossible, but not probable when everything is built correctly.

Image Notes1. Dot and Notch

File Downloads

ChromationSystems-QuickKey_v1.zip (591 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'ChromationSystems-QuickKey_v1.zip']

Step 1: Parts and Supplies

Complete Kits including the programmed PIC is available in my Store

Basic Kits including the programmed PIC, without buttons and wire are also available.

Parts:

PIC18F14K50 - DIP package, Buy One Programmed2x 10k 5 bused resistors Like ThisUSB Type B Socket12 mhz Oscillator, series*0.1uF disc Capacitor220nF disc Capacitor4 pin Header, such as Molex KK64104 pin Housing, such as Molex KK 64716 pin Header, such as Molex KK64106 pin Housing, such as Molex KK 6471Crimps, Molex KK 4809Wire, solid strand and strandedPrinted Circuit Board or Perforated Proto board and solid strand wire10 Normally Open Push buttons, board mountUSB Type B to Type A cable(most devices such as printers use them) Buy One

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

*Normal crystal oscillator can be used, just add a 22pF capacitor from each OSC pin to ground.

Tools:

Soldering IronWire StrippersDiagonal Cutters

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Image Notes1. Type of bused resistor required.

Step 2: Construct PCB

If Purchasing A PCB or Making one yourself, have it ready before beginning this step. Perforated board could also be used, then just follow the schematic.

The silkscreen PCB layout image included in the ZIP in Step 1 should be accessible for this Step, it shows the parts layout.

- Start with the 20-pin socket, the notch on the end marks the Pin 1 end. Carefully insert it, ensuring all pins line up.

- Resistor Buses are next, they each have 5 10k resistors in parallel within them with a common pin on one end, The common pin, which is marked with a dot on the SIPpackage should be lined up with the printed dot on the end of RN1 and RN2.

- Oscillator, ensure the solder joints are shiny and designing your own board, it should be as close to the MCU as possible.

- Capacitors C1 & C2: C1 is a 100nF disc cap for decoupling, C2 is a 220nF capacitor connected between the MCU's VBUS pin and V+.

- Resistor R1 pulls the Data+ line high, which signals to the Host what USB speed the Device runs at.

- USB Receptacle: It only goes in one way, Bend the mounting pins outward once it is in the board, solder all the contacts ensure their good joints. Make sure the solderdoesn't bridge, as the contacts are quite close together.

- Headers: The polarized headers go in now, they can go in facing either way, there is a 4-pin and a 6-pin.

- PWR: Unused power header, leave it empty but solder over both pads. It is there in case more power than the bus can provide would be needed if the device wasrepurposed.

- Jumpers: Lastly the jumpers are installed, using these means that single sided copper circuit board can be used. Use some solid strand wire. And avoid other touchingother parts, especially bare wire line on a capacitor.

J1 is jumped to J2P1 is jumped to P2 which is jumped to P3. solder 2 wires into P2, then one wire each goes to P1 and P3.G1 and G2 are left open, explained in the next step.RX and TX are also left open and are not used, but are connected to the USART.

All the electronic parts except the PIC microcontroller and switches should be installed onto the circuit board. Look over everything carefully for jumps, bad solder joints,loose wires, or parts. 

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Image Notes1. Dot on resistor bus matches with dot on PCB

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Step 3: Buttons

Buttons are connected as seen in the diagrams. The buttons are pulled-high by the device, bringing an input pin to ground will signal that the button has been pressed.And send the firmware assigned command from the device to the host computer.

Shown here is the layout I chose for my buttons, I am placing them under the monitor bezel. I am only using 9 buttons so I can have one centered.

Buttons are quite easy to wire up, some push button types have 4 and can be wired as normally open or normally closed, others have 2 leads. But either way normallyopen are required, so when the button is pressed it will connect the sw1-10 to ground, thus pressing the button.

Wiring:

- Mark the hole locations on the panel that the buttons will be mounted on.

- Measure the width of your push buttons and drill a hole a bit bigger than that measurement. Otherwise drill them smaller and use a small file to square the corners of thehole so the buttons will fit. Ones included in the kit should drill with a 3/8th bit or a tad smaller.

- Prep the medium used to mount the buttons, I am using perforated board to mount the buttons on, cut it to fit my hole spacing.

- Using the drilled holes as a guide mount the buttons onto the perfboard or other medium, checking the spacing.

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

- Once the buttons are mounted, they all will need to have one of their leads soldered in parallel with one lead from all the other buttons.(see image), this will be theground rail,

- Connect a wire from all the buttons grounds to the a GND jumper hole on the PCB. Either one.

- Then connect the remaining lead from each of the buttons to its corresponding header on the PCB. If using crimps and housings which are supplied with the purchasedkit, read This Tutorial for instructions on crimping. Or solder the wires from the buttons directly into the PCB.

Attaching:

- Once all the buttons are wired up they can be inserted into the panel with the holes drilled in it.

- Use some glue(hot works good) or some tape that doesn't stretch, to attach the perfboard, and hold the buttons in place.

- Finish attaching all perfboard with buttons.

- Once the buttons are in place, find a good spot for the PCB and mount it with some tape, glue or screws.

Decals: Now from the front there will be holes with the square buttons in them, looks ugly so it will need some decals. Once all the other graphics are completed ofcourse. Included in the ZIP is some graphics I made for my button layout. I printed them onto vinyl graphic material, lamented, and contour cut them in a vinylcutter.(Machine that cuts out shapes from sheet material)

---> Offering Reprints of my Graphics and Custom Graphics, any shape, size, image, Contact Us for Details <----

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Image Notes1. Layout for my cabinet, only using 9 of the buttons

Image Notes1. Ground Wires are soldered in

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Step 4: Firmware

This device's design is based on the Low Pin Count Development Kit hardware from Microchip, Microchip Solutions has example programs for that development kit so itis quite easy to get them running on the device covered in this Instructable.

For the purposes of this project I used the USB Device - HID - Keyboard example for the Low Pin Count Development Kit. But there are various other devices that couldbe programmed onto this hardware/device, anything that could use 10 switch inputs.

Included in the ZIP on Step 1 is the MPLAB project files, you must install the latest version of MPLAB and the latest release of C18 compiler. Microchip Downloads CanBe Found Here

Firmware Overview:

The included project files were taken and modified from Microchip's example code. They had wrote it in a way so it can run on multiple different PIC devices, so there is alot of extra code not needed. The rest is mostly USB related code, the only function that was modified was the Keyboard() function.

ProcessIO() -> Keyboard() -> Check if IN endpoint is ready -> Check Switches ->Send Data -> ProcessIO()

The switches state are checked and compared to their previous state. if the states differ the switch is considered pressed and will fill a data buffer with/the required datathen send it. Then continue checking the switches.

hid_report_in[0] = is the modifier byte, it holds the state of the shift, alt, ctrl, gui(windows) keyshid_report_in[1] = 0; is reserved and always 0hid_report_in[2] thru [7] // Can be a keycode, up to 6 keys can be pressed and reported at onceSee the "HID Usage Tables" pg. 52 for keycodes

Modifier key chart:

Bit Key0 LEFT CTRL1 LEFT SHIFT2 LEFT ALT3 LEFT GUI4 RIGHT CTRL5 RIGHT SHIFT

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

6 RIGHT ALT7 RIGHT GUI

Example:         hid_report_in[0] = 4; //alt         hid_report_in[0] = 8; //L GUI         hid_report_in[0] = 7; //ctrl+alt + shift

Some commands need a second key sent or key combo sent, by setting filling the data bytes NextModKey and NextKey then setting AnotherFlag flag in the firmware,after the primary command is sent it will send another report with those key values.

Such as Minimize Window which the Windows hotkey is Alt+Spacebar, then press n.

Step 5: Flash Microcontroller

Kits and PIC's Purchased Here, come programmed and ready to use. Just carefully plug it in, lining up the dot on the MCU with the notch in the 20-pin socket, ensuringall the pins line up, then press it in firmly.

If you have a blank PIC18F14K50 or want to be able to flash the firmware, there are 2 options.

- Program the chip in an external programmer and insert it into its socket, remove to reprogram if necessary.

- Or a ICSP header can be attached to the bottom of the PCB, using some wires to connect the proper solder pads to the PIC's ICSP headers, and use that to programand reprogram.

Check everything over well, a short could damage the Host Computers USB bus. All solder joints should be shiny.

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Image Notes1. Dot and Notch

Step 6: Usage

This device is a Human Interface Device which do not require any drivers or setting up. Its Plug and Play.

Once you are confident that the circuit is correct, its time to power it up.

For Windows OS users: (this part isn't necessary but it helps be sure it is working or not when its first ran)

- First open Device Manager

- Plug in the finished QuickKey Adapater

- In Windows the Device Manager will refresh itself after it detects the device

- Under Human Interface Devices "QuickKey v.1" will appear with a yellow exclamation mark, it will go away and refresh again after a second.

- Its name will get changed from QuickKey v.1 to USB Human Interface Device.

Assuming there is nothing now listed with a yellow exclamation mark, the device is working properly.

Button Codes: Pressing the buttons will signal the firmware to send a key or keys to the Computer. All 10 of the keys are set to send different key combinations, whichthe computer uses to run commands or actions. The key codes that are programmed in the supplied firmware are meant to be used with a Windows computer, and won'twork on other OS's but the firmware can be modified with ones that would. 

sw1 - Opens Task Manager - Alt + Ctrl + Delsw2 - Close Open Program - Alt+F4sw3 - Minimize All Windows(show desktop) - Windows Key + Dsw4 - Maximize Window - Alt + Spacebar -> Xsw5 - Minimize Window - Alt + Spacebar -> Nsw6 - Escape - Escape Key, exits most gamessw7 - Toggle Full Screen - Alt + Entersw8 - Open Program(Emulator Launcher Program) - Alt + Ctrl + Shift + L, set a windows Hotkey to a desktop shortcutsw9 - Coin1 - Ctrl + 1sw10 - Coin2 - Ctrl + 2

http://www.instructables.com/id/Quick-Key-Adapter-10-Button-HID-Keyboard/

Image Notes1. Dot and Notch

Step 7: Enjoy

Thank You for reading my Instructable, I hope it has been useful. If any of the information is wrong, please send me a PM I want fix it.

Check Out all of my other Instructables In My Profile or on my Main Website's Project Page

I have Kits for This and Many Other Projects In My Store, Take a Look and Maybe Show Some Support By Purchasing.

Keep A Look out by Subscribing for my future projects including: More Uses for my 24 Channel High Current LED Controller  enthralling cylinder style lamp,MAME/Emulator Touch Screen Arcade, 24" Round Infinity Mirror with 16 Channel RGB LED Driver and USB connected software.

Image Notes1. The buttons installed! with no graphics yet2. My Emulator Arcade Cabinet, soon to be released Instructable.