Академический Документы
Профессиональный Документы
Культура Документы
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
with 12 inputs (4 directional buttons and 8 general FEATURES
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.
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
make it ideal for embedded control and monitoring This project will require following hardware:
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
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.
• HID Descriptor
The HID descriptor identifies the length and type of
subordinate descriptors for a device.
Figure 3
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.
Figure 7
Figure 8
ICSP for programming PIC Please refer to Appendix A for the PCB layout of PR26.
microcontroller The PCB layout is provided free and therefore Cytron
Technologies will not be responsible for any further
modification or improvement.
Figure 12
MCLR, RB6 and RB7 need to be connected to the
USB In Circuit Programmer (UIC00A) to program the
PIC microcontroller. The programmer (UIC00A) is not
included in DIY project set since it can be used several
time for different project set. User can also choose
other type of PIC programmer to load the program.
2 3
1
10 4
5 6
8 9
Figure 13
Component:
Push button NO
4. The next step is to install MPLAB IDE and
pressed? Microchip C18 Compiler into a computer.
The MPLAB IDE and C18 Compiler can be
downloaded from www.cytron.com.my Please
YES
refer document to install MPLAB software
Save updated and C18 compiler software.
value
5. After the installation complete, open the
project file provided using MPLAB IDE.
Send all updated Please refer Installation of C18 compiler
value to computer and open project_18F document to open
project.
6. When you create project for the game 12. Diagram below shown the example of file
controller, create the subfolder and include the after all necessary file added.
c.file, h.file, and linker into the project.
Figure 14
Figure 16
13. Build the project and load the hex file into the
PIC microcontroller using the USB In Circuit
Programmer (UIC00A). When users build the
project, MPLAB IDE will generate hex file.
The hex file generated from MPLAB IDE will
be named according to project name, not C
file name. Cytron Technologies also provide
hex file for user. Do not forget to switch ON
Figure 15 the power. The programmer is not included in
the hardware set but it can be found at Cytron
9. To add file in subfolder Files and Source website. (User manual is provided at website).
Files, right click on the folder Files, then click
on Add Files…, 14. Make sure when you load the hex file into
PIC microcontroller, USB cable is connected
10. User may repeat the similar steps to create to USB type-B connector and computer. It is
subfolder in the header file. First, right click because power supply is gets from computer
on the Header Files, then click on Create through USB cable.
Subfolder…,
15. Test the functionality of the PCB board.
11. Another file need to add is rm18f2550-HID
Bootload.lkr, which is under Linker Script. 16. Have fun!
TEST METHOD
WARRANTY
No warranty will be provided as this is DIY project.
Thus, user is advice to check the polarity of each
Figure 18 electronic component before soldering it to board.
Appendix A
Appendix B
PCB Layout:
+
-
-
+
-
+
wire
wire
wire
wire
* Cytron Technologies reserved the right to replace the component in the list with component of the same functionality
without prior notice.
Prepared by
Cytron Technologies Sdn. Bhd.
19, Jalan Kebudayaan 1A,
Taman Universiti,
81300 Skudai,
Johor, Malaysia.
URL: www.cytron.com.my
Email: support@cytron.com.my
sales@cytron.com.my