View
225
Download
0
Category
Preview:
Citation preview
8/6/2019 Pic Micro Presentation
1/57
bb
8/6/2019 Pic Micro Presentation
2/57
PIC Microcontroller
Prepared by:
Ahmed Usama
8/6/2019 Pic Micro Presentation
3/57
References
8/6/2019 Pic Micro Presentation
4/57
Group Formation
Group of 4 persons. Nominate a representative.
8/6/2019 Pic Micro Presentation
5/57
MICROCONTROLLERS1st DAY
8/6/2019 Pic Micro Presentation
6/57
MICROCONTROLLERS1st DAY
ReviewWhat is the embedded system
Microprocessor , Microcontroller and FPGA.
Why a microcontroller is needed?
Variety of microcontrollers.Why PIC microcontrollers?
Specificiations of PIC 16F877.
Programming PIC 16F877.
PIC 16F877 in circuit.Application.
8/6/2019 Pic Micro Presentation
7/57
Review
Digital System:
A system that works with discrete elements of information ratherthan with continuous signals as in an analog system.
This discrete information is represented in binary form.
Data processing is carried out by means of binary logicelements using binary signals.
Quantities are stored in binary storage elements (memory).
8/6/2019 Pic Micro Presentation
8/57
8
There are two primary classifications of logic circuits(System):
1. Combinational logic circuits
Circuits of this type have outputs that are functions of the inputs(illustrated below)
The order in which the inputs are applied is not important.
Combinational logic circuits have no capability for memory
Combinational
LogicInputs Outputs = f(Inputs)
Combinational Logic Circuit
8/6/2019 Pic Micro Presentation
9/57
9
2. Sequential logic circuits
Circuits of this type have outputs that are functions of both inputsand previous outputs (illustrated below)
Sequential circuits contain some type of memory elements. As anexample, a counter must remember that its previous output was 6 inorder to produce its new output 7.
Combinational
Logic
Inputs Outputs = f(inputs + past outputs)
Memory
Sequential Logic Circuit
8/6/2019 Pic Micro Presentation
10/57
Embedded System
An embedded system is a computer system designedto perform one or a few dedicated functions(often real-time).
Hardware and Software expected to function withouthuman intervention.
Respond, monitor, control external environment usingsensor and actuators.
In contrast a general-purpose computer, such as apersonal computer (PC), is designed to be flexible and to
meet a wide range of end-user needs.
8/6/2019 Pic Micro Presentation
11/57
Why Embedded systems
Low cost. Small packaging.
Low power consumption.
Programmable, re-programmable.
Easy integration with circuit. For application in which cost, power and space are
critical
Single-purpose
Real-time operation.(ex: ABS (WSS) ; ECU(FI)) Application dependent processor.
Automation
8/6/2019 Pic Micro Presentation
12/57
Automation
Control
Electronic circuits Power Electronics
Mechanics
8/6/2019 Pic Micro Presentation
13/57
8/6/2019 Pic Micro Presentation
14/57
8/6/2019 Pic Micro Presentation
15/57
A microcontroller is a specialized form of microprocessor that is designed tobe self-sufficient and cost-effective, where a microprocessor is typicallydesigned to be general purpose (the kind used in a PC). Microcontrollersare frequently found in automobiles, office machines, toys, and appliances.
Microcontroller combines onto the same chip:
The CPU core (microprocessor),Memory (both ROM and RAM) ,Someparallel digital I/O
A microcontroller is part of an embedded system, which is essentially the(Microcontroller + whole circuit board) to perform dedicated task.
Microcontroller incorporates features of microprocessor(CPU,ALU,Register)
along with the presence of added features like RAM, ROM, I\O ports,counter etc.
A microcontroller controls the operation of machine using fixed programstored in Rom that doesn't change with lifetime
8/6/2019 Pic Micro Presentation
16/57
What is the difference?
Microprocessor
Microcontrollers FPGA
8/6/2019 Pic Micro Presentation
17/57
SO
Microcontrollers are intelligentelectronic devices used tocontroland monitordevices inthe real world
Microcontrollers areprogrammeddevices.
A program is a sequence of
instructionsthat tell themicrocontroller what to do.
8/6/2019 Pic Micro Presentation
18/57
Why a microcontroller is needed?
Sensors Controllers Actuators
8/6/2019 Pic Micro Presentation
19/57
PowerSupply
Microcontroller
Keypad
Level Switch
Temp. Sensor
Heater
Input Valve
Output ValveLCD
Alarm
Sensors M icrocontrollers Actuators
8/6/2019 Pic Micro Presentation
20/57
Sensors M icrocontrollers Actuators
8/6/2019 Pic Micro Presentation
21/57
Variety of microcontrollers
8/6/2019 Pic Micro Presentation
22/57
Von Neumann Architecture where programs and data share asingle memory area that is accessed over a common bus. Thisscheme works well for general use computers.
Harvard Architecture Vs PIC microcontroller uses Harvard
architecture. This architecture design uses separate memory areasand buses for data and programs.
Architecture for computers:
Generally there are two types of architecture for computers
8/6/2019 Pic Micro Presentation
23/57
CISC vs RISC In the early days work was done in assembly language.
Therefore CPU designers tried to make instructions that woulddo as much work as possible. This design philosophy was
named Complex Instruction Set Computer (CISC). With the advent of higher level languages, led to Reduced
Instruction Set Computer (RISC) (Simple compiler to RISC)(simpler assembly coding).
PIC microcontroller use RISC because there is a perception that
RISC is faster than CISC: Ex: A processor with MUL and other one with only ADD.
A processor with (ADD X(i),B,C) and other (ADD,Store).
Instruction Set
8/6/2019 Pic Micro Presentation
24/57
PIC Peripheral Interface Controller
Microchip Technology (www.microchip.com)
Harvard Architecture
RISC
Microchip Technology (www.microchip.com)
Harvard Architecture
RISC
8/6/2019 Pic Micro Presentation
25/57
PIC Microcontrollers are small computer on a chip with some specialproperties:
CPU, code memory, data memory and IO Ports all included on a singlechip.
Dedicated to one task.
Small and low cost. Embedded in many consumer devices.
Easy to program.
Better online documentation.
Low cost.
What is PIC microcontrollers?
8/6/2019 Pic Micro Presentation
26/57
Which PIC microcontrollers?
8/6/2019 Pic Micro Presentation
27/57
PIC SPEED
Can use crystals, clock oscillators, or even an RC circuit.
Some PICs have a built in 4MHz RC clock.
16F877 and 16F877A
Specificiations of PIC
8/6/2019 Pic Micro Presentation
28/57
Specificiations of PIC
40MHz
4MHz
10MHz
20MHz
33MHz
Max. Speed
8/6/2019 Pic Micro Presentation
29/57
PIC 16F877
8/6/2019 Pic Micro Presentation
30/57
8 kbytes of FLASH Program Memory
368 bytes of Data Memory (RAM)
256 bytes of EEPROM Data Memory
20 MHz operating speed(200 ns instruction cycle)
Max. 25 mA current from an output pin
Low-power consumption
Wide Operating Voltage: 2.0 5.0 V
Timers Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep via external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register,prescaler and postscaler
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
10-bit multi-channel A-to-D Converter I2C (Inter IC)Bus
USART for Serial Communication
5 I/O Ports: A, B, C, D, and E (33 input or output pins)
Specificiations PIC 16F877
8/6/2019 Pic Micro Presentation
31/57
LanguagesAssemblyBASICCCode Flow
Parallel portSerial portUSB port
Programming PIC 16F877
8/6/2019 Pic Micro Presentation
32/57
As a result of a successful compilationand assembling of a PIC BASIC programthe following files will be created.- BLINK.ASM - assembly file
- BLINK.LST - program listing- BLINK.HEX - executable file which iswritten into the programming memory
Pic Basic Pro
8/6/2019 Pic Micro Presentation
33/57
IDE(Integrated Development
Environment)
ISE Pack (FPGA)
MikroC MpLab
Proton
PICsimulator
8/6/2019 Pic Micro Presentation
34/57
Programming Languages
C-Language
Assembly BASIC
8/6/2019 Pic Micro Presentation
35/57
8/6/2019 Pic Micro Presentation
36/57
Minimum circuitry for
PIC16F877
Power Supply
Clock generation Reset
8/6/2019 Pic Micro Presentation
37/57
PIC 16F877
8/6/2019 Pic Micro Presentation
38/57
8/6/2019 Pic Micro Presentation
39/57
PIC 16F877
8/6/2019 Pic Micro Presentation
40/57
8/6/2019 Pic Micro Presentation
41/57
PIC 16F877
8/6/2019 Pic Micro Presentation
42/57
8/6/2019 Pic Micro Presentation
43/57
Minimum circuitry for PIC16F877
8/6/2019 Pic Micro Presentation
44/57
8/6/2019 Pic Micro Presentation
45/57
TRISB("TRI-State Enable" registers for port b
One register used to define if the B is set input or outputmode of each bit (1 for an input; 0 for an output).
In this example, TRISB value may be set as:
TRISB=%01110100 binary or
TRISB=$74 hex orTRISB=116 decimal
8/6/2019 Pic Micro Presentation
46/57
Exercise (PicSimulator)
8/6/2019 Pic Micro Presentation
47/57
PIC 16F877
8/6/2019 Pic Micro Presentation
48/57
Button and Leds
8/6/2019 Pic Micro Presentation
49/57
Methods of Isolation
Transistors
Optocoupler
Relay driver
8/6/2019 Pic Micro Presentation
50/57
Optocoupler
8/6/2019 Pic Micro Presentation
51/57
Relay driver board
8/6/2019 Pic Micro Presentation
52/57
8/6/2019 Pic Micro Presentation
53/57
8/6/2019 Pic Micro Presentation
54/57
Motor Direction Control
8/6/2019 Pic Micro Presentation
55/57
SPDT Relay (H-Bridge)
8/6/2019 Pic Micro Presentation
56/57
Circuit Schematic
8/6/2019 Pic Micro Presentation
57/57
Thank you
Recommended