Showing posts with label Micro-controller. Show all posts
Showing posts with label Micro-controller. Show all posts

Friday, July 10, 2015

INTERFACING OF ATmega16 TO LCD AND SENDING DATA TO LCD VIA USART


Hi Guys Today we see how to transfer data from USART to LCD in ATmega16

Interfacing of LCD to ATmega16 and sending data to LCD from USART PORT

To design this Project we need to initialize USART and LCD

Then we must fetch data from TXD Pin send to LCD display.

To Enable USART:

In this we are using F_CPU = 8MHz; for the USART communication we should initialize proper Baud Rate.

To Enable USART:
    1.) Baud Rate should be set.
    2.) Initialize Control register for 8bit data transfer

We take Baud Rate as 9600























For F_cpu = 8Mhz and Baud Rate 9600 we should enter the value of UBRR value as shown in Table above i.e.: 51 in decimal so in we must enter 33 Hex Value.
U2X = 0 means asynchronous and U2X = 1 means synchronous.
We are using asynchronous transmission.
There are 3 control register and 1 data register for USART

Control Register:

1.) UCSRA
2.) UCSRB
3.) UCSRC

Data Register:

1.) UDR

Control Register:
        1.) UCSRB & UCSRC:

In this Register we should enable TXEN and RXEN bit by setting it 1(high).

And there is bit UCSZ2 bit with used to set whether it’s a 8 bit transmission or 9 bit transmission.

UCSZ2 combine with two other bit UCSZ1 and UCSZ0 in Register UCSRC are used to set it the Table show the setting.
We are using the Character Size as 8 bit, so UCSZ2-UCSZ0 = 011

In UCSRC Register there is bit URSEL which is used to access the UBRR Register and UCSRC Register if Set 0 means UBRR (initially its UBRR Register) and when set 1 we can use UCSRC Register. Thus to set 8bit transmission we should 1st set URSEL bit.

 


2.) UCSRA:

   U2X = 0 because we are using Asynchronous mode.(Initially it is 0)

3.) UDR:

This is a Data register for USART it convert Serial data (8 bit) into Parallel (8 bit) data and vice versa.
Is used to for transmitting and receiving the data from TXD and RXD Pin.


To Enable LCD:

1.)           We are using 4-bit LCD.

       To interface LCD in 4-bit mode we have seen in previous topic.
     For more details in coding LCD please refer Videos

In this program we receive each data from the rxd pin and send it to LCD using microcontroller.

Each time a data is send via serial port it will be displayed in LCD.



Thursday, July 9, 2015

USART COMMUNICATION USING ATmega16

Hi Guys Today we will see about AVR Atmega16 USART communication.

In this we are using F_CPU = 8MHz; for the USART communication we should initialize proper Baud Rate.

To Enable USART:
    1.) Baud Rate should be set.
    2.) Initialize Control register for 8bit data transfer

We take Baud Rate as 9600


For F_cpu = 8Mhz and Baud Rate 9600 we should enter the value of UBRR value as shown in Table above i.e.: 51 in decimal so in we must enter 33 Hex Value.
U2X = 0 means asynchronous and U2X = 1 means synchronous.
We are using asynchronous transmission.
There are 3 control register and 1 data register for USART
Control Register:
1.) UCSRA
2.) UCSRB
3.) UCSRC
Data Register:
1.) UDR

Control Register:
        1.) UCSRB & UCSRC:

In this Register we should enable TXEN and RXEN bit by setting it 1(high).
And there is bit UCSZ2 bit with used to set whether it’s a 8 bit transmission or 9 bit transmission.

UCSZ2 combine with two other bit UCSZ1 and UCSZ0 in Register UCSRC are used to set it the Table show the setting.
We are using the Character Size as 8 bit, so UCSZ2-UCSZ0 = 011

In UCSRC Register there is bit URSEL which is used to access the UBRR Register and UCSRC Register if Set 0 means UBRR (initially its UBRR Register) and when set 1 we can use UCSRC Register. Thus to set 8bit transmission we should 1st set URSEL bit.

 



2.) UCSRA:

   U2X = 0 because we are using Asynchronous mode.(Initially it is 0)

3.) UDR:

This is a Data register for USART it convert Serial data (8 bit) into Parallel (8 bit) data and vice versa.
Is used to for transmitting and receiving the data from TXD and RXD Pin.

For More details:

Refer Videos

code:

Thursday, June 26, 2014

INTERFACING OF PIC18F4550 TO LCD IN 4-BIT MODE

INTERFACING OF PIC18F4550 TO LCD IN 4-BIT MODE

LCD Description:

LCD display has 3 control pin:
       
       1.)  Register Select Pin (rs)
       2.) Read/Write Pin (rw)
       3.) Enable Pin (en)

Register Select Pin used for selecting the Register of LCD i.e.
Command Register or Data Register.
rs = 0; Command Register.
rs = 1; Data Register.

Read /Write Pin used for selecting Read from or Write to LCD i.e.
rw = 0; Write mode.
rw = 1; Read mode.

Enable Pin used for Latching Data into LCD data Register.
When Write Data to LCD en must go High to Low.
And to Read Data from LCD en must go Low to High.




LCD has 8-bit Data Pin:

We are using 4-bit Mode, so we are using only high 4-bit.
i.e. (D7-D4).



Thank You.
Plz Do Share and Subscribe the Video.
Code: Click For Code
For Video on Above Program: Click For Video

Wednesday, April 16, 2014

INTERFACING OF 4x4 KEYPAD TO MICROCONTROLLER


INTERFACING OF 4x4 KEYPAD TO MICROCONTROLLER
  • Interfacing of microcontroller to 4x4 Keypad is very simple.
  • The Simple logic behind this is just scan all the key in the matrix.
  • Let assume 4 line are output and 4 lines are input.
  • Columns are input.
  • Row are output.





C1
C2
C3
C4
R1
0
1
2
3
R2
4
5
6
7
R3
8
9
A
B
R4
C
D
E
F


          C = Columns
          R = Rows
























Case 0:

C1
C2
C3
C4
R1
0
1
1
1
R2
1
1
1
1
R3
1
1
1
1
R4
1
1
1
1
  •  When Row and Column are shorted then it is accepted as Key Pressed Now C1 & R1 = 0.
  • That means “0”. 







Case 15:

C1
C2
C3
C4
R1
0
1
1
1
R2
1
1
1
1
R3
1
1
1
1
R4
1
1
1
0
  •  When Row and Column are shorted then it is accepted as Key Pressed Now C4 & R4 = 0.
  • That means “F”.








Similarly all other Keys are checked. While pressed we must wait to 20msec i.e. Debounce effect of switch button or key. If Still key is pressed then it’s assumed as key pressed and Equivalent value is displayed.























Thank you and for any queries do comment .....

For Program download it below link:
For LCD : Click for Code
For Keyboard : Click for code
For Videos on Above Program : Click on the Link