KEMBAR78
Full Lab Manuals Updated On 11 July 2024 | PDF | Microcontroller | Classes Of Computers
0% found this document useful (0 votes)
84 views61 pages

Full Lab Manuals Updated On 11 July 2024

This document is a lab manual for introductory courses on microcontrollers, specifically focusing on the PIC16F84A architecture. It includes various lab exercises that guide students through programming and interfacing with the microcontroller, using software tools like CCS C and PROTEUS. The manual aims to provide practical knowledge and skills for working with microcontrollers in embedded programming and hardware applications.

Uploaded by

arunan1315
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)
84 views61 pages

Full Lab Manuals Updated On 11 July 2024

This document is a lab manual for introductory courses on microcontrollers, specifically focusing on the PIC16F84A architecture. It includes various lab exercises that guide students through programming and interfacing with the microcontroller, using software tools like CCS C and PROTEUS. The manual aims to provide practical knowledge and skills for working with microcontrollers in embedded programming and hardware applications.

Uploaded by

arunan1315
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/ 61

Lab Manuals

Contents

LAB1 : Introduction to Software Tools ...................................................................................................................................... 3


LAB2 : Introduction to PIC16F84A............................................................................................................................................. 8
LAB3 : To Make an LED Blink continuously .............................................................................................................................12
LAB4 : To Make at least 2 LED Blink continuously & Simultaneously .....................................................................................15
LAB5 : To Make at least 2 LED Blink alternatively ...................................................................................................................17
LAB6 : To Make 1 LED Blink only 5 times ................................................................................................................................18
LAB7 : LED is on respectively based on the input via 2 different push button .......................................................................24
LAB8 : Blinking LED only 3 times after a button is pressed. ....................................................................................................27
LAB9 : ON a LED after a Toggle switch pressed ......................................................................................................................30
LAB10 : To make many LEDs blink simultaneously .................................................................................................................33
LAB11 : To make many LEDs blink like Disco ..........................................................................................................................36
LAB12 : To toggle the 2 LEDs ...................................................................................................................................................39
LAB13 : Using 2 or more MCU.................................................................................................................................................42
LAB14 : Delay Loops Applications Flasher & Counter .............................................................................................................44
7 Segment LED DISPLAY ......................................................................................................................................................47
LAB15 : Display text on LCD ....................................................................................................................................................53
LAB16 : LCD Display with Inputs .............................................................................................................................................55
LCD DISPLAY ........................................................................................................................................................................50
LCD Screen ..........................................................................................................................................................................52
LAB17 : Buzzer.........................................................................................................................................................................58
Main References: ....................................................................................................................................................................61

MICROCONTROLLER - 1
Lab Manuals

Preface:

This manual has been developed for the introductory courses on microcontrollers taught by myself at the
Akademi Laut Malaysia (ALAM).It introduces students to the field of microcontrollers – what they are, how they
work, how they interface with their I/O components, and what considerations the programmer has to observe
in hardware-based and embedded programming. This text is intended to teach one particular controller
architecture which is PIC16F84A,

We concentrate, however, on small 8-bit controllers and their most basic features, since they already offer
enough variety to achieve our goals.

Since one of our courses is a lab and uses the PIC16F84A, we tend to use this microcontroller
in our examples.

Please help me further improve this text by notifying me any errors. If you have any suggestions or
wishes like better and/or more thorough explanations, proposals for additional topics, feel free to email me at
Ramesh_amathalai@yahoo.com

Modify : 2/1/2019 V 3.0

MICROCONTROLLER - 2
Lab Manuals

LAB1 : Introduction to Software Tools


CCS C, and PROTEUS

Objectives : 1. To be familiar with some software tools: CCS C ,& PROTEUS


2. To know how to make a project using MPLAB and then get the hex file of the software
program of the project.
3. How to simulate the hex file using PROTEUS.

Introduction These programs are the backbone of the microprocessor and microcontroller based
systems; since using CCS C we can build the software of the project using C or Assembly
language, and then we can simulate the project virtually using PROTEUS, finally we can
download the program on the microcontroller and see the results practically using PIC Kit 2.
So this experiment includes all the knowledge the student will need to get started to these
programs.

MICROCONTROLLER - 3
Lab Manuals

1. C Compiler Program
CCS C?
Benefits of a C Compiler

CCS provides a complete integrated tool suite for developing and debugging embedded applications running on Microchip PIC®

