USB Game Controller

USB Game Controller

PR26 USB Game Controller Version 1.0 October 2009 Cytron Technologies Sdn. Bhd. Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is assumed by Cytron Technologies Incorporated with respect to the accuracy or use of such information or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Cytron Technologies’s products as critical components in life support systems is not authorized except with express written approval by Cytron Technologies. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. OVERVIEW Just connect, play and you learn - it's that simple. This document describes the development of Cytron Schematic and source code is provided. Technologies DIY (Do It Yourself) Project PR26. This firmware implements a standard USB game controller FEATURES with 12 inputs (4 directional buttons and 8 general purpose buttons) and 4 analog inputs. There are no PIC18F2550 drivers required, since USB standard defined device - 8-bit microcontroller with 22 I/O classes, this project using the human input device (HID) - Operate with 5V supply which allows user to tell the computer that the - Operating speed 20MHz connected USB device is a game controller. This - Full Speed USB 2.0 (12Mbit/s) interface project will be using PIC18F2550, push button and Joystick joystick to give a guideline to hobbyist on how to build - With 2-axis (x-axis and y-axis) and 1 push a standard USB Game Controller. The performance of button the USB Game Controller can be tested by using PC. Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved ROBOT . HEAD to TOE PR26 – USB Game Controller SYSTEM OVERVIEW 12 Push Buttons PIC18F2550 HID USB interface Computer 2 Joysticks GENERAL DESCRIPTION More information on PIC18F2550 can visit the website PIC18F2550 at: Ideal for low power (nanoWatt) and connectivity http://ww1.microchip.com/downloads/en/DeviceDoc/3 applications that benefit from the availability of three 9632D.pdf serial ports: FS-USB (12 Mbit/s), I²C™ and SPI™ (up to 10Mbit/s) and an asynchronous (LIN capable) serial port (EUSART). Large amounts of RAM memory for HARDWARE buffering and Enhanced FLASH program memory This project will require following hardware: make it ideal for embedded control and monitoring applications that require periodic connection with a a. 1 x PIC18F2550 (legacy free) Personal Computer via USB for data b. 1 x PR26 Printed Circuit Board (PCB) upload/download and/or firmware updates. c. 12 x push button d. 2 x joystick Feature of the device: e. 1 x USB B type connector • High-Current Sink/Source: 25 mA/25 mA f. 1 x USB cable • Three External Interrupts g. 1 x 9V-12V power supply • Four Timer modules (Timer0 to Timer3) h. Related electronic components • Up to 2 Capture/Compare/PWM (CCP) modules: • Enhanced Capture/Compare/PWM (ECCP) Please refer to Appendix A for the board layout of module PR26. The board layout is provided free therefore • Enhanced USART module Cytron Technologies will not be responsible for any • 10-bit, up to 13-channel Analog-to-Digital further modification or improvement. Converter module (A/D) with Programmable Acquisition Time • Dual Analog Comparators with Input Multiplexing Interface joystick with PIC18F2550 • 100,000 Erase/Write Cycle Enhanced Flash Program Memory typical • 1,000,000 Erase/Write Cycle Data EEPROM Memory typical • Self-Programmable under Software Control • Priority Levels for Interrupts • 8 x 8 Single-Cycle Hardware Multiplier • Extended Watchdog Timer (WDT) • Programming™ (ICSP™) via two pins - In-Circuit Debug (ICD) via two pins - Optional dedicated ICD/ICSP port (44-pin Figure 1 devices only) - Wide Operating Voltage Range (2.0V to 5.5V) The analog-to-digital (A/D) converter module has inputs for the 28pins PIC18F2550. This module allows conversion of an analog input signal to a corresponding Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved ROBOT . HEAD to TOE PR26 – USB Game Controller 10-bit digital number but we only use 8-bit for this Since USB standard defined device classes, this project project. using the human input device (HID) which allows user The module has five registers: to tell the computer that the connected USB device is a • A/D Result High Register (ADRESH) game controller and has 2 joysticks and 12 buttons. • A/D Result Low Register (ADRESL) • A/D Control Register 0 (ADCON0) First of all, we have to set down the data in the HID • A/D Control Register 1 (ADCON1) Report Descriptor to tell the computer of what function • A/D Control Register 2 (ADCON2) the device has, and how many bytes of data needed to be sent back to the computer. For more detail about USB, please visit www.usb.org. The information on report descriptor will be explained more at software part later. Device Class Definition for Human Interface Devices (HID) The HID class device class uses the following standard USB descriptors: • Device Figure 2 • Configuration • Interface In this PR, we have 4 analog outputs from two • Endpoint joysticks (x-axis, y-axis, z-axis, z-rotation), so analog • String input pin of AN0-AN3 are connected to the 4 presets from joysticks. But make sure the ADC configuration USB Descriptor in the programming is correct. Each device class includes one or more class-specific descriptors. These descriptors differ from standard USB descriptors. A HID class device uses the following class-specific descriptors: HID, Report and Physical. • HID Descriptor The HID descriptor identifies the length and type of subordinate descriptors for a device. Figure 3 A/D converter module is enabled, by setting bit0 of ADCON0 as 1. Default ADCON1 as only 4 analog pins (AN0-AN3) are used. Use left justified for A/D Result Format Select bit by setting bit7 of ADCON2 as 1. For ADCON2, set ADCS2:ADCS0 (A/D Conversion Clock Select bits) as 101, while ACQT2:ACQT0 (A/D Acquisition Time Select bits) as 110, since the maximum device frequency that used is 20MHz. For reduce the noise (low pass filter), a capacitor (104) is added between the analog signal and GND for every analog input from joystick. More information on ADC configuration, please refer to PIC18F2550 datasheet at http://www.microchip.com. Figure 4 Interface HID Report Descriptor with • Report Descriptor joystick The Report descriptor is unlike other descriptors in that it is not simply a table of values. The length and content of a Report descriptor vary depending on the For this PR, we are going to implements a standard number of data fields required for the device’s report USB game controller with twelve inputs (four or reports. A Report descriptor is the complete set of directional buttons and eight general purpose buttons). all items for a device. By looking at a Report descriptor Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved ROBOT . HEAD to TOE PR26 – USB Game Controller alone, an application knows how to handle incoming • Physical Descriptors data, as well as what the data could be used for. A Physical Descriptor is a data structure that provides The Report descriptor is made up of items that provide information about the specific part or parts of the information about the device. The first part of an item human body that are activating a control or controls. contains three fields: item type, item tag, and item size. For example, a physical descriptor might indicate that Together these fields identify the kind of information the right hand thumb is used to activate button 5. An the item provides. There are three item types: Main, application can use this information to assign Global, and Local. functionality to the controls of a device. There are five Main item tags currently defined: Note: Physical Descriptors are entirely optional. They • Input item tag: Refers to the data from one or add complexity and offer very little in return for most more similar controls on a device. For devices. However, some devices, particularly those example, variable data such as reading the with a large number of identical controls (for example, position of a single axis or a group of levers or buttons) will find that Physical Descriptors help array data such as one or more push buttons or different applications assign functionality to these switches. controls in a more consistent manner. • Output item tag: Refers to the data to one or more similar controls on a device such as setting the position of a single axis or a group To make a clearer picture of HID device class of levers (variable data). Or, it can represent descriptor structure, all of these things can be data to one or more LEDs (array data). combined as shown below. Understand the HID • Feature item tag: Describes device input and descriptor well will help you know more about this output not intended for consumption by the PR26. end user —for example, a software feature or Control Panel toggle. • Collection item tag: A meaningful grouping of Input, Output, and Feature items—for example, mouse, keyboard, joystick, and pointer. • End Collection item tag: A terminating item used to specify the end of a collection of items. A Report descriptor is the complete set of all items for a device. By looking at a Report descriptor alone, an application knows how to handle incoming data, as well as what the data could be used for. One or more fields of data from controls are defined by a Main item and further described by the preceding Global and Local items.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us