27-06-2014, 02:08 PM
PIC Lab Manual
PIC Lab.pdf (Size: 1.44 MB / Downloads: 418)
Introduction
These programs are the backbone of the microprocessor and microcontroller based
systems; since using MPLAB 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 ICPROG.
So this experiment includes all the knowledge the student will need to get started to these
programs
MPLAB Program
What is MPLAB?
MPLAB is a software program that runs on your PC to provide a development
environment for your embedded system design.
In other words it is a Windows program package that makes writing and developing
a program easier. It could best be described as developing environment for a
standard program language that is intended for programming microcontrollers
Get started to MPLAB
1. Open the program by double clicking on its icon on the desktop.
2. From the project menu choose project wizard.
3. Choose PIC 16F84A.
4. Brows and name the project.
5. From view menu choose project; to view the project.
6. Then add a file to the source files by right clicking on source files, and
choose add files and then name the file anyName.asm.
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. Place the ECOM 4315 CD into CD ROM drive.
3. Double click on the software tools folder and then choose Proteus Simulator after
that double click Proteus 7.1 folder and run the setup.
4. Press next until you reach the window which ask for the key.
5. From browse for key; browse until you reach the same folder where the setup
exists, and then open the second folder and chose the MAXIM_LICENCE folder.
6. Then click on the top icon which is MAXIM and then press install.
7. Then choose yes and then close the window, after that browse and install the
program.
8. After that run the patch which exist in the same folder where the
MAXIM_LICENCE exists.
9. Then browse for c:\Program files\Labcenter electronics \Proteus.
10. Finally chose next, and then finish.
QL-2006 programmer
QL-2006 programmer is the high-speed programmer designed specially for
development and production programming of PIC single chip
microcomputer (SCM) by Shenzhen Qianlongsheng Electronic Technology
Co., Ltd. The product is featured with small volume, low power
consumption, high reliability as well as easy and convenient operation.
QL-2006 is applicable for almost all PIC10/12/16/18 series SCMs except
16C5X. It also supports memories in 24XX series and 93XX series
Hardware Installation
There is no special requirement for installation of this programmer. Connect
programmer to PC through serial port cable or USB cable and power up,
then the programmer works. (This programmer supports direct USB power
supply. If USB cable is connected, you may not connect external power.
However, if current through USB interface is very low – less than 200MA
and insufficient to drive programmer, connection to external power is
required to enable the programmer to work regularly.)
Introduction to PIC16F84A
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
Procedure
Part 1: Addition Function
Write an assembly program to achieve the addition of two numbers entered to
port B and display the result on port A.
• Simulate the program using the circuit shown in figure via Proteus software.
Verify it operates properly when simulated
Subtraction Function
Write an assembly program to achieve the subtraction of two numbers
entered to port B and display the result on port A.
• Simulate the program using the circuit shown in figure via Proteus software.
Verify it operates properly when simulated
Procedure
Part 1: Flasher
Write an assembly program to make a Flasher on RB0 (Hint: Use the Delay
Subroutine).
• Simulate the program using the circuit shown in figure via Proteus software.
Verify it operates properly when simulated
• Program a PIC 16F84A using the QL2006 programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its
operation. Demonstrate the circuits operation to the instructor.
Procedure
• Write an assembly program to make a Flasher on RA0; then use the interrupt
method to control the flashing speed of this flasher.
Hint// Use the interrupt on change (RB4 – RB7)
• Simulate the program using the circuit shown in figure via Proteus software.
Verify it operates properly when simulated
• Program a PIC 16F84A using the QL2006 programmer.
• Build the circuit using the programmed PIC 16F84A and then observe its
operation. Demonstrate the circuits operation to the instructor.
More Information about TMR0
This incrementing is done in the background of everything a microcontroller does. It
is up to programmer to "think up a way" how he will take advantage of this
characteristic for his needs. One of the ways is increasing some variable on each timer
overflow. If we know how much time a timer needs to make one complete round, then
multiplying the value of a variable by that time will yield the total amount of elapsed
time.
PIC16F84 has an 8-bit timer. Number of bits determines what value timer counts to
before starting to count from zero again. In the case of an 8-bit timer, that number is
256. A simplified scheme of relation between a timer and a prescaler is represented on
the previous diagram. Prescaler is a name for the part of a microcontroller which
divides oscillator clock before it will reach logic that increases timer status. Number
which divides a clock is defined through first three bits in OPTION register. The
highest divisor is 256. This actually means that only at every 256th clock, timer value
would increase by one. This provides us with the ability to measure longer timer
periods.
TMR0 and Reset
After each count up to 255, timer resets its value to zero and starts with a new cycle of
counting to 255. During each transition from 255 to zero, T0IF bit in INTCOM
register is set. If interrupts are allowed to occur, this can be taken advantage of in
generating interrupts and in processing interrupt routine. It is up to programmer to
reset T0IF bit in interrupt routine, so that new interrupt or new overflow could be
detected. Beside the internal oscillator clock, timer status can also be increased by the
external clock on RA4/TOCKI pin. Choosing one of these two options is done in
OPTION register through T0CS bit. If this option of external clock was selected, it
would be possible to define the edge of a signal (rising or falling), on which timer
would increase its value.