MCUs and dsPIC® DSCs. The heart of this development tools suite is the CCS intelligent code optimizing Microchip PIC® C

compiler which frees developers to concentrate on design functionality instead of having to become an MCU architecture

expert.

• Maximize code reuse by easily porting from one MCU to another. Devices Supported
• Minimize lines of new code with CCS provided peripheral drivers, built-in functions and standard C
operators
• Built-in functions are specific to PIC® MCU registers, allowing access to hardware features directly from C

Key C Aware IDE Components:

• Project manager
• C-Aware text editor
• Compilation control to completely or partially build projects
• Utilities for file comparison, numeric conversion, disassembly, parametric device selection and more
• C-Source code level in-circuit debugger
• Output file viewers for list files, symbol maps, call trees, etc.
• Documentation creation tools

MICROCONTROLLER - 4
Lab Manuals

The CCS Microchip PIC® C Compiler has complementary development tools that work seamlessly with the compiler. Program,

debug, and data stream from one environment that may be used for development and production.

A. PROTEUS Program

What is PROTEUS?

Proteus contains everything you need to develop, test and virtually prototype your embedded system designs
based around the Microchip Technologies™ PIC16 series of microcontrollers. The unique nature of schematic
based microcontroller simulation with Proteus facilitates rapid, flexible and parallel development of both the
system hardware and the system firmware. This design synergy allows engineers to evolve their projects more
quickly, empowering them with the flexibility to make hardware or firmware changes at will and reducing the
time to market.
Proteus VSM models will fundamentally work with the exact same HEX file as you would program the physical
device with, binary files (i.e. Intel or Motorola Hex files) produced by any assembler or compiler.

How to setup PROTEUS?

1. Start-up the Microsoft Windows.


2. Double click on the software tools folder and
then choose Proteus Simulator after that
double click Proteus 7. folder and run the
setup.
3. Press next until you reach the window which
ask for the key.
4. From browse for key; browse until you reach
the same folder where the setup exists, and
then open the folder and chose the Sonsivri.
5. Then click on the top icon which is Sonsivri
and then press install.
6. Then choose yes and then close the window,
after that browse and install the program.

Get started to PROTEUS

1. From start menu chose the PROTEUS, and then chose ISIS(blue).
2. To get a part click on Devices ( P ).
3. Write the name of the PIC16F84A.
4. To get LED write led then chose green led.
5. To get a resistor write 1k and chose the first part.

MICROCONTROLLER - 5
Lab Manuals

B. Get started to CCS C

1. Open the program by double clicking on its icon on the desktop.


2. File → New → Source File
3. Give a file name , (Save the file in a folder )
4. On Target : Choose PIC 16F84A.

C.. PICkit 2 Development Programmer

The PICkit 2 — introduced in May 2005[3] — replaced the PICkit 1. The most
notable difference between the two is that the PICkit 2 has a separate
programmer/debugger unit which plugs into the board carrying the chip to be
programmed, whereas the PICkit 1 was a single unit. This makes it possible to
use the programmer with a custom circuit board via an In Circuit Serial
Programming (ICSP) header. This feature is not intended[3] for so-called
"production" programming, however.

The PICkit 2 uses an internal PIC18F2550 with FullSpeed USB. The latest
PICkit 2 firmware allows the user to program and debug
most of the 8 and 16 bit PICmicro and dsPIC members
of the Microchip product line.

The PICkit 2 is open to the public, including its


