USB Host Board – Joystick Software

 

The USB Joystick Software allows you to connect a USB Joystick to the USB Host Board and read the analog stick inputs and button presses using I2C or serial TTL

This is a free software download for our USB Host Board and USB Host IC’s (SOICDIPSSOP).

Please note: This software is free to download but only works on one of our USB boards or chips which must be bought separately.
To order, simply select which of our boards or IC products you wish to have the software loaded onto. See the USB Host Board and IC product pages for details onĀ pricingĀ and installing this software.

The USB Joystick software for our USB Host board allows you to easily read the analog stick inputs and all the switch inputs from a USB Joystick. This can give you much more functionality than a traditional Radio Control system and it is much easier to access the control inputs directly  in a microcontroller.

Use it to control

  • A Robotic Arm and grabber (robot claw)
  • Wheeled or tracked vehicles
  • Your own Arcade game
  • ….

All the analog stick and button presses are available using either standard serial TTL or via I2C communication. I2C makes for an easier interface to implement directly from a microcontroller but serial TTL is a good choice if you want to use the joystick as a remote control device sending signals wirelessly.

Axis and Buttons

Not all joysticks are the same. Some joysticks have only basic X and Y axis and a few buttons, whilst some have many more axis of movement and many more buttons. The software will identify all the major axis and buttons/switches used. The axis and buttons possible are

AxisButtons
X AxisButton 1
Y AxisButton 2
Z AxisButton 3
RX AxisButton 4
RY AxisButton 5
RZ AxisButton 6
SliderButton 7
DialButton 8
WheelButton 9
HATButton 10
 Button 11
 Button 12
 Button 13

The best way to see which axis and buttons are available, is to monitor the serial output. Move the joystick around and click each button and note which value changes.

The serial output corresponds to the axis and buttons above with the axis displayed in order first, followed by the buttons. The last two entries are the joystick manufacturer VID and PID.The output is comma delimited and the format looks like the following

$JOY,90,90,180,90,90,90,90,90,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,07B5,0316

Configuration Settings

Configuration can be done by sending commands via the serial port. Either by microcontroller or via a terminal program and a suitable serial TTL connection. Commands take effect immediately and are stored in Eeprom on the board.

The following Commands are available.

BAUD <value>Set Serial Port Baud Rate (default 9600)
[2400|4800|9600|14400|19200|38400|57600|115200]
SCALE <value>Set Scale for analog joystick inputs
[10-255]
HEX <value>Set Serial Hex Output ON/OFF
[ON|OFF]
I2C <value>Set I2C Address
[10-127]

BAUD Rate

The USB Host board will communicate over serial TTL at the following baud rates

  • 2400
  • 4800
  • 9600 (default)
  • 14400
  • 19200
  • 28800
  • 57600
  • 115200

The default baud rate is 9600

SCALE

SCALE sets the maximum value for the joystick axis. The default is 255.

With the joystick in the center position the output will be half this value.

This feature allows you to alter the output to match your controlling program. This is useful for instance if you are directly controlling servo’s from an Arduino board as the SCALE setting can be set to 180 to give an output of 0 – 180 with 90 being the center position. This directly creates the values needed for the Arduino Servo commands.

HEX

The HEX option converts the SERIAL output into single Hexadecimal bytes and adds a CRC checkdigit. It reduces the amount of data transmitted and makes it easier to process at the receiving device.It is very useful for transmission of the data via XBee to a remote device.

I2C Address

The I2C default address is 41. This can be changed to any value between 1 and 127 using the I2C command

Help

Help can be displayed at any time by typing ? or HELP

The current settings for SCALE and I2C address are displayed.

?

USB Host Joystick v1.06

  BAUD <value>            - Set Serial Port Baud Rate
                            [2400|4800|9600|14400|19200|38400|57600|115200]
  SCALE <value>           - Set XYZ Scale value
   (255)                    [10 - 255]
  HEX <value>             - Set Serial Data Output Hexadecimal On/Off
   (ON)                   - [ON|OFF]
  I2C <value>             - Set I2C Address
   (41 )                    [1 - 127]
  HELP or ?               - display help

Connections required for Joystick Software

  • 5V power in
  • 0V
  • RX/TX (for setting baud, scale factor and changing I2C address only)
  • For sending output to a microcontroller, either (or both)
    • TX
    • I2C


Reading the Joystick Data

Serial Connection (TX)

Everytime the joystick is moved, or a button is pressed or released a text string is sent via the serial port in the following format

$JOY,90,90,180,90,90,90,90,90,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,07B5,0316\r\n

The output corresponds to the axis and buttons listed above with the axis displayed in order first, followed by the buttons. The last two entries are the joystick manufacturer VID and PID. The output is comma delimited.

This serial transmission is useful for testing and for transmission via wireless connection

HEX Serial Data Output

This is similar to the Serial data output, but each value is output as a single hexadecimal value and there are no comma delimiters. Additionally there is an extra CRC8 checkdigit added to the data to enable the data to be checked for errors. The HEX output is useful for transmission via XBee radio to remote devices.

The data is transmitted in the format shown below.
A total of 18 characters is transmitted

ByteData
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
‘J’
‘O’
‘Y’
X Axis
Y Axis
Z Axis
RX Axis
RY Axis
RZ Axis
Slider
Dial
Wheel
HAT
Buttons 1-8
Buttons 9-13
CRC
\r
\n

I2C

You can request all of the data items or individual items or groups of items.

Data is stored in registers numbered from 0 through 26

RegisterData
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
X Axis
Y Axis
Z Axis
RX Axis
RY Axis
RZ Axis
Slider
Dial
Wheel
HAT
Button 1
Button 2
Button 3
Button 4
Button 5
Button 6
Button 7
Button 8
Button 9
Button 10
Button 11
Button 12
Button 13
Vendor ID High Byte
Vendor ID Low Byte
Product ID High Byte
Product ID Low Byte

As per normal I2C practice, issue a write command and send the starting register address, then issue a read for the data that you require.

Shopping Basket
Scroll to Top