keypad.c and lcd.c that are required to implement a simple
VEX UI. These are conveniently provided as a download
from the SERVO website at www.servomagazine.com.
To test the keypad and LCD interface, you only need to
download the keypad.hex application. To customize it, you
will need to modify the code in the main function of the
WPIkeypad.c routine and re-make the project using MPLAB.
The functions used in this application include the following:
• The Get_Key function scans the keypad and returns
the keystroke that was pressed from the user after
• The lcd_goto function positions the LCD cursor to the
• The lcd_puts function sends the text contained in the
buffer to the LCD.
• The lcd_printdec displays numeric data to the LCD.
• The Two WheelDrive function called from the WPILIB
initializes the microcontroller to run the VEX motors
in two wheel drive mode (2WD).
• The SetPWM function called from the WPILIB is used
to set motor #1 speed to the value entered from the
To run the application, download the WPIKeypad.hex
file to the microcontroller using the IFI bootloader and start
entering a speed for the motor with up to three digits for a
speed value between 000 and 255. Notice that the first
digit entered is the most significant digit (unlike calculators
which enter the least significant digit first). This can easily
be modified in the WPIKeypad.c application by storing the
digits into a small buffer. The motor will start turning at the
selected speed once an extra digit between 0 and 9 is
entered from the keypad; the cycle repeats, overwriting the
current motor command.
I will be referring to more WPILIB functions in future
articles and showing you some advanced coding examples
that would be much more difficult if done without WPILIB
since controlling motors requires waveform generation
(PWM) and reading sensors may require interrupt support.
Figure 4 also shows where I added my own routines to
scan the keypad. This MPLAB project contains all the
necessary modules to compile and link the keypad
application that generates the keypad.hex file that is used
to program the controller once the keypad has been wired
to it. As a side note, I do prefer using the DDT tools instead
of WPILIB when interrupts are required (such as scanning
pushbutton switches or bumper switches since it allows
access to most of the PIC18F8520 registers, timers, and
Going further, an interesting experiment is to use the
keypad to enter floating point or hex numbers, and display
Introducing Pololu’s new line of
Maestro USB Servo Controllers
Conduct a symphony of servos.
Three control methods: USB, TTL serial, and internal scripting
Free configuration and control application with motion sequencer
Channels can be used for digital I/O or up to 12 analog inputs
Individual servo speed and acceleration control for each channel
Up to 8 KB of internal scripting memory (~3000 servo positions)
0.25 us servo pulse resolution with pulse rate up to 333 Hz
Pololu's 6-channel Micro Maestro and new 12-, 18-, and
24-channel Mini Maestros take serial servo controllers to
the next level by incorporating native USB control for
easy connection to a PC and programmability via a
simple scripting language for self-contained, host
controller-free applications. Whether you want the best
servo controller available or a versatile, general-purpose
I/O control board, these compact devices will deliver.
more information at www.pololu.com/maestro
54 SERVO 08.2010