0% found this document useful (0 votes)
44 views8 pages

Hammad Khan Lab11

This document is a lab report for an experiment on serial communication using a PIC18F452 microcontroller. The objectives were to get introduced to the microcontroller's serial port and interface it with a PC. The report describes the equipment used, discusses synchronous and asynchronous communication, and outlines three tasks performed - transmitting a string via serial, receiving a string until a delimiter, and receiving a single byte of data. The learning outcome was understanding how to use serial communication with the PIC18F452 microcontroller in MikroC and verifying the code in Proteus and on hardware.

Uploaded by

Inshal Ghafoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views8 pages

Hammad Khan Lab11

This document is a lab report for an experiment on serial communication using a PIC18F452 microcontroller. The objectives were to get introduced to the microcontroller's serial port and interface it with a PC. The report describes the equipment used, discusses synchronous and asynchronous communication, and outlines three tasks performed - transmitting a string via serial, receiving a string until a delimiter, and receiving a single byte of data. The learning outcome was understanding how to use serial communication with the PIC18F452 microcontroller in MikroC and verifying the code in Proteus and on hardware.

Uploaded by

Inshal Ghafoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

SERIAL COMMUNICATION (ADC) IN PIC18F452

With PIC18F452

Hammad Khan (191216)


_________________________

BACHELOR OF ELECTRICAL ENGINEERING


Fall-19

Submitted To:
Engr. Mariam Sabir
Lab Engineer
____________

Department of Electrical Engineering


FACULTY OF ENGINEERING
AIR UNIVERSITY,ISLAMABAD
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 11

Lab Title: Serial Communication

Student Name: Hammad Khan Reg. No: 191216

Objective: Getting introduced to serial port of microcontroller.Serially interfacing microcontroller


with PC

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: 22-12-2021 Signature:


Lab#11
SERIAL COMMUNICATION
Objective:
 Getting introduced to serial port of microcontroller
 Serially interfacing microcontroller with PC

Equipment:
Hardware:

 SSD(Common Anode)
 Keypad(4x3)
 LCD display(16x2)
 PIC18F452
Software:
1. MikroC for PIC
2. Smart-pro 5000u

Discussion:

Synchronous communication:
When using the synchronous communication – the information is transmitted from the
transmitter to the receiver:

 In sequence
 Bit after Bit
 With fixed baud rate
 And the clock frequency is transmitted along with the bits
That means that the transmitter and the receiver are synchronized between them by the same
clock frequency. Asynchronous communication: When using the asynchronous communication -
the transmitter and the receiver refraining to transmit long sequences of bits because there is not
a full synchronization between the transmitter and receiver. In this case, the information
Frames of information must not necessarily be transmitted at equal time space, since they are
independent of the clock. To communicate with external components such as computers or
microcontrollers, the PIC microcontroller uses a component called USART (Universal
Synchronous Asynchronous Receiver Transmitter0). This component can be configured as:

A Full-Duplex asynchronous system that can communicate with peripheral devices,such


as CRT terminals and personal computers

A Half-Duplex synchronous system that can communicate with peripheral devices,such


as A/D or D/A integrated circuits, serial EEPROMs, etc.

The serial port of computer sends/receives data serially at logic levels between -12 to and
+12V whereas, microcontroller works at logic levels between 0 to 5V (TTL). A MAX232 is
Used for this purpose. It provides 2-channel RS232C port and requires external 10uF
capacitors. The driver requires a single supply of +5V. While using software mikroC a
library of “UART” is included to use USART

LAB TASKS
Task#01
Write a code to transmit a string “Serial Communication” serially. Perform it in Proteus
using virtual Terminal and on Hardware via RS232 and Max232 using HyperTerminal.
Program Code
void main()
{
char abc;
UART1_Init(9600); //Initialize UART module at 9600 bps
Delay_ms(100);
while(1)
{
Delay_ms(1000);
UART1_Write_Text(" Serial Communication ");

}
Proteus Circuit

Output
Task#02
Write a code to Receive a string serially until “.” is found and then transmit back to display
it on Hyper Terminal screen. Perform it in Proteus using virtual Terminal and on
Hardware via RS232 and Max232 using Hyper Terminal.

Program Code
void main() {
char var[255];
UART1_Init(9600);
Delay_ms(100);
while(1){
while(UART1_Data_Ready() == 0);
UART1_Read_text(var,".",9600);
UART1_write_text(var);
}
}

Proteus Circuit
Output

Task#03
Write a code to Receive a data (byte) serially and then transmit back to display it on Hyper
Terminal screen. Perform it in Proteus using virtual Terminal.
Code
void main() {
char data1;
UART1_Init(9600); //Initialize UART module at 9600 BPS
Delay_ms(100); //Wait for UART module to stabilize
while(1){
while(UART1_Data_Ready() == 0); //If data is ready then
data1= UART1_Read(); //Receive the data(byte) and store it in data1
UART1_write(data1); //Transmit the received data(byte) data1
}
}
Proteus Circuit

Output

Learning Outcomes:
In this lab, we learnt about serial communication using PIC 18F452 in MikroC. Serial
communication is Synchronous communication which means the information is transmitted from
the transmitter to the receiver.
We used virtual terminal as a hyper terminal in proteus simulation to verify our code and to
simulate in on proteus. We performed several tasks such as to send data to virtual terminal as a
string. After that we performed a task in which we can keep sending data to terminal until a
certain character (in our case “.”) is pressed in which we were able to understand how serial
communication works.

You might also like