1300 Henley Court
Pullman, WA 99163
509.334.6306
www.digilentinc.com
PmodJSTK2 Reference Manual
Revised July 19, 2016
This manual applies to the PmodJSTK2 rev. C
DOC#: 502-330
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 1 of 9
Overview
The Digilent PmodJSTK2 (Revision C) is a versatile user input device that can be easily incorporated into a wide
variety of projects. With a two-axis joystick on a center button, a trigger button, and a programmable
RGB LED capable of 24-bit color.
1 Functional Descriptions
The PmodJSTK2 utilizes two potentiometers oriented orthogonally to one another and are manipulated by moving
the joystick in the X and Y directions. As the joystick moves, the voltage output at the sweep pin of each
potentiometer changes and is measured by the 10-bit ADC present on the embedded PIC16F1618 microcontroller.
The raw measured data is stored at a rate of 100 Hz as a 16-bit right-justified variable in RAM with the upper 6 bits
masked with zeros.
Additionally, each successive measurement also produces two 8-bit values representative of the joysticks physical
location with respect to each axis. Note that if inversion of either of the 8-bit position axis are set, the values will
not change until the data has been re-collected by the PIC16 at the 100 Hz rate.
The PmodJSTK2.
Features include:
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 2 of 9
2 Specifications
Note¹: Data in the Typical Column uses VCC at 3.3V unless otherwise noted
Note²: Normal operation with the RGB LED Off and no buttons pressed
Note³: Normal operation with the RGB LED set to white and both buttons pressed
3 Interfacing with the Pmod
The PmodJSTK2 communicates with the host board via the SPI protocol. With the PmodJSTK2, there are two types
of data packet protocols: the standard data packet of 5 bytes and an extended data packet with 6 or 7 bytes in
total. With the standard 5 byte protocol, users may use the old code from the PmodJSTK without any syntax errors.
The 5 byte packet structure is provided in the image below:
As noted in the standard data packet structure, users may either send a zero and a series of 4 dummy bytes to
receive the standard 5 bytes of data or they may send a single command byte with up to 4 parameters in the four
following bytes to set the internal values such as the joystick calibration or on-board RGB LED.
The extended data protocol allows for additional data to be obtained from the device during a communication
session after the standard 5 bytes of information such as normalized 8-bit positional data for each axis. Users may
also obtain the current calibration values and the status of the module through this method.
Parameter
Min
Typical1
Max
Units
Recommended Operating Voltage
3.1
3.3
3.5
V
Maximum Supply Voltage
-
-
5.5
V
Power Supply Current2
-
4.85
-
mA
Power Supply Current3
-
17.6
-
mA
Parameter
Value
Units
Maximum Joystick Angle
25
Degrees
Communication Protocol
SPI
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 3 of 9
3.1 SPI Timing Requirements
The embedded PIC16F1618 requires certain SPI timing requirements in order for successful communication to
occur. When the Chip Select line is brought low, users must wait at least 15 μS before sending the first byte of
data. An interbyte delay of at least 10 μS is required when transferring multiple bytes. When the Chip Select line is
brought high after the last byte has been transferred, at least 25 μS is required before users may bring the Chip
Select line low again to initiate another communication session.
3.2 Calibrating the Module
The PmodJSTK2 has a set of factory loaded calibration values that are used to calculate the 8-bit position values for
each axis. Users may enter calibration mode to recalculate all of those values by rotating the joystick around so the
embedded PIC16 can record all of the maximum and minimum samples for the two axes. The on-board blue LED
will be flashing to indicate that the calibration sequence is taking place. When the embedded microcontroller
detects that the joystick has not changed for an entire second, allowing the microcontroller to presume that the
most recent set of measurements correspond to the joystick's center position, the blue LED will stop flashing and
the green LED will flash twice to indicate that the calibration procedure was successful. However, if 10 seconds
pass without the PIC16 detecting the center position, the blue LED will stop flashing and the red LED will flash
twice indicating that the calibration procedure was not successful.
Once the Chip Select pin goes high after the calibration command has been processed, the PmodJSTK2 will not
accept any new commands during the calibration procedure. Users may still poll the status register to determine
the current status of the device during this time.
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 4 of 9
3.3 Using the High-endurance Flash
The PmodJSTK2 has a set of factory loaded calibration values that are used to calculate the 8-bit position values for
each axis. Users may enter calibration mode to recalculate all of those values by rotating the joystick around so the
embedded PIC16 can record all of the maximum and minimum samples for the two axes. The on-board blue LED
will be flashing to indicate that the calibration sequence is taking place. When the embedded microcontroller
detects that the joystick has not changed for an entire second, allowing the microcontroller to presume that the
most recent set of measurements correspond to the joystick's center position, the blue LED will stop flashing and
the green LED will flash twice to indicate that the calibration procedure was successful. However, if 10 seconds
pass without the PIC16 detecting the center position, the blue LED will stop flashing and the red LED will flash
twice indicating that the calibration procedure was not successful.
Once the Chip Select pin goes high after the calibration command has been processed, the PmodJSTK2 will not
accept any new commands during the calibration procedure. Users may still poll the status register to determine
the current status of the device during this time.
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 5 of 9
3.4 Command Summary
3.4.1 Get Commands
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 6 of 9
3.4.2 Set Commands
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 7 of 9
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 8 of 9
3.4.3 Other Commands
PmodJSTK2™ Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 9 of 9
4 Pinout Description Table
A pinout table of the PmodJSTK2 is provided below.
Although users are welcome to create their own interface code for the PmodJSTK2 if they so desire, pre-
constructed libraries that provide functions for initializing the module, reading in values, and adjusting calibration
values exist. They are available on the PmodJSTK2 example code page.
Any external power applied to the PmodJSTK2 must be within 2.95V and 5.5V; however, it is recommended that
Pmod is operated at 3.3V.
5 Physical Dimensions
The pins on the pin header are spaced 100 mil apart. The PCB is 1.875 inches long on the sides parallel to the pins
on the pin header, 0.9375-inch-long on the sides perpendicular to the pin header, and 1.75 inches tall. With the 3-
D printed housing the module is 1.875 inches long on the sides parallel to the pins on the pin header, 1.125 inches
long on the sides perpendicular to the pin header, and 1.75 inches tall.
Pin
Signal
Description
1
CS
Chip Select
2
MOSI
Master-Out-Slave-In
3
MISO
Master-In-Slave-Out
4
SCK
Serial Clock
5
GND
Power Supply Ground
6
VCC
Power Supply (3.3V/5V)