hardware schematic, firmware source code (in C
language) and application programs (in C# language).
End users and third parties can easily modify both the
hardware and software for enhanced features. e.g.
GNU/Linux version of PICKit 2 application software,
DOS style CMD support, etc.

The PICkit 2 has a programmer-to-go (PTG) feature,


which can download the hex file and programming
instructions into on-board memory (128K byte I2C
EEPROM or 256K byte I2C EEPROM), so that no PC is
required at the end application.

The Microchip version of PICkit 2 has a standard 128K byte memory. 256K byte memory can be achieved by
modifying the hardware or from third party.

Additionally, a 500 kHz three-channel logic analyser and a UART tool are built into the PICKit 2. These features
are missing from the PICkit 3.

MICROCONTROLLER - 6
Lab Manuals

Since release of V2.61, PICkit 2 PC software now support maximum 4M bytes of memory for programmer-to-go
feature. This modification makes the PICKit 2 support 8x more memory than the PICKit 3. This enhancement
has been contributed by Au Group Electronics and the PICkit 2 firmware is also reported to be submitted to
Microchip PICkit 2 team in the middle of March 2009. Hopefully this enhancement will be integrated into future
firmware releases too.

MICROCONTROLLER - 7
Lab Manuals

LAB2 : Introduction to PIC16F84A

Objectives : To get familiar with programming and using PIC16F84 microcontroller.

Tools : PIC16F84 Microcontroller, IC programmer, MPLAB software.

Theory A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor


emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose
microprocessor (the kind used in a PC).

A microcontroller is a single integrated circuit, commonly with the following


features:
• central processing unit - ranging from small and simple 4-bit processors to sophisticated
32- or 64-bit processors
• input/output interfaces such as serial ports (UARTs)
• Other serial communications interfaces like I²C, Serial Peripheral Interface and Controller
Area Network for system interconnect
• Peripherals such as timers and watchdog
• RAM for data storage
• ROM, EPROM, EEPROM or Flash memory for program storage
• clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit
• many include analog-to-digital converters

MICROCONTROLLER - 8
Lab Manuals

PIC16F84 microcontroller PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Its
general structure is shown on the following map representing basic blocks. PIC16F84 has a total of 18 pins. It is
most frequently found in a DIP18 type of case but can also be found in SMD case which is smaller from a DIP.
DIP is an abbreviation for Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that
holes for pins to go through when mounting aren't necessary in soldering this type of a component.

Pins on PIC16F84 microcontroller have the following meaning:

• Pin no.1 RA2 Second pin on port A. Has no additional function


• Pin no.2 RA3 Third pin on port A. Has no additional function.
• Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin
• Pin no.4 MCLR Reset input and Vpp programming voltage of a microcontroller
• Pin no.5 Vss Ground of power supply.
• Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function.
• Pin no.7 RB1 First pin on port B. No additional function.
• Pin no.8 RB2 Second pin on port B. No additional function.
• Pin no.9 RB3 Third pin on port B. No additional function.
• Pin no.10 RB4 Fourth pin on port B. No additional function.
• Pin no.11 RB5 Fifth pin on port B. No additional function.
• Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode.
• Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode.
• Pin no.14 Vdd Positive power supply pole.
• Pin no.15 OSC2 Pin assigned for connecting with an oscillator
• Pin no.16 OSC1 Pin assigned for connecting with an oscillator
• Pin no.17 RA2 Second pin on port A. No additional function
• Pin no.18 RA1 First pin on port A. No additional function.

MICROCONTROLLER - 9
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High to RA0 port A

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F84A. You can use any crystal from
0 to 20MHz with PIC16F84A.

MCLR master reset pin is pulled high to keep PIC16F84A out of reset. RA0 pin is being light up permanently in the
code.

MICROCONTROLLER - 10
Lab Manuals

Code :

With proper
definitions

** Now try to light ON the LED using different pin.

MICROCONTROLLER - 11
Lab Manuals

LAB3 : To Make an LED Blink continuously

Objectives : 1. To know how to include some looping structure in C using the MCU PIC16F84A.
2. To know how to simulate these functions using PROTEUS program.
3. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer

Theory : This provides the code to make an LED blink using PIC16F84A microcontroller. This code is
written in C language using CSC C Compiler. This code is intended to be the first step in
learning how to use PIC16F84A microcontroller in your projects.

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High to RA0 port and Low to RA0 in Port A continuously.

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 12
Lab Manuals

In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F84A. You can use any crystal from
0 to 20MHz with PIC16F84A.

MCLR master reset pin is pulled high to keep PIC16F84A out of reset. RA0 pin is being light up permanently in the
code.

Notes and References :

Whenever you are writing code for PIC microcontrollers, then you have to include " #include <16F84A.h>" file in the
code. After including " #include <16F84A.h>" file, configuration bits are being set in the code shown above. To
understand the details of how these configuration bits are being programmed please clarify with your instructor.

After the configuration bits, LED pin is being defined as the RA0 pin. You can replace RA0 with any other pin name if
you want (e-g RB0 etc). After LED pin definition, CPU frequency is being defined. You have to define “ #use
delay(clock=4000000) “ macro, if you want to use built in delay functions like delay_us() and delay_ms().

Here CPU frequency is defined to be 20MHz, which is the crystal oscillator frequency attached with PIC16F84A in
the circuit.

In the main function, firstly RA0 pin direction is set to be an output pin using PortA = 0; statement. we can set the
direction of any pin i-e if it is an input or output. Then LED pin is made low using output_low(Pin_A0) and
output_high(Pin_A0) statement.

LED pin is being toggled in the while loop after every half second. In this way you can easily make LED blink using
PIC16F84A microcontroller.

MICROCONTROLLER - 13
Lab Manuals

Codes : With proper declarations (defining )

MICROCONTROLLER - 14
Lab Manuals

LAB4 : To Make at least 2 LED Blink continuously & Simultaneously

Objectives : 1. To know how to include some looping structure in C using the MCU PIC16F84A.
2. To know how to simulate these functions using PROTEUS program.
3. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer

Theory : This provides the code to make an LED blink using PIC16F84A microcontroller. This code is
written in C language using CSC C Compiler. This code is intended to show on how to
connect at least 2 LEDs and blink continuously & Simultaneously

MICROCONTROLLER - 15
Lab Manuals

MICROCONTROLLER - 16
Lab Manuals

LAB5 : To Make at least 2 LED Blink alternatively

Objectives : 1. To know how to include some looping structure in C using the MCU PIC16F84A.
2. To know how to simulate these functions using PROTEUS program.
3. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer

Theory : This provides the code to make an LED blink using PIC16F84A microcontroller alternatively.

MICROCONTROLLER - 17
Lab Manuals

LAB6 : To Make 1 LED Blink only 5 times

Objectives : 1. To know how to include some looping structure in C using the MCU PIC16F84A.
2. To know how to simulate these functions using PROTEUS program.
3. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer

Theory : This provides the code to make an LED blink using PIC16F84A microcontroller for only 5
times.

MICROCONTROLLER - 18
Lab Manuals

MICROCONTROLLER - 19
Lab Manuals

Lab 7 : LED is ON based on the input

Objectives : 1. Use PIC16F84A pins as inputs.


2. understand how to make PIC16F84A pins as inputs and how to read their value in the
code.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, Switch, LED,
Resistor, capacitors, Crystal

Theory : This provides the code to make an LED on using PIC16F84A microcontroller after a Switch is
pressed. This code is written in C language using CSC C Compiler. This code is to show how
input and output pins are used in PIC16F84A microcontroller.

MICROCONTROLLER - 20
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High to RB0 if the RA0 is On (Switch is pressed )

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F84A. You can use any crystal from
0 to 20MHz with PIC16F84A.

MCLR master reset pin is pulled high to keep PIC16F84A out of reset. RA0 pin is being light up permanently in the
code.

MICROCONTROLLER - 21
Lab Manuals

Notes and References :

PIC16F84A is running on external crystal of 20MHz. RA0 pin is being used as the input pin. When the push button is
in the pushed state then, RA0 pin is high, otherwise RA0 pin is low. Whenever RA0 pin is high, then RB0 pin
(Attached with the LED) is also made high just to indicate correct reading of RA0 pin status in the micro-controller.

In the main function, firstly RA0 pin is made an input and RB0 is made an output. Using Set_Tris_X, we can set the
direction of any pin i-e if it is an input or output. So, Set_Tris_A = 1; makes RA0 pin an input pin. And Set_Tris_B = 0;
makes RB0 pin an output pin. Also, using the statement output_low(pin_b0); RB0 pin is made low.

In the while(1) loop, status of RA0 pin is constantly being checked, if it becomes high then RB0 is also made high. If
RA0 is low, then RB0 is also made low as well.

MICROCONTROLLER - 22
Lab Manuals

Codes :

MICROCONTROLLER - 23
Lab Manuals

LAB7 : LED is on respectively based on the input via 2 different push


button

Objectives : 1. Use PIC16F84A pins as inputs & outputs.


2. understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, Switch, LED,
Resistor, capacitors, Crystal

Theory : This provides the code to make an LED blink 3 times on using PIC16F84A microcontroller
after a Switch is pressed. This code is written in C language using CSC C Compiler. This code
is to show how input and output pins are used in PIC16F84A microcontroller. Using control
loop.

MICROCONTROLLER - 24
Lab Manuals

MICROCONTROLLER - 25
Lab Manuals

MICROCONTROLLER - 26
Lab Manuals

LAB8 : Blinking LED only 3 times after a button is pressed.

Objectives : 1. Use PIC16F84A pins as inputs & outputs.


2. understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, Switch, LED,
Resistor, capacitors, Crystal

Theory : This provides the code to make an LED blink 3 times on using PIC16F84A microcontroller
after a Switch is pressed. This code is written in C language using CSC C Compiler. This code
is to show how input and output pins are used in PIC16F84A microcontroller. Using control
loop.

MICROCONTROLLER - 27
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High to RB0 3 times if the RA0 is On (Switch is pressed )

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F84A. You can use any crystal from
0 to 20MHz with PIC16F84A.

MCLR master reset pin is pulled high to keep PIC16F84A out of reset. RA0 pin is being light up permanently in the
code.

MICROCONTROLLER - 28
Lab Manuals

Codes :

MICROCONTROLLER - 29
Lab Manuals

LAB9 : ON a LED after a Toggle switch pressed

Objectives : 1. Use PIC16F84A pins as inputs & outputs.


2. Understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, Switch, LED,
Resistor, capacitors, Crystal

Theory : This provides the code to make an LED ON after a switched is pressed using PIC16F84A
microcontroller. This code is written in C language using CSC C Compiler. This code is to
show how input and output pins are used in PIC16F84A microcontroller.

Procedure

Part 1 1. Connect the circuit shown in the figure

MICROCONTROLLER - 30
Lab Manuals

Ramesh Babu

2. Write C program that send High to either

• RB0 if RA0 is ON, (Switch is pressed )


• RB1 if RA1 is ON , (Switch is pressed )
• RB2 if RA2 is ON, (Switch is pressed )

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 31
Lab Manuals

Codes :

MICROCONTROLLER - 32
Lab Manuals

LAB10 : To make many LEDs blink simultaneously

Objectives : 1. Use PIC16F84A pins as outputs.


2. understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 8 LEDs, Resistor,
capacitors, Crystal

Theory : This provides the code to make many LEDs blink simultaneously using PIC16F84A
microcontroller. This code is written in C language using CSC C Compiler. This code is to
show how output pins are used in PIC16F84A microcontroller.

MICROCONTROLLER - 33
Lab Manuals

Procedure

Part 1 Connect the circuit shown in the figure

Ramesh Babu

Write C program that send High all the pins in Port B

Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 34
Lab Manuals

Codes :

MICROCONTROLLER - 35
Lab Manuals

LAB11 : To make many LEDs blink like Disco

Objectives : 1. Use PIC16F84A pins as outputs.


2. Understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 8 LEDs, Resistor,
capacitors, Crystal

Theory : This provides the code to make many LEDs blink simultaneously alternate toggling using
PIC16F84A microcontroller. This code is written in C language using CSC C Compiler. This
code is to show how output pins are used in PIC16F84A microcontroller.

MICROCONTROLLER - 36
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High all the pins in Port B, alternating toggling the pins in a
row.

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 37
Lab Manuals

Codes :

Lab 9

MICROCONTROLLER - 38
Lab Manuals

LAB12 : To toggle the 2 LEDs

Objectives : 1. Use PIC16F84A pins as inputs and outputs.


2. Understand how to make PIC16F84A pins as inputs and how to read their value in the
Code and output accordingly.
3. To know how to simulate these functions using PROTEUS program.
4. To know how to program the microcontroller PIC16F84A and then simulate
these Logic Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 2 LEDs, Resistor,
capacitors, Crystal

Theory : This provides the code to make 2 LEDs to toggled , lighting up ether one at a time using
PIC16F84A microcontroller. This code is written in C language using CSC C Compiler. This
code is to show how output pins are used in PIC16F84A microcontroller.

MICROCONTROLLER - 39
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send High to either RB4 or RB5 pins in Port B, alternating toggling
between these two pins in a row.

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

Codes :

MICROCONTROLLER - 40
Lab Manuals

MICROCONTROLLER - 41
Lab Manuals

LAB13 : Using 2 or more MCU

Objectives : 1. To know how to make integrate 2 or more MCU in a single circuit.


2. To realize how PIC16F84A microcontroller is connected to each other for communication
3. withing the circuit.
4. To get familiar with interfacing PIC16F84A with another PIC16F84A MCU.
5. To know how to program the microcontroller PIC16F84A and then simulate these Logic
Functions using hardware..

Tools : 2 sets of : PIC16F84 Microcontroller, Resistor, capacitors, Crystal , 1 push button , Proteus,
CSC C software PicKit 2 programmer

Theory : Integrating 2 or more MCU together in a single circuit.

Procedure
MICROCONTROLLER - 42
Lab Manuals

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. MCU 1 : Write a C program that send a signal high to RB0 & RB1if the input A0 = 1.
3. MCU 2 : Write a C program that send a signal high to RB0 if the input A0 = 1.

4. Load the program to the microcontroller

MICROCONTROLLER - 43
Lab Manuals

LAB14 : Delay Loops Applications Flasher & Counter

Objectives : 1. To know how to make a delay loop with a certain value.


2. To realize how PIC16F84A microcontroller deals with timing issues.
3. To get familiar with interfacing 7-Seg display to PIC16F84A and make a counter.
4. To get familiar with interfacing LED display to PIC16F84A and make a flasher.
5. To know how to program the microcontroller PIC16F84A and then simulate these Logic
Functions using hardware..

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 1 - 7 Segment LED,
Resistor, capacitors, Crystal

Theory : Generate a Delay with a certain value using the Delay Loops Technique; after that we will
use this delay to make some applications like Flasher and Counter.

MICROCONTROLLER - 44
Lab Manuals

Procedure

Part 1 5. Connect the circuit shown in the figure

Ramesh Babu

6. Write C program that send a counter to 7 Segment LED, incrementing by 1 every 1


seconds..

7. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 45
Lab Manuals

Codes :

MICROCONTROLLER - 46
Lab Manuals

7 Segment LED DISPLAY

Basically, an LED display is nothing more than several LEDs molded in the same plastic
case. There are many types of displays and some of them are composed of several dozens
built-in diodes which can display different symbols. Nevertheless, the most commonly used
display is a 7-segment display. It is composed of 8 LEDs. Seven segments of a digit are
arranged as a rectangle to display symbols, whereas the additional segment is used to
display a decimal point. In order to simplify connection, anodes or cathodes of all diodes
are connected to one single pin so that there are common anode displays and common
cathode displays, respectively. Segments are marked with letters from a to g, plus dp, as
shown in figure below. When connecting an LED display, each diode is treated separately,
which means that each one must have its own current limiting resistor.

Here are a few things that you should pay attention to when buying LED displays:

• As mentioned above, depending on whether anodes or cathodes are connected to the common pin, there
are common anode displays and common cathode displays. There is no difference between them at all in
their appearance so you are advised to double check which one is to be used prior to installing it.
• Maximum current that each microcontroller pin can receive or give is limited. Therefore, if several
displays are connected to the microcontroller then so called Low current LEDs limited to only 2mA
should be used.
• Display segments are usually marked with letters from a to g, but there is no fast rule indicating display
pins they are connected to. For this reason, it is very important to check connection prior to start writing a
program or designing a device.

LED displays connected to the microcontroller usually occupy a large number of valuable I/O pins, which can be
troublesome especially when it is necessary to display multi digit numbers. It is even more complicated if, for
example, it is necessary to display two 6-digit numbers. A simple calculation shows that 96 output pins are
needed in this case. The solution to this issue is called multiplexing.

Here is how an optical illusion based on the same operating principle as a film camera is made. Only one digit is
active at a time, but they change their on/off conditions so quickly creting the impression that all digits of a
number are simultaneously active.

MICROCONTROLLER - 47
Lab Manuals

Let’s take a look at the figure above. First a byte


representing units is loaded to the microcontroller
port PORT2 and transistor T1 is activated at the
same time. After a while, the transistor T1 is turned
off, a byte representing tens is loaded to PORT2 and
the transistor T2 is activated. This procedure is
repeated cyclically at high speed for all digits and
corresponding transistors.

A disappointing fact which indicates that the


microcontroller is just a kind of miniature computer
designed to understand only the language of zeros
and ones is fully expressed when displaying digits. Namely, the microcontroller does not know what units, tens
or hundreds are, nor what ten digits we are used to look like. For this reason, each number to be displayed must
undergo the following procedure:

First of all, a multi digit number must be split


into units, tens etc. in a specialized subroutine.
Then each of these digits must be stored in a
specific byte. Digits get recognizable
appearance for humans by performing a simple
procedure called ‘masking’. In other words, a
binary number is replaced with a different
combination of bits. For example, digit 8 (0000
1000) is replaced with the binary number 0111
1111 in order to activate all LEDs displaying
this digit. The only diode remaining inactive
here is reserved for the decimal point.

If the microcontroller port is connected to a display so as that bit 0 activates segment ‘a’, bit 1 activates segment
‘b’, bit 2 segment ‘c’ etc., then table below shows appropriate binary mask for each digit.

MICROCONTROLLER - 48
Lab Manuals

In addition to digits (0-9), there are some letters of alphabet - A, C, E, J, F, U, H, L, b, c, d, o, r, t- that can also
be displayed by masking.

In case that common anode displays are used, all ones contained in the table above should be replaced with zeros
and vice versa. Additionally, PNP transistors should be used as drivers.

MICROCONTROLLER - 49
Lab Manuals

LM016L LCD DISPLAY

An LCD display is specifically manufactured for the use with microcontrollers, which means that it cannot be
activated by standard IC circuits. It is used to display different messages on a miniature liquid crystal display.
The LCD display described here is for its low price and great capabilities most frequently used in practice.

An LCD screen is an electronic display module that uses liquid crystal to produce a visible image. The 16×2
LCD display is a very basic module commonly used in DIYs and circuits. The 16×2 translates a display of 16
characters per line in 2 such lines. In this LCD, each character is displayed in a 5×7 pixel matrix.

MICROCONTROLLER - 50
Lab Manuals

MICROCONTROLLER - 51
Lab Manuals

LCD Screen

If there are no characters displayed or if they are dimmed when the display is switched on, the first thing that should be
done is to check the potentiometer for contrast adjustment. Is it properly adjusted? The same applies if the operating
mode of display has been changed (write in one or two lines).

MICROCONTROLLER - 52
Lab Manuals

LAB15 : Display text on LCD

Objectives : 1. To know how to make display characters to LCD display.


2. To know what is the Liquid Crystal Display (LCD), and how to interface it to
the Microcontroller.

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 1 LCD Display,
Resistor, capacitors, Crystal

Theory : To display characters on the display unit.

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that send some text to the LCD Display.

3. Load the program to the microcontroller

MICROCONTROLLER - 53
Lab Manuals

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2 programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

Codes :

MICROCONTROLLER - 54
Lab Manuals

LAB16 : LCD Display with Inputs

Objectives : 1. To know how to make display characters to LCD display.


2. To know what is the Liquid Crystal Display (LCD), and how to interface it to
the Microcontroller.

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 1 LCD Display,
Resistor, capacitors, Crystal

Theory : To display characters on the display unit.

Procedure

Part 1 4. Connect the circuit shown in the figure

Ramesh Babu

5. Write C program that send some text to the LCD Display.

6. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2 programmer.

MICROCONTROLLER - 55
Lab Manuals

• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

Codes :

MICROCONTROLLER - 56
Lab Manuals

MICROCONTROLLER - 57
Lab Manuals

LAB17 : Buzzer

Objectives : 1. To know how to make a simple buzzer.


2. To know what is the buzzer , and how to interface it to the Microcontroller.

Tools : PIC16F84 Microcontroller, Proteus, CSC C software PicKit 2 programmer, 1 buzzer, switch,
Resistor, capacitors, Crystal

Theory : To produce a noise using buzzer and a switch.

MICROCONTROLLER - 58
Lab Manuals

Procedure

Part 1 1. Connect the circuit shown in the figure

Ramesh Babu

2. Write C program that makes a buzzer sound .

3. Load the program to the microcontroller

Part 2 • Connect the circuit shown in the figure in hardwired


• Program a PIC 16F84A using the PICKit 2 programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its operation.
• Demonstrate the circuits operation to the instructor.

MICROCONTROLLER - 59
Lab Manuals

Codes :

MICROCONTROLLER - 60
Lab Manuals

Main References:

 Microchip Technology (Manufacturer):

http://microchip.com

 The PIC Tutorial:

http://o.mneina.googlepages.com/what_is_microcontroller.htm

 Embedded Systems/PIC Microcontroller

http://en.wikibooks.org/wiki/Embedded_Systems/PIC_Microcontroller

 Wikipedia Entry: PIC Microcontroller

http://en.wikipedia.org/wiki/PIC_microcontroller

MICROCONTROLLER - 61

You might also like