USB2LCD+

For the Tivo I was building I had to build a driver for a standard HD44780 character LCD screen (up to 4x20 characters). I started from the excellent work by ch424 and all of the contributors to his thread at bit-tech. He was even kind enough to give me the source code for his microchip.

Well, I had never really made a circuit before, and I had definately never programmed a microchip before, so I wanted to have a go at re-doing his work to better suit my needs and wants. So I completely re-designed his circuit and re-coded the entire project. I definately used his code and circuit as a starting point, but I reworked every part of it to be my own. Additionally I recieved help from the RPI Electronics Club.


Capabilities

* May work with KS0073. Will not work with T6963C or KS0066FF00.


Change Log


Future Work


Microchip

The circuit uses a PIC18F2550 DIP28. With little or no changes to the code PIC18F2455/4455/4550 may also be used. The program is written in C18. It uses seperate bootloader and firmware programs. The bootloader loads first and in particular situations enters "update mode" allowing a new firmware to be easily installed onto the chip. The firmware does most of the work.

Download bootloader: hex (5.17 KB, updated 11/21/09) or source (77.71 KB, updated 11/21/09)

Download firmware: hex (39.59 KB, updated 11/21/09) or source (122.71 KB, updated 11/21/09)

Note: The bootloader is optional. The firmware can be applied directly with a PIC programmer. If you do not have the bootloader, any firmware updates will need to be applied with a PIC programmer as well.


Programming the Microchip

To install the bootloader onto the PIC you will need to buy, make, or borrow a PIC programmer. A tutorial is available from ObdDiag.net. You need to make sure to set the programmer configuration as in this image. Especially important is the USB voltage regulator setting. I may have actually compiled these into the bootloader hex file above, but I am not sure.

When plugging in the USB device you will need to install the MCHPUSB driver from Microchip to recongnize the device in bootloader mode. Then use the LCD-Setter program to install the firmware. To update the firmware in the future all you have to do is use the LCD-Setter program.

Download MCHPUSB Bootloader Driver (67.27 KB, updated 11/16/09)


Pinout

[PIC18F2550 Pinout]

Where MCLR is the clear pin, BL- is the backlight ground, IN# are inputs, OUT# are output pins, RB ports are the 8 pins to the LCD, OSC1/2 are the clock pins connected to a 4 MHz crystal, VDD is +5V from USB, VSS is ground, D+/D- are USB data pins, and VUSB is the voltage regulator.


The Circuit

The circuit was designed using Cadsoft Eagle Free. Here is the board I designed:

[USB2LCD+ Board] View larger image (16.79 KB, updated 11/16/09) Download Eagle schematic (309.55 KB, updated 11/16/09) Download Eagle schematic (24.66 KB, updated 11/16/09)

Components

Note 1: You may replace C1, C2, and X1 (the crystal clock) with a ceramic resonator.

Note 2: Any bipolar NPN transistor (BC547(B), BC548(A/B), (2S)C1815, ...) will likely work, just make sure to check the order of the pins. Also the resistor connected to the base pin will probably need to be adjusted.

Connectors

The difference between the two types of OUT are that 1-3 draw current directly from the USB port (suitable for fans) and 4-5 draw current through the chip (suitable for LEDs). You can make any of them how you want (high or low current draw). If you use the transistor setup it will allow more current draw. Also note that the GND and VCC are kinda backwards between the two types.

Note: Some displays require a resistor for the backlight pins. Check your datasheet.


Connecting to the Computer

Once the firmware is installed a different driver is needed. For Windows XP/Vista/Windows 7 (32 or 64 bit) you can use the driver below. You will get an unsigned driver warning, but can safely ignore it. It is actually using a serial emulation driver built into Windows. You will get a new USB2LCD+ Communications Port which you can use as a normal serial port.

Note: For Vista 64 you need to install the certificate included. In XP / Vista 32 / Windows 7 this removes all unsigned driver warnings. To install the certificate, do the following BEFORE installing the driver:

USB2LCD+ Driver (3.96 KB, updated 11/16/09)

Linux supports this device natively*, and it shows up as /dev/ttyACM# (where # is some number, mine is 0). Sadly you will still need Windows to install the firmware the first time with the LCD-Setter program.

* Some distributions of Linux are missing the USB cdc-acm driver module and require additional setup.

Using LCD-Setter

I made a program that utilizes almost every feature of the USB2LCD+ interface. It is required to install or update the firmware on the chip. It is very useful for testing the circuit and code. Additionally it is the easiest way to set the startup message for the chip. It also comes with a utility library that has all the code for finding devices and updating the firmware. You need at least .NET Framework 2.0 to use the program. The program source code is written in C++/CLI and the utility DLL is in C++. It allows you to define what characters your display actually uses so that you can see what the output will look like.

Download LCD Setter Application (43.54 KB, updated 02/23/10) Download LCD Setter Source Code (112.51 KB, updated 02/23/10)

Using LCD Smartie

Use the Matrix display driver, set the COM port appropiately, and you should be all good to go!

Or you can use a custom driver I made for LCD Smartie. The custom driver has slightly better performance, a little more power, and you don't need to know the COM port. It is able to find which COM port it is on it's own (which is really nice if you plug the LCD into different USB ports and the COM port changes). To install just download the DLL file and put it in the "displays" folder of LCD Smartie, then restart LCD Smartie and select the USB2LCD driver in the setup.

Download USB2LCD+ LCD Smartie Driver (11 KB, updated 02/23/10) Download Visual C++ Project for Display Driver (22.76 KB, updated 02/23/10)

Using Custom Commands

There is a very long list of commands that are supported by this program. The commands are used by sending special characters over the serial connection and can be used from a custom made program, from a terminal (cmd.exe, bash, etc), from a program like Hyperterminal or SecureCRT, or from within LCD Smartie with $Chr(). Anything that does not start with a 254 character will be printed to the screen. Here is the brief list:

All 45+ Commands (48.95 KB, updated 11/21/09)

Terminal examples: Windows: echo Hello World! > \\.\COM8 Linux: printf "\xFE\x47\x1\x1Hello World!" > /dev/ttyACM0


Troubleshooting

A number of problems can occur while building the USB2LCD+. As I get emails with questions, I will post the most common problems and solutions here.

The most common is the following error in Windows:

USB Device Not Recognized: One of the USB devices attached to this computer has...

If this happens before you install the firmware it is most likely that the bootloader was not installed properly or part of the circuit is not setup correctly. The components that can cause this are C4, X1/C1/C2, C3/C5, C6, or R1. Other components are not required before the firmware is installed.

If you get this error after installing the firmware it is most likely that the LCD is not properly connected in the circuit. The firmware freezes if it cannot communicate with the LCD. When the firmware freezes, the USB connection freezes, which causes Windows to complain.