Sunday, 22 February 2015

Making a Digital Clock Using Timer,16x2 LCD and 8051/89c51

Digital Clock Using Timer with 8051/89c51

Here I am writing program of Digital Clock using timer for 8051/89c51 microcontroller. To understand complete code of Digital Clock using timer you must have to look at the connection diagram first which is shown in image below :-


In this connection diagram i have only connect the 16x2 LCD with 8051/89c51 microcontroller to display time. Here you can see that LCD is connected in 4-bit mode.

Now I’ll explain you the digital clock program. The main file of Digital Clock program is shown in image which is given below:-  


As you can see in the main program firstly I have initialize the Timer 1 through which I have generated 50 msec interrupt. So for more explanation about Timer 1 interrupt generation you can see my earlier post “Timer 1interrupt in 8051”.Then after I have initialized the LCD and send the command 0x80 to display text from 1st position of first line on LCD. After that I have write the text “Format : HH:MM:SS” on LCD .For more explanation to display text on LCD you can see my earlier post “LCD interfacing with 8051 using 4 datalines”.

Now after entering in while loop I have display time in Hour, Minute and Second format. This Time’s Hours, minutes and seconds is managed in Timer 1 interrupt. Which you can see in interrupt function which is shown in image below:-


Here in this interrupt function firstly I have increment msec counter. when this msec counter gets equal to 20 then I have increment sec counter because it is a 50 msec interrupt and 50x20 =1000 msec (1 sec) also I have make msec counter 0. So when sec counter gets equal to 60 then I have increment min counter and when min counter gets equal to 60  than I have increment hour Counter. In this manner we can manage seconds, minutes and hours. This Time will start from 0 when Microcontroller gets start.

Here in this program one more thing which you have to see that I have used a function name “variable_lcd_diaplay” through which I have display variable on LCD is shown in image below:- 

          
In this function firstly I have break a variable and the 1s digit and 10s digit is taken in different –different variable which are a and b. Then after both variable is converted into ASCII by adding 48. After that these ASCII values has been displayed on LCD by using “LCD_write_data” function.

After completion of program the LCD display will looks like as per the image given below:-



Download Link

To download complete code of Digital Clock Using Timer you can click here. If you are unable to download the complete code than you can leave your email id in comment section and i’ll send you the complete code.





Thursday, 12 February 2015

8051 Development Board Schematic

8051 Development Board Schematic


Here we have following sections:-

1) POWER SUPPLY :- this a 5V power supply circuit to provide a filtered power to MCU and other peripherals. input of this supply is available through adaptor of 8-16 AC or Dc.

2) SPI-ADC :- this a advanced MCP300Spi communicated Analogue to digital converter for two channels to sense analog inputs voltages via SPI.

3) DC MOTOR INTERFACE :- Dc motor interface circuit for communicating a dc motor application.

4) UART/USB :- this a combo circuit which can be used as uart and used as Usb communication since USB communication feature is not available in 8051 a special IC CP2103 is used to convert the uart signal to USB.

5) LCD INTERFACING :- Here we have designed a LCD interfacing circuit which can be used to display parameters. this circuit is configurable for all 16x1 ,16x2,16x4 Lcd's.

6) LED 's :- This section is used to play with general purpose Led for indications.

7) GPIO's :- This section is used to play with general purpose input outputs for indications and interrupts handlings.

8) RESET :- here we have a reset section which is used to reset the embedded software.

8051 Development Board Schematic

Please share your feedbacks if you have any doubts regarding any of the hardware and software part for the above.

we are happy to help you :)


Tuesday, 10 February 2015

How to scrolling Text on 16x2 LCD.

Moving Text On 16x2 LCD USING 8051/AT 89C51

Here in this post I’ll explain you that how we can scroll text message on 16x2 LCD. If you are new to embedded programming then I’ll suggest you that first read my older post which is “How to interface 16x2 LCD”  so that you can understand this post completely.

Before explaining you about the program I’ll show you the connection diagram first so that you can have a clear picture of about circuit that I have used in my program. Now here in below image you can see the connection diagram of 16x2 LCD to 8051 Microcontroller.

   
I feel that from above picture the connection between 8051 microcontroller and 16x2 LCD is clear.
Now I will explain you that how can we move the text on 16x2 LCD. You can see the main program file of my program in image given below:- 


Here in the program which is shown in above image firstly I have initialized the 16x2 LCD and then I write my name and my Profession on first line of LCD which is “VAIBHAV SINGHAL (Firmware Developer )” after that I have write my blog URL on Second Line of LCD which is “www.embeddedsolutions4u.blogspot.com”.

After displaying data on LCD the only thing that I did to keep this text moving is sending the command of 0x1c for shifting display right and put 500 millisecond delay. So from LCD right shift command and 500 millisecond delay the text will start moving on 16x2 LCD after every 500 millisecond.
       
Note :-
·         Also read my older post “How to interface 16x2 LCD” to understand this post completely.

Download Link :-
·         To download complete code of “Moving text on 16x2 LCD” click here. If you are unable to download the complete code please drop your email-id in comment section so that I can send the complete code to you.