In good old days,using a LCD display on a DIY project was quite trouble some.But now it has become much cheaper and simpler to use a LCD in a such project.Here,we are going to use industry defacto Hitachi HD44780 controller base one from ebay.fro US$ 2.89 including shipping.You can see it here.
Next part is the microcontroller base driver unit.I’m using PIC16F887 as the microcontroller here as I’m going to do some other stuffs with it in upcoming posts . PIC16F887 is really nice uC with internal oscillator upto 8Mhz.So,we don’t have to use external clock source or crystal for non-timing critical application The whole circuit will be simpler to be build and cheaper due to less components.
My choice of programming language is Mikro C Pro as it has many in-built functions.You can get the free demo version as on my previous post.
Let’s look at the schematic diagram
I’m using PicKit2 programmer I built earlier to program the uC using ICSP.The variable resistor connected to VO pin of the LCD is used to change contrast of the LCD.For testing,I’m going to powerup the whole thing using the ICSP port(from +5V via the USB port itself to the PK2 programmer).The LED used for just for monitoring
Let’s look at the MikroC code,
sbit LCD_RS at RB5_bit; sbit LCD_RS_Direction at TRISB5_bit; void main() { Lcd_Cmd(_LCD_CLEAR); |
The first few lines are used to define the pins used for the LCD library.You can find more information about that from here.Then,I have set the internal clock to 8Mhz as on the 4.2 section(page 62) of the PIC16F887 datasheet.Check there to find information on how to set different internal clock frequencies other than 8Mhz.Then,ANSEL registered are selected to disable analog input pins(ANx) as I use them as Digital IO pins on my project.The LCD is initialized and Lcd_Out(row,column,”text”) command is used to output characters to the LCD display.Isn’t that so simple (I think the above syntax is self explanatory )
Make sure to select appropriate configuration bits for the project.We have to used oscillator type as internal as below.
Now it is the time to check the built and tested circuit
No comments:
Post a Comment