USB Host Board - USB Joystick Software

HobbyTronics USB Host Board - USB Joystick Software
Cliquer pour agrandir
Modèle : USBHOST-JOYSTICK
Fabricant : HobbyTronics
Évaluation : Aucune évaluation

HobbyTronics

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 (SOIC, DIP, SSOP).
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.

Download Software
Click Here to Download (Version 1.07)
USB Host BoardUSB Host Mini
USB Host Boards
USB Host IC SOIC  USB Host IC DIP  USB Host IC SSOP
USB Host IC's

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

Axis Buttons
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

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 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 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

Byte Data

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

Register Data

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.

An example Arduino sketch is shown below and should be easily modifyable for other languages.

Software Updates

To upload the Software to the USB Host Board you will need to use the ds30Loader program. See the USB Host Board product page for more information on this.

See the Joystick Software in action

The following video shows a joystick connected to the Magician Robot Chassis and a Robot Claw

Example Arduino code

Arduino Example code using Hex Serial
Arduino Example code using I2C

Version History

   1.07   30 Mar 2016   Added support for 14 bit Joysticks
   1.06   09 Sep 2015   Added HEX output option
   1.05   07 Sep 2015   Added JOYSTICK config setting
   1.04   18 Aug 2015   Fixed code for 10-bit data Joysticks
   1.03   24 Oct 2012   Bug fix on eeprom write (V2 board only)
   1.01   29 Jun 2012   Added VendorID and ProductID
   1.00   24 May 2012   Initial Release

 

Écrire un avis
Votre nom :


Votre avis : N.B. : Le HTML n'est pas pris en charge !

Évaluation : Mauvais            Bon

Saisir le code ci-dessous :

Il n'y a aucune image supplémentaire pour ce produit.
USB Host Board - USB Joystick Software
$ 00€ New In Stock
Panier
Aucun article
 
Frais de Livraison

France & EU - poste aerienne de 3.53€ +VAT
Plus d'informations...

 
Marques
 
 Check out our videos