Upload
prince-alen
View
268
Download
0
Embed Size (px)
Citation preview
7/30/2019 Orcad Instruction
1/46
1
1. OVERVIEW OF THE DESIGN FLOW
This section illustrates the basic procedure for generating a schematic in Capture and
converting the schematic to a board design in Layout. The basic procedure is as follows:
1. Start Capture and set up a PCB project using the PC Board wizard.
2. Make a circuit schematic using OrCAD Capture.
3. Use Capture to generate a Layout netlist and save it as a .MNL fi le for Layout.
4. Start Layout and select a PCB technology template (.TCH fi le).
5. Save the Layout project as a .MAX project fi le.
6. Use Layout to import the .MNL netlist into the .MAX fi le.
7. Make a board outline.
8. Position the parts within the board outline.
9. Autoroute the board.
10. Run the postprocessor to generate fi les used to manufacture the PCB.
2. CREATING A CIRCUIT DESIGN WITH CAPTURE
If you do not have a full version of OrCAD you can install the version 10.5 Demo CD
included with this book or go to the OrCAD Web site and download the latest demo. If
you are using an older version of Layout most of the following information in this book
still applies, but some of the dialog boxes and menu items may be different.
2.1 Starting a New Project
Before you make a PCB layout, you need to have a circuit to lay out. You will use
Capture to make the schematic, so the fi rst step is to start the Capture application by
clicking the Windows Startbutton on your task bar and navigate to All Programs
OrCAD 10.5Demo . Once Capture is running, you should have a blank Capture
session frame and a session log. Go to the File dropdown menu and navigate to File
New and clickProject as shown in Fig. 2-1.
7/30/2019 Orcad Instruction
2/46
2
Figure 2-1 Starting a new project in Capture.
TheNew Project dialog box in Fig. 2-2 will pop up. Type a name for your project, and
then select the PC Board Wizard radio button. If you feel comfortable selecting your ownlocation to save the project, you can do that, or you can use the default location for now
(just remember where it is as you will need to fi nd it later on with Layout). ClickOK.
After you clickOK, the PCB Project Wizard dialog box shown in Fig. 2-3(a) will pop up.
For now circuit simulation will not be performed, so leave the Enable project simulation
box unchecked (we will take a look at circuit simulation in Chap. 9). ClickNext. After
you clickNext, the PCB Project Wizard dialog box shown in Fig. 2-3(b) will pop up.
This box allows you to add specifi c libraries to your project. Scroll down until you find
the Discrete.olb library, highlight it by clicking on it, and then click the Add__ button;
then clickFinish. This completes the project set up. You should have a Project Manager
window in the left side of the Capture session frame as shown in Fig. 2-4. You may also
have a Schematic window in the work space. If the schematic is not open, expand the
7/30/2019 Orcad Instruction
3/46
3
projectname.dsn directory by clicking the _ box that is to the left of the
projectname.dsn icon (whereprojectname is the name you gave your project while using
the project setup wizard). Click the _ box next to the Schematics folder, and
Figure 2-2 New Project dialog box
Figure 2-3 PCB Project Wizard dialog boxes. (a) Simulation selection. (b) Parts library
selection.
7/30/2019 Orcad Instruction
4/46
4
then double click the fi le called Page1. The Schematic page should open. If you do not
see the dots, that means your grid is turned off. The grid must be turned on to properly
place and connect parts. To turn the grid onclick the button. If the grid is on, the grid
dots will be visible and the grid button will be gray instead of red.
Figure 2-4 Example view of a new project.
2.2 Placing Parts
To add parts to your schematic, make the Schematic page active and select Place from the
Part dropdown menu, or press the place part tool button , or press P on your keyboard.
The Place Part dialog box shown in Fig. 2-5 pops up. In the Libraries selection box in the
bottom left of the dialog box, clickDISCRETE. Then in the Part List box clickC (for
7/30/2019 Orcad Instruction
5/46
5
capacitor). You should see its symbol in the Preview window on the lower right. Click
OK. In the Libraries window you may have libraries different from what is shown in Fig.
2-5. At the very least youshould have the DISCRETE library since you had the wizard
include it. If for some reason youdo not see any parts or the DISCRETE library is notthere, you can follow along for now to getan overview of the process, or you can fi nd
and add the library to your project.
To add a part libraryto your project select Place from the Part dropdown menu as
describedabove. In the Place Part dialog box shown in Fig. 2-5 press the Add Library
button tobring up the Browse File dialog box shown in Fig. 2-6. Find and select the
Discrete.olblibrary and clickOpen. You can also fi nd a capacitor in thepspice library
folder. To add it,double click thepspice folder, select the Analog.olb library, and click
Open. You should now be back to the Place Part dialog box, and the library you just
added should be shown in the Libraries list box. Find and select C from the Part List
selection box and clickOK
.
Figure 2-5 Place Part dialog box.
7/30/2019 Orcad Instruction
6/46
6
After you clickOK, you should immediately return to the Schematic page and have a
capacitor tagging along with your mouse pointer. Left click on the Schematic page to
place a part as shown in Fig. 2-7. Place a couple of the capacitors on the page. When you
are finished, hit the ESC key or right click the mouse and select End Mode from the pop-up menu.
Figure 2-6 Add a library using the Browse File dialog box
7/30/2019 Orcad Instruction
7/46
7
.
Figure 2-7 Placing the parts
2.3 Creating The Layout Netlist In Capture
Once all of the connections are complete the next step is to create a netlist (an ASCII text
fi le that describes the circuit). There are several types of netlists, but you will want to
generate a Layout netlist. Begin by making the Project Manager window active (instead
of the Schematic Page window) and select the .dsn icon by left clicking it once. If the
Schematic page is active the Tools menu will not be available. Minimize the Schematic
page if necessary to get to the Project Manager. As shown in Fig. 2-9, select Tools
7/30/2019 Orcad Instruction
8/46
8
Create Netlist from the Tools menu. The Create Netlist dialog box will pop up as shown
in Fig. 2-10.
Figure 2-9 Create the Layout netlist.
7/30/2019 Orcad Instruction
9/46
9
Figure 2-10 Create Netlist dialog box.
From the Create Netlist dialog box, select the Layout tab. Later, you will see how to set
up file structures to organize your projects, but for now just save it to the current (default)
directory and remember where the netlist fi le (with the .MNL extension) is saved. Leave
the RunECO to Layout radio button unchecked for now. You will use the ECO
(engineering change order) tool in Chap. 9. ClickFinish to generate the netlist. Capture
will display a warning text box stating, DesignPath/Yourname.dsn will be saved prior
to netlisting. ClickOK. Capture will then generate the netlist and report the results in theSession log. At this point you have generated a netlist fi le with a .MNL extension that
Layout can use. You could close Capture now, but leave it open so that Capture and
Layout can communicate with each other if necessary. This will allow you to go back and
review the circuit if you need to when you are working in Layout.
7/30/2019 Orcad Instruction
10/46
10
3. DESIGNING THE PCB WITH LAYOUT
3.1 Starting Layout And Importing The Netlist
Now you will use the netlist to route a board using Layout. Begin by clicking the
Windows Startbutton on your task bar and navigate to All Programs OrCAD 10.5
Demo .
Once Layout is up and running, you will be presented with a blank session frame initially.
Tobegin working on your board you need to tell Layout what kind of board you want to
use andthen import the netlist fi le you generated with Capture into that board type.
Begin by selecting New from the session frames File menu. An AutoECO (automatic
engineering changeorder) dialog box will pop up as shown in Fig. 2-11. There are threepieces of information that
Figure 2-11 Assigning a PCB technology fi le.+
need to be entered into the AutoECO dialog box. You will add the fi rst two pieces of
information in the TCH and the MNL text boxes, and Layout will enter a default value
into the third (MAX) text box.
The first step is to select a board technology template(a *.TCH fi le). Click the Browse
7/30/2019 Orcad Instruction
11/46
11
button across from the TCH text box and navigate to the Tools/Layout/Data folder
(Layout should go there automatically) and select the default technology template
(default.tch) as shown in Fig. 2-11. We will use some of the other technology files in
Chap. 9. ClickOpen.The wizard will type the path and name of the technology fi le into the text box for you.
Once the technology fi le is assigned, you need to select the Layout netlist (.MNL) file
you generated in Capture. To do so, click the Browsebutton across from the MNL text
box and locate the .MNL fi le you created in Capture (Fig. 2-12). You probably will not
see it at first since you will likely be in the Data folder from which you selected the
technology fi le. Navigate to where you saved the project. Once you fi nd your fi le,
select it and clickOpen. The wizard will type the path and name of the netlist fi le into
the text box for you.
Figure 2-12 Opening the netlist.
7/30/2019 Orcad Instruction
12/46
12
Once you have entered these fi rst two pieces of information, the wizard will fi ll in the
MAX fi le information for you with a default name as shown in Fig. 2-13. The MAX fi le
is Layouts project fi le that contains the information needed to build your board. You can
use the default name (recommended for now) or save it with a different name. Click theApply ECObutton at the bottom of the dialog box. You do not need to make any changes
to the Options settings at this point. Layout will immediately go about setting up the
project environment.
Figure 2-13 Save the MAX Layout file.
When setting up the project Layout checks for footprint assignments for each part in the
netlist. If no footprint was assigned, or if a footprint that Layout does not know about is
assigned to a part, Layout will ask you to choose a footprint with the Link Footprint to
Component dialog box shown in Fig. 2-14. Most likely this will be the case since no
7/30/2019 Orcad Instruction
13/46
13
footprints were assigned to these parts in Capture (you will see how to do that in Chaps. 3
and 9). If you get the Link Footprint dialog box, click on the Link existing footprint to
componentbutton..
Figure 2-14 The Auto ECO Link Footprint to Component dialog box.
Layout will initiate the Footprint Library utility shown in Fig. 2-15. Depending on how
(or if) Layout has been used before, you may have libraries different from those shown in
the figure. If you are using the Demo version, you should, at the very least, have the
Ex_gui library; which you should select. In the Footprints box below the Libraries box, fi
nd the SIP/TM/L.200/2 footprint. If you are using the full version fi nd and select the
TM_AXIAL.LLB and select a footprint that has two pads. A picture of the footprint will
be displayed in the Preview window on the right of the dialog box. In Chap. 8 you will
see how to add other libraries and footprints and also how to make our own footprints if
the one you need does not exist. For now clickOKonce you have selected a footprint.
Layout will assign this footprint to all of the capacitors in the design by default. If you
7/30/2019 Orcad Instruction
14/46
14
added other components in addition to the capacitors, you will probably have to repeat
this procedure for each type of component. Right now it is not important what the
footprint is because we just want to get an overview of the overall process.
Once the AutoECO utility has completed assigning the footprints, you should end up inthe board layout environment shown in Fig. 2-16. This is the Design window for your
board. Here you can see the component footprints as well as the silk screen and assembly
details. Also visible is the board origin and the board drill symbol table. We will look at
those items in greater detail later, but right now we will concentrate on making a board
outline, placing the parts, and routing the traces.
Figure 2-16 Layout initial view.
7/30/2019 Orcad Instruction
15/46
15
3.2 Making A Board Outline
Next, we will add a board outline. It is good practice to place the boards lower left
cornerat the origin (see Fig. 2-16). If you have not already done so, zoom out so that you
can seethe entire drill table and have it located near the bottom of the window. Next,
make sure thatthe online Design Rule Check (DRC) box is off. If you do not see it, it is
already off, butif you see a dashed (or solid) white box in the work space, the DRC box
is on. To turn offthe DRC box, click the button. There is another DRC button that looks
like , but it is for checking the entire design for errors prior to sending the design out for
fabrication. Theonline DRC checks the area within the box while you work. Sometimes
it can get in the wayof doing what you need to do while you are moving things around,
so turn it off for now. Tomake a board outline, click on the Obstaclebuttonit looks
like . Move your cursor tothe work area and right click with the mouse; click theNew
option from the pop-up menu.The cross hair cursor will be smaller now, indicating that it
is poised to do something. Rightclick on the work area again and select the Properties
option from the pop-up menu. TheEdit Obstacle dialog box will pop up as shown in Fig.
2-18. Make sure that Board Outlineis selected in the Obstacle Type dropdown list and
that Global Layeris selected in theObstacle Layerdropdown list. ClickOK.
Create a board outline similar to the one shown in Fig. 2-19. Place the cursor over the
originmark in the drill charts upper left corner (position 1). Click and release the left
mouse buttononce. This begins the fi rst vertex of the board outline. Next move the
cursor to position 2. Theborder will stretch from the last place you clicked to the cursor.
At position 2 left click andrelease again. Continue in the same manner to positions 3 and
4. After you have placed thefinal vertex at position 4, right click to bring up a menu box
and clickFinish to complete theboard outline. The board outline does not have to berectangular, but for now it will help keepthings simple.
7/30/2019 Orcad Instruction
16/46
16
Figure 2-18 Edit Obstacle properties box.
7/30/2019 Orcad Instruction
17/46
17
4. SUMMARY OF PCB DESIGNING
The following is a summary of the process:
1. Start Capture and set up a PCB project using the wizard.
2. Design the circuit using OrCAD Capture.
3. Generate a Layout netlist using Capture and save it as a .MNL fi le.
4. Start Layout and select a PCB technology (.TCH fi le) template.
5. Save the Layout project as a .MAX fi le.
6. Import the .MNL netlist from Capture.
7. Make a board outline.
8. Position the parts.
9. Autoroute the board.
10. Postprocess the board to make the Gerber files used to manufacture the PCB.
7/30/2019 Orcad Instruction
18/46
18
5. INTRODUCTION TO MICROCONTROLLERS
A microcontroller (sometimes abbreviated C, uC or MCU) is a small computer on a
single integrated circuit containing a processor core, memory, and programmable
input/outputperipherals. Program memory in the form ofNOR flash orOTP ROM is also
often included on chip, as well as a typically small amount ofRAM. Microcontrollers are
designed for embedded applications, in contrast to the microprocessors used in personal
computers or other general purpose applications.
Microcontrollers are used in automatically controlled products and devices, such as
automobile engine control systems, implantable medical devices, remote controls, office
machines, appliances, power tools, and toys. By reducing the size and cost compared to adesign that uses a separate microprocessor, memory, and input/output devices,
microcontrollers make it economical to digitally control even more devices and processes.
Mixed signal microcontrollers are common, integrating analog components needed to
control non-digital electronic systems.
Some microcontrollers may use four-bit words and operate at clock rate frequencies as
low as 4 kHz, for low power consumption (milli watts or microwatts). They will
generally have the ability to retain functionality while waiting for an event such as a
button press or other interrupt; power consumption while sleeping (CPU clock and most
peripherals off) may be just nano watts, making many of them well suited for long lasting
battery applications. Other microcontrollers may serve performance-critical roles, where
they may need to act more like a digital signal processor(DSP), with higher clock speeds
and power consumption.
Try making a list and counting how many devices with microcontrollers you use in a
typical day. Here are some examples: if your clock radio goes off, and you hit the snooze
button a few times in the morning, the first thing you do in your day is interact with a
microcontroller. Heating up some food in the microwave oven and making a call on cell
phone also involve operating microcontrollers. Thats just the beginning. Here are a few
http://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Flash_memory#NOR_flashhttp://en.wikipedia.org/wiki/Programmable_read-only_memoryhttp://en.wikipedia.org/wiki/Random-access_memoryhttp://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Clock_ratehttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Clock_ratehttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Random-access_memoryhttp://en.wikipedia.org/wiki/Programmable_read-only_memoryhttp://en.wikipedia.org/wiki/Flash_memory#NOR_flashhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Integrated_circuit7/30/2019 Orcad Instruction
19/46
19
more examples: turning on the television with a handheld remote, playing a handheld
game, using a calculator, and checking your digital wristwatch. All those devices have
microcontrollers inside them that interact with you.
Microcontrollers are hidden inside a surprising number of products these days. If your
microwave oven has an LED orLCD screen and a keypad, it contains a microcontroller.
All modern automobiles contain at least one microcontroller, and can have as many as six
or seven: The engine is controlled by a microcontroller, as are the anti-lock brakes, the
cruise control and so on. Any device that has a remote control almost certainly contains a
microcontroller: TVs, VCRs and high-end stereo systems all fall into this category. Nice
SLRand digital cameras, cell phones, camcorders, answering machines, laser printers,
telephones (the ones with caller ID, 20-number memory, etc.), pagers, and feature-laden
refrigerators, dishwashers, washers and dryers (the ones with displays and keypads)...
You get the idea. Basically, any product or device that interacts with its user has a
microcontroller buried inside.
5.1 Microcontroller Manufacturers
1. Texas Instruments
2. ST Micro
3. Atmel
4. Dallas Semiconductor
5.Renesas Electronics Corporation
6. Hitachi Semiconductor
7. Intel
8. Microchip
9. National Semiconductor
http://www.howstuffworks.com/led.htmhttp://www.howstuffworks.com/lcd.htmhttp://www.howstuffworks.com/engine.htmhttp://www.howstuffworks.com/anti-lock-brake.htmhttp://www.howstuffworks.com/cruise-control.htmhttp://www.howstuffworks.com/tv.htmhttp://www.howstuffworks.com/vcr.htmhttp://www.howstuffworks.com/camera.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/cell-phone.htmhttp://www.howstuffworks.com/camcorder.htmhttp://www.howstuffworks.com/question21.htmhttp://www.howstuffworks.com/laser-printer.htmhttp://www.howstuffworks.com/telephone.htmhttp://www.howstuffworks.com/refrigerator.htmhttp://www.howstuffworks.com/washer.htmhttp://www.howstuffworks.com/dryer.htmhttp://www.howstuffworks.com/dryer.htmhttp://www.howstuffworks.com/washer.htmhttp://www.howstuffworks.com/refrigerator.htmhttp://www.howstuffworks.com/telephone.htmhttp://www.howstuffworks.com/laser-printer.htmhttp://www.howstuffworks.com/question21.htmhttp://www.howstuffworks.com/camcorder.htmhttp://www.howstuffworks.com/cell-phone.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/camera.htmhttp://www.howstuffworks.com/vcr.htmhttp://www.howstuffworks.com/tv.htmhttp://www.howstuffworks.com/cruise-control.htmhttp://www.howstuffworks.com/anti-lock-brake.htmhttp://www.howstuffworks.com/engine.htmhttp://www.howstuffworks.com/lcd.htmhttp://www.howstuffworks.com/led.htm7/30/2019 Orcad Instruction
20/46
20
A microcontroller is a specialized form of microprocessor that is designed to be self
sufficient and cost-effective, where a microprocessor is typically designed to be general
purpose (the kind used in a PC). Microcontrollers are frequently found in automobiles,
office machines, toys, and appliances. The microcontroller is the integration of a numberof useful functions into a single IC package.
These functions are:
The ability to execute a stored set of instructions to carry out user defined tasks.
The ability to be able to access external memory chips to both read and write data from
and to the memory.
Basically, a microcontroller is a device which integrates a number of the components of a
microprocessor system onto a single microchip. So a microcontroller combines onto the
same microchip :
1.The CPU core (microprocessor)
2.Memory (both ROM and RAM)
3.Some parallel digital I/O
Also, a microcontroller is part of an embedded system, which is essentially the whole
circuit board. Look up "embedded system" on Wikipedia. The difference is that
microcontroller incorporates features of microprocessor(CPU,ALU,Registers)along with
the presence of added features like presence of RAM,ROM,I\O ports,counter etc.Here
microcontroller control the operation of machine using fixed programme stored in Rom
that doesn't change with lifetime.
7/30/2019 Orcad Instruction
21/46
21
6. AN INTRODUCTION TO PIC MICROCONTROLLERS
The PIC microcontroller family is manufactured by Microchip Technology Inc. Currently
they are one of the most popular microcontrollers, used in many commercial and
industrial applications. Over 120 million devices are sold each year.
The PIC microcontroller architecture is based on a modifi ed Harvard RISC (Reduced
Instruction Set Computer) instruction set with dual-bus architecture, providing fast and fl
exible design with an easy migration path from only 6 pins to 80 pins, and from 384 bytes
to 128 kbytes of program memory.
6.1 PIC History
The PIC (peripheral interface controller) was developed in the early '90s by Arizona
microchip to meet a demand for a cheap, small and practical microcontroller which was
both easy to use and program. The thing that made the PIC so successful was the fact that
it was so small compared to the other options available on the market at the time.
6.2 FEATURES OF PIC MICROCONTROLLER
6.2.1 High-Performance RISC CPU:
1. Only 35 single-word instructions to learn
2. All single-cycle instructions except for program branches, which are two-cycle
3. Operating speed: DC20 MHz clock input
4. DC200 ns instruction cycle
5. Up to 8K x 14 words of Flash Program Memory,
6. Up to 368 x 8 bytes of Data Memory (RAM),
8. Pinout compatible to other 28-pin or 40/44-pin
7/30/2019 Orcad Instruction
22/46
22
6.2.2 Peripheral Features:
1. Timer0: 8-bit timer/counter with 8-bit prescaler
2. Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep via
external crystal /clock3. Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
4. Two Capture, Compare, PWM modules Capture is 16-bit, max. resolution is 12.5 ns
Compare is 16-bit, max. resolution is 200 ns PWM max. resolution is 10-bit
5. Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave)
6. Brown-out detection circuitry for Brown-out Reset (BOR)
6.2.3 Analog Features:
1. 10-bit, up to 8-channel Analog-to-Digital Converter (A/D)
2. Brown-out Reset (BOR)
3. Analog Comparator module with:
Two analog comparators
Programmable on-chip voltage reference
(VREF) module
Programmable input multiplexing from device
inputs and internal voltage reference
Comparator outputs are externally accessible
6.2.4 Special Microcontroller Features:
1. 100,000 erase/write cycle Enhanced Flash program memory typical
2. 1,000,000 erase/write cycle Data EEPROM memory typical
3. Data EEPROM Retention > 40 years
4. Self-reprogrammable under software control
7/30/2019 Orcad Instruction
23/46
23
5. In-Circuit Serial Programming (ICSP) via two pins
6. Single-supply 5V In-Circuit Serial Programming
7. Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
8. Programmable code protection9. Power saving Sleep mode
10.Electable oscillator options
11. In-Circuit Debug (ICD) via two pins
Although there are many models of PIC microcontrollers, the nice thing is that they are
upward compatible with each other and a program developed for one model can very
easily, in many cases with no modifications, be run on other models of the family. The
basic assembler instruction set of PIC microcontrollers consists of only 33 instructions
and most of the family members (except the newly developed devices) use the same
instruction set. This is why a program developed for one model can run on another model
with similar architecture without any changes.
The important point to remember is that there could be many models that satisfy all of
these requirements. You should always try to find the model that satisfies your minimum
requirements and the one that does not offer more than you may need. For example, if
you require a microcontroller with only 8 I/O pins and if there are two identical
microcontrollers, one with 8 and the other one with 16 I/O pins, you should select the one
with 8 I/O pins. Although there are several hundred models of PIC microcontrollers, the
family can be broken down into three main groups, which are:
12-bit instruction word (e.g., 12C5XX, 16C5X) (also referred to in this book as the 12Series and the 16C5X Series)
14-bit instruction word (e.g., 16F8X, 16F87X) (also referred to in this book as the 16
Series)
16-bit instruction word (e.g., 17C7XX, 18C2XX) (also referred to in this book as the 17
7/30/2019 Orcad Instruction
24/46
24
Series and the 18 Series).
All three groups share the same RISC architecture and the same instruction set, with a
few additional instructions available for the 14-bit models, and many more instructions
available for the 16-bit models. Instructions occupy only one word in memory, thusincreasing the code efficiency and reducing the required program memory. Instructions
and data are transferred on separate buses, so the overall system performance is increased.
7/30/2019 Orcad Instruction
25/46
25
7. PIC 16F877A MICROCONTROLLER
The 16F877A is one of the most popular PIC microcontrollers and it's easy to see why - it
comes in a 40 pin DIP pinout and it has many internal peripherals. The 40 pins make it
easier to use the peripherals as the functions are spread out over the pins. This makes it
easier to decide what external devices to attach without worrying too much if there
enough pins to do the job.
One of the main advantages is that each pin is only shared between two or three functions
so its easier to decide what the pin function (other devices have up to 5 functions for a
pin).
7.1 Microchip PIC16F877A Microcontroller Features
7.1.1 High-Performance RISC CPU
Lead-free; RoHS-compliant Operating speed: 20 MHz, 200 ns instruction cycle Operating voltage: 4.0-5.5V Industrial temperature range (-40 to +85C) 15 Interrupt Sources 35 single-word instructions All single-cycle instructions
except for program branches
(two-cycle)
7.1.2 Special Microcontroller
Features
Flash Memory: 14.3 Kbytes(8192 words)
Data SRAM: 368 bytes
7/30/2019 Orcad Instruction
26/46
26
Data EEPROM: 256 bytes Self-reprogrammable under software control In-Circuit Serial Programming via two pins (5V)
Watchdog Timer with on-chip RC oscillator Programmable code protection Power-saving Sleep mode Selectable oscillator options In-Circuit Debug via two pins
7.1.3 Peripheral Features
33 I/O pins; 5 I/O ports Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler
o Can be incremented during Sleep via external crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules
o 16-bit Capture input; max resolution 12.5 nso 16-bit Compare; max resolution 200 nso 10-bit PWM
Synchronous Serial Port with two modes:o SPI Mastero I2C Master and Slave
USART/SCI with 9-bit address detection Parallel Slave Port (PSP)
o 8 bits wide with external RD, WR and CS controls Brown-out detection circuitry for Brown-Out Reset
7/30/2019 Orcad Instruction
27/46
27
7.1.4 Analog Features
10-bit, 8-channel A/D Converter Brown-Out Reset Analog Comparator module
o 2 analog comparatorso Programmable on-chip voltage reference moduleo Programmable input multiplexing from device inputs and internal VREFo Comparator outputs are externally accessible
As you can see the PIC16F877A is rich in peripherals so you can use it for many
different projects.
7/30/2019 Orcad Instruction
28/46
28
PIC 16F877A Register File Map
7/30/2019 Orcad Instruction
29/46
29
7.2 I/O Ports
Some pins for these I/O ports are multiplexed with an alternate function for the peripheral
features on the device. In general, when a peripheral is enabled, that pin may not be used
as a general purpose I/O pin.
7.3 Interrupts
An INTERRUPT is any service request that causes the CPU to stop its current execution
and execute a stream to service the interrupt .
Sources of interrupt can be :
1.
TIMER OVERFLOW INTERRUPT2. A/D INTERRUPT3. USART INTERRUPT4. INTERRUPT FROM EXTERNAL SOURCE Control Registers
PICs use a series of Special Function Registers for controlling peripherals Some
examples are:
OPTION -external interrupt edge select ,timer 0 Prescaler
INTCON -Interrupt control: interrupt enables, flags, etc
7.4 OPTION_REG Register
The OPTION_REG Register is a readable and writable register, which contains various
control bits to configure the TMR0 prescaler/WDT postscaler (single assignable register
known also as the prescaler), the external INT interrupt, TMR0 and the weak pull-ups on
PORTB.
bit 7 RBPU: PORTB Pull-up Enable bit
7/30/2019 Orcad Instruction
30/46
30
1 = PORTB pull-ups are disabled
0 = PORTB pull-ups are enabled by individual port latch values
bit 6 INTEDG: Interrupt Edge Select bit
1 = Interrupt on rising edge of RB0/INT pin0 = Interrupt on falling edge of RB0/INT pin
bit 5 T0CS: TMR0 Clock Source Select bit
1 = Transition on RA4/T0CKI pin
0 = Internal instruction cycle clock (CLKO)
bit 4 T0SE: TMR0 Source Edge Select bit
1 = Increment on high-to-low transition on RA4/T0CKI pin
0 = Increment on low-to-high transition on RA4/T0CKI pin
bit 3 PSA: Prescaler Assignment bit
1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
bit 2-0 PS2:PS0: Prescaler Rate Select bit
7.5 INTCON Register
The INTCON register is a readable and writable register, which contains various enable
and flag bits for the TMR0 register overflow, RB port change and external RB0/INT pin
interrupts.
bit 7 GIE: Global Interrupt Enable bit
1 = Enables all unmasked interrupts
0 = Disables all interrupts
bit 6 PEIE: Peripheral Interrupt Enable bit
1 = Enables all unmasked peripheral interrupts
7/30/2019 Orcad Instruction
31/46
31
0 = Disables all peripheral interrupts
bit 5 TMR0IE: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 interrupt
0 = Disables the TMR0 interruptbit 4 INTE: RB0/INT External Interrupt Enable bit
1 = Enables the RB0/INT external interrupt
0 = Disables the RB0/INT external interrupt
bit 3 RBIE: RB Port Change Interrupt Enable bit
1 = Enables the RB port change interrupt
0 = Disables the RB port change interrupt
bit 2 TMR0IF: TMR0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed (must be cleared in software)
0 = TMR0 register did not overflow
bit 1 INTF: RB0/INT External Interrupt Flag bit
1 = The RB0/INT external interrupt occurred (must be cleared in software)
0 = The RB0/INT external interrupt did not occur
bit 0 RBIF: RB Port Change Interrupt Flag bit
1 = At least one of the RB7:RB4 pins changed state; a mismatch condition will continue
to set
the bit. Reading PORTB will end the mismatch condition and allow the bit to be cleared
(must be cleared in software).
0 = None of the RB7:RB4 pins have changed state
7.6 Data EEPROM & Flash Program Memory
The data EEPROM and Flash program memory is readable and writable during normal
operation (over the full VDD range). This memory is not directly mapped in the register
7/30/2019 Orcad Instruction
32/46
32
file space. Instead, it is indirectly addressed through the Special Function Registers.
There are six SFRs used to read and write this memory:
1. EECON12.
EECON2
3. EEDATA4. EEDATH5. EEADR6. EEADRH
When interfacing to the data memory block, EEDATA holds the 8-bit data for read/write
and EEADR holds the address of the EEPROM location being accessed.
These devices have 128 or 256 bytes of data EEPROM (depending on the device), with
an address range from 00h to FFh. On devices with 128 bytes, addresses from
80h to FFh are unimplemented and will wraparound to the beginning of data EEPROM
memory. When writing to unimplemented locations, the on-chip charge pump will be
turned off.
7.7 Timer0 Module
The Timer0 module timer/counter has the following features:
1. 8-bit timer/counter2. Readable and writable3. 8-bit software programmable prescaler4. Internal or external clock select5. Interrupt on overflow from FFh to 00h6. Edge select for external clock
Figure 5-1 is a block diagram of the Timer0 module and the prescaler shared with the
WDT. Additional information on the Timer0 module is available in the PICmicro Mid-
Range MCU Family Reference Manual (DS33023). Timer mode is selected by clearing
7/30/2019 Orcad Instruction
33/46
33
bit T0CS (OPTION_REG). In Timer mode, the Timer0 module will increment every
instruction cycle (without prescaler). If the TMR0 register is written, the increment is
inhibited for the following two instruction cycles.
The user can work around this by writing an adjusted value to the TMR0 register.Counter mode is selected by setting bit T0CS
(OPTION_REG). In Counter mode, Timer0 will increment either on every rising or
falling edge of pin RA4/T0CKI. The incrementing edge is determined by the Timer0
Source Edge Select bit, T0SE (OPTION_REG). Clearing bit T0SE selects the rising
edge. Restrictions on the external clock input are discussed in detail in Section 5.2 Using
Timer0 with an External Clock.
The prescaler is mutually exclusively shared between the Timer0 module and the
Watchdog Timer. The prescaler is not readable or writable. Prescalerdetails the
operation of the prescaler.
7.7.1 Timer0 Interrupt
The TMR0 interrupt is generated when the TMR0register overflows from FFh to 00h.
This overflow setsbit TMR0IF (INTCON). The interrupt can bemasked by clearing
bit TMR0IE (INTCON). BitTMR0IF must be cleared in software by the Timer0
module Interrupt Service Routine before re-enablingthis interrupt. The TMR0 interrupt
cannot awaken theprocessor from Sleep since the timer is shut-off duringSleep.
7.8 Analog-To-Digital Converter (A/D) Module
The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices and
eight for the 40/44-pin devices.
The conversion of an analog input signal results in a corresponding 10-bit digital number.
The A/D module has high and low-voltage reference input that is software
selectable to some combination of VDD, VSS, RA2 or RA3.
7/30/2019 Orcad Instruction
34/46
34
The A/D converter has a unique feature of being able to operate while the device is in
Sleep mode. To operate in Sleep, the A/D clock must be derived from the A/Ds internal
RC oscillator.
The A/D module has four registers. These registers are:1. A/D Result High Register (ADRESH)2. A/D Result Low Register (ADRESL)3. A/D Control Register 0 (ADCON0)4. A/D Control Register 1 (ADCON1)
The ADCON0 register, shown in Register 11-1, controls the operation of the A/D module.
The ADCON1 register, shown in Register 11-2, configures the functions
of the port pins. The port pins can be configured as analog inputs (RA3 can also be the
voltage reference) or as digital I/O.
7/30/2019 Orcad Instruction
35/46
35
8. PROGRAMS
8.1 Example Of A To D Converter
#include
#fuses HS
#byte portd=0x08
#byte trisd=0x88
#byte trisa=0x85
#byte porta=0x05
#byte adcon0=0x1f
#byte adcon1=0x9f
#byte adresh=0x1e
#byte adres1=0x9e
unsigned int32 i;
unsigned int16 digital;
unsigned int digit,pos;
void main()
{
trisd=0x00;
trise=0x00;
trisa=0x02;
adcon0=0x89;
adcon1=0xc4;
lcd_command(0x38);
lcd_command(0x0e);
lcd_command(0x06);
7/30/2019 Orcad Instruction
36/46
36
lcd_command(0x01);
lcd_command(0x02);
while(1)
{
adcon0|=0x04;
for(i=0;i
7/30/2019 Orcad Instruction
37/46
37
enable();
}
void enable()
{porte|=0x04;
for(i=0;i
7/30/2019 Orcad Instruction
38/46
38
void lcd_command(unsigned char);
void lcd_data(unsigned char);
#INT_EXT
int_external()
{
count++;
intcon&=0xfd;
}
void main()
{trisb=0x01;
option=0xff;
intcon=0xd0;
trisd=0x00;
trise=0x00;
lcd_command(0x38);
lcd_command(0x0e);
lcd_command(0x06);
lcd_command(0x01);
lcd_command(0x02);
while(1)
{
temp=count;
pos=0xc9;
while(1)
{
lcd_comand(pos--);
7/30/2019 Orcad Instruction
39/46
7/30/2019 Orcad Instruction
40/46
40
8.3 Example of Blinking of LEDs
#include
7/30/2019 Orcad Instruction
41/46
41
CONCLUSION
Summer Training developed a thorough understanding of PCB Designing & Embedded
system ( PIC Microcontroller). It helped me to develop some new idea in electronics and
in the field of microcontroller This approach is particularly suited to affective
expression. This platform will be used to explore several affective technique in the PCB
Designing & Embedded system ( PIC Microcontroller). I have gathered a lot of
knowledge about how to use these ideas in our field and to transfer these ideas into a real
and genuine product.
7/30/2019 Orcad Instruction
42/46
42
REFERENCES
1. Kraig Mitzner(2007) Complete PCB Design Using OrCad Capture andLayout pp 17-37
2. Microchip Technology Inc. (2003) PIC16F87XA Data Sheet
7/30/2019 Orcad Instruction
43/46
43
7/30/2019 Orcad Instruction
44/46
44
7/30/2019 Orcad Instruction
45/46
45
7/30/2019 Orcad Instruction
46/46