4x40 LCD Project
This is my PIC microcontroller 4x40 character LCD project. So far I can write to the LCD, but I can't get much success in using the keypad via the 74C922 encoder. I do have some of the "buggy" problems with the same setup on a project using the Basic Stamp. I think the problem is the output of the 74C922 is probably being subject to noise, or I'm using too small values for the capacitors so the that the debounce is being unreliable. Also, the 74C922 puts its output in tri-state when the data enable is high leaving the inputs of the uC in a floating state. When I rewired the same ciruit (the keypad on my BASIC Stamp project) it seemed to work just fine not next to any power cables. So I'm changing my design so that the 74C922 is using a CMOS 4049 as a buffer and I'm going to change the values of the 74C922 keybounce and oscillator capacitors to values times ten. And I think I need to tie the inputs of the uC to ground via 10K resistors. I haven't tried it out since I moved out of the Texas Heat Studio, but as soon as I have my work area back in order I should hopefully have some good results.
Chuck Hellebuych's second volume on programming PIC micros in C does really well in explaining how to control a 2x16 LCD. Although this example code is available in the HI-TECH C compiler (as well as many other places), I found reading the Hitachi datasheet helps a whole lot since some of the LCD commands aren't even mentioned. The 4x40 character LCD is really just two 2x40 LCDs hooked together using the same data bus but having differnet EN (enable) pins. All I did was modify the lcd_write() and lcd_init() function to write to the top 2 lines and bottom 2 lines of the LCD, and also rewrote the lcd_goto() function so I could specify lines 1-4. The schematics and code (minus the code for the keypad) can be downloaded here. The pause, LCD, and main functions are all in the one text file:
I'm also planning on using this for a DIY speedomater/tachometer for my car using a hall sensor. As soon as I have a chance I'm going to also write some code to display custom characters. The only PIC I have currently is the PIC18F4550, which I really haven't played with yet. If anybody out there reading this already has the C code for custom characters (PIC Microchip or AVR), feel free to let me in on it.