FIGURE 3. I recently found
the electronic equivalent that
makes it a snap to build a
circuit like this. The secret is to
use the jumper cables shown
here which are sold at SparkFun
in combination with standard
.100 pin headers.
to those used for the LCD as shown in Figure 2.
A VEX User Interface
Data entry can be either in decimal, floating point, or
hexadecimal format since the keypad has 16 keys. In fact,
we can edit the values by assigning the unused keys from
the keypad as a backspace, insert or delete key, cursor
position, or tab key. Our PIC18 C User Interface (UI)
application uses the keypad scan routine to scan for the
user’s keystrokes and uses the digits entered to build an
ASCII representation of the motor speed entered. We’ll
slightly alter the firmware from the June ‘ 10 article to work
with the keypad.
This application also uses the WPILIB routines to drive
the VEX motor to the selected speed which prevented me
from using a modified version of printf to display data since
the WPILIB could not be modified. Instead, I had to resort
to making specific function calls to position the cursor and
format the data for the LCD.
Although the example provided is very rudimentary,
the reader can build on this to develop custom user
interfaces using our source code as a starting point.
Some Assembly Required
In order to connect the keypad and LCD to the
microcontroller, just follow the wiring diagram shown in the
schematic in Figure 2. The motor is connected to motor
block, pin 1, located on the microcontroller. Please note
that two of the LCD signals (RS and E pins) have been
relocated from IO7 and IO6 to IO10 and IO11 on the
microcontroller (this is different from the schematic in the
May issue). I had to change the LCD wiring to accommodate
the keypad firmware. The 10K potentiometer controls the
contrast to the LCD and should be adjusted for ambient
lighting conditions.
TABLE 1. Bill of materials required to build the
User Interface using a keypad and LCD. One component
not shown in the schematic is a VEX motor.
I used one to demonstrate how to change the
motor speed using this interface.
ITEM
QT Y
DESCRIPTION
1
1
VEX Controller
2
1
4 x 4 Keypad
3
1
16 x 2 LCD Display
4
40
5
1
6
1
7
1
8
1
.100 Pin Headers
10K ohm Trim
Potentiometer
Wire-wrap Cable
Package of
Jumper Cables
VEX Motor
SOURCE
Innovation First, Inc.
www.vexforum.com
RadioShack
www.radioshack.com
SparkFun
www.sparkfun.com
Digi-Key
www.Digi-Key.com
Digi-Key
www.Digi-Key.com
RadioShack
www.radioshack.com
SparkFun
www.sparkfun.com
Innovation First, Inc.
www.vexforum.com
SERVO 08.2010 51