INTRODUCTION:
ATMEGA32 is a 8-bit AVR microcontroller with 32K Bytes In-system Programmable Flash. In Atmega32pins pin no.14 and 15 are RxD and TxD resp.
SERIAL PORT:
In computing, a serial port is a serial communication physical interface through which information transfers in or out one bit at a time. Throughout most of the history of personal computers, data transfer through serial ports connected the computer to devices such as terminals and various peripherals.
MAX232: As we know for serial port we require TIA/EIA-232-F voltage level i.e. it can accept ±30-V. MAX232 has a capacitive voltage generator to supply TIA/EIA-232-F voltage levels from a single 5-V supply. Each receiver converts TIA/EIA-232-F inputs to 5-V TTL/CMOS levels.
So, to interface the atmega32 to the computer we will be connecting atmega32 (pin no 14 & 15) to serial port via max232. We are using max232 because atmega32 works at TTL voltage level and for serial port we require other voltage level, max232 converts the TTL voltage level to the required voltage level.
Atmega32 will receive the signal from MAX232 and transmit to max232 which will be received by serial port. Do the following connections:
connect pin no 2 (Tx) of serial port to Tx out of the MAX 232 IC (pin no 14)
connect pin no 3 (Rx) of serial port to Rx in of the MAX 232 IC (pin no 13)
connect pin no 14 (RxD) of Atmega to Rx out of MAX 232 IC (pin no 12)
connect pin no 15 (TxD) of Atmega to Tx in of MAX 232 IC (pin no 11)
Do other necessary connections like ground and Vcc.
PROGRAMMING:
By selecting UART tab of the CodeWizardAVR , you can specify the UART configuration
Specify the baud rate and communication parameter.
Click on save, generate and exit.
Write the code.
Burn the program.
Open the terminal in CodeVisionAVR TOOL—-à TERMINAL (shift + F5).
Specify the baud rate and communication parameter.(ensure that you specify the same parameter which you have specify in step 2)
In terminal you monitor the whole operation.
NOTE: instead of terminal of CodeVisionAVR you can use other software like DockLight.
It allows us to specify the following communication modes:
Asynchronous
Synchronous Master, with the UCSRC register’s UCPOL bit set to 0
Synchronous Master, with the UCSRC register’s UCPOL bit set to 1
Synchronous Slave, with the UCSRC register’s UCPOL bit set to 0
Synchronous Slave, with the UCSRC register’s UCPOL bit set to 1
The serial communication is realized using the Standard Input/Output Function getchar , gets , scanf , putchar , puts and printf.
SAMPLE PROGRAM:
If we want to write program in which, when button ‘a’ on keyboard is pressed then all the LED connected to PORTA should be ON , when button ‘s’ is pressed all LED should be OFF.
#include
#include
Void main()
{
DDRA=0xFF;
PORTA=0×00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0×00;
UCSRB=0×18;
UCSRC=0×86;
UBRRH=0×00;
UBRRL=0×33;
while (1)
{
if (getchar() == ‘a’)
{
PORTA=0×11111111;
}
if (getchar() == ‘b’)
{
PORTA=0×00;
}
};
}
In this way you can interface your ATMEGA32 to your computer. In similar way you can control the motor (in semi-autonomous BOT).

3 comments:
NICE WORK PRAVEEN !!!!
lageey rahoo babu!!!
my name is rakesh.be/1031/09.i want to know how to create a website and connect it to general web..........i have a keen interest in it.please tell me about it or mail to rkspidey@gmail.com.
if possible.
waiting for response..........
Post a Comment