numbers, hex numbers and binary numbers can also be
printed on the LCD display, but floating point numbers are
currently not supported. The reason you can’t print floats
using this technique is because the printf routine included
with the free PIC18 C Student Compiler does not support
floating point format.
The LCD driver code was developed using Microchip
MPLAB and the PIC18 C compiler, and also uses IFI libraries.
The code configures the VEX controller’s digital ports to
outputs and initializes the Hitachi LCD controller. Once
compiled, the lcd.hex file is generated that is used to
program the VEX controller. (I have provided the lcd.hex file
so that it can be used without having to compile it.) You’ll
need the orange programming cable to download the
firmware to the controller just like last time.
To include LCD support for your own applications, just
add “#include lcd.h” to your C programs and lcd.c to your
MPLAB project files.
Once you have downloaded the lcd.hex application
using the IFI bootloader, the message “Hello World!!!”
should appear. If it doesn’t work the first time, check the
wiring and the power supply using a digital voltmeter;
check for short circuits. Also make sure that the contrast is
set correctly using the 10K trim pot.
This version of the LCD firmware includes a special LCD
version of printf that can be used to display integer and hex
values using the example shown in Listing 2. It uses the
printf function to convert the integer value from binary to a
formatted character string and then sends it directly to the
LCD. The pause(n) function is used to delay in milliseconds
between each printf call to give the user a chance to read
the LCD display before it is overwritten by the next printf.
Displaying Floating Point Values
As previously mentioned, displaying 32-bit IEEE567
floating point values on the LCD is currently not supported
in the C firmware that I provided, but is a feature that I
would like to add in the future for my own VEX
applications. It would require software to reformat the
floating point numbers to ASCII text strings so that they can
be printed on the LCD. In fact, I provided a routine in my
previous article to display “fixed point” numbers on the
numeric LED display that could easily be modified to display
fixed point numbers and to also handle IEEE567 floating
point numbers with exponents on higher resolution LCD
displays.
Programming the VEX Controller
The next step is to download the lcd.hex application
that is provided with this article into the controller and run
it. Start by copying the led.hex file to your computer’s hard
disk and place it in a folder. This is done by running the IFI
bootloader and browsing to the directory that you created
FIGURE 5. This accelerometer display was generated using
a Microchip dsPIC30F6014 development board graphics LCD
display which uses the SPI interface. Notice that it does not
have any problems with floating point when displaying the
xyz tilt angles since the Microchip C30 compiler provides the
necessary floating point libraries.
for the lcd.hex file. Turn the power switch on and
download the led.hex file.
Once the lcd.hex file has been downloaded, the LCD
should show “Hello World!!!” on the first line of the 2 x 16
character display.
Using Other LCD Displays Work with VEX?
Another character display that I connected to the VEX
controller is shown in Figure 4. It is a surplus two line by
24 character display that I purchased online for around $10.
The two lines and 24 character line length allow you to
display even more information, including floating point
values and extended text messages.
Graphics LCD Display Applications
Applications for new graphics displays are limitless and
can be integrated into appliances, medical devices,
automotive devices, and other embedded devices. The new
QVGA interface provides access to high resolution graphics
OLED displays and color LCD displays. Except for the serial
RS-232 interface, these interfaces are more involved
requiring more capable microcontrollers with built-in I2C and
SPI peripherals.
The accelerometer display shown in Figure 5 was
generated using a dsPIC30F6014 development board LCD
display which uses the SPI interface. Notice that it does not
have any problems with floating point when displaying the
xyz tilt angles since the Microchip C30 compiler provides
the necessary floating point libraries.
Going Further
Using the information in this article, you can easily
SERVO 06.2010 65