SlideShare a Scribd company logo
1 of 39
PIC MICROCONTROLLER
PROGRAMMING
BASED ON MIKROC
Difference from A
microprocessor?
• To communicate microprocessor with
peripheral environment, special circuits must
be used.
Internal Structure
Description
• PIC – “Peripheral Interface Controller”
• Made by Microchip Technology
• Most popular by industry developers and
hobbyists
– Low cost (cents to dollars)
– Availability
– Extensive application notes
– Serial programming
4
Internal Units description
REGISTER
• An electronic circuit which can memorize the
state of one byte
SFR(Special Function Register)
• Registers whose function is predetermined by
the manufacturer of the microcontroller
• Examples are timers, A/D converter,
oscillators ,etc
INPUT / OUTPUT PORTS
• Microcontroller has one or more registers
(called ports) connected to the microcontroller
pins.
• Can change a pin function as you wish
MEMORY UNIT
• Memory is part of the microcontroller used for
data storage.
• Types
1.MROM,
2.OTP ROM, 3.UV EP
ROM, 4.FLASH MEM
5. EEPROM, 6. RAM
INTERRUPT
• Most programs use interrupts in their regular
execution
• The signal which informs the central processor
unit about such an event is called an
INTERRUPT.
CENTRAL PROCESSOR UNIT (CPU)
• Instruction decoder decodes program
instructions and runs other circuits based on
this
• Accumulator is a kind of working desk used
for storing all data upon which some
operation should be performed (addition,
shift/move etc.)
• ALU
OSCILLATOR
• Enable harmonic and synchronous operation of
all circuits within the microcontroller.
• Usually configured so as to use quartz crystal or
ceramic resonator for frequency stability
• but it can also operate as a stand-alone circuit
(like RC oscillator).
TIMERS/COUNTERS
• To measure time between two events, it is
sufficient to count up pulses generated by the
oscillator. This is exactly what the timer does.
• ‘Stopwatches’ commonly 8- or 16-bit SFRs the
contents of which is automatically incremented
by each coming pulse.
HOW DOES THE TIMER OPERATE?
• It is easy to measure short time intervals, up to
256 microsecond in this mode
•To measure time intervals greater than 256 micro
size we use two modified methods
Using a pre Scaler
Using
Interrupt
COUNTERS
• If the timer receives pulses form the
microcontroller input pin, then it turns into a
counter.
• The only difference is that in this case pulses
to be counted come over the microcontroller
input pin and their duration (width) is mostly
undefined.
A/D CONVERTER
• Converts continuous signals to discrete digital
numbers or circuit converts an analogue value
into a binary number and passes it to the CPU
for further processing.
Basic path of processing codes
Tools required for programming
• Micro C IDE
• USB PIC Programmer drivers
• USB PIC Programmer
IDE FOR MIKROC PRO FOR PIC
• HNKKKKHH
COMPILER’S TOOLS AND LIBRARIES
• USART TERMINAL
• EEPROM EDITOR
• ASCII CHART
• SEVEN SEGMENT EDITOR
• LCD CUSTOM CHARACTER
• GRAPHIC LCD BITMAP GENERATOR
• LIBRARIES
SEVEN SEGMENT EDITOR
PIC 16F877A LAYOUT
Analog I/O
UART
I2C
PORTA
http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-
world-of-microcontrollers/
24
FEATURES OF PIC 16F887A
• RISC architecture
– Only 35 instructions to learn
– All single-cycle instructions except branches
• Operating frequency 0-20 MHz
• Precision internal oscillator
– Factory calibrated
– Software selectable frequency range of 8MHz to 31KHz
• Power supply voltage 2.0-5.5V
– Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA
(stand-by mode)
• Power-Saving Sleep Mode
• Brown-out Reset (BOR) with software control option
• 35 input/output pins
– High current source/sink for direct LED drive
• 256 bytes EEPROM memory
– Data can be written more than 1.000.000 times
• 368 bytes RAM memory
• A/D converter:
– 14-channels
– 10-bit resolution
• 3 independent timers/counters
• Watch-dog timer
• Analogue comparator module with
– Two analogue comparators
– Fixed voltage reference (0.6V)
– Programmable on-chip voltage reference
• PWM output steering control
• Enhanced USART module
– Supports RS-485, RS-232 and LIN2.0
– Auto-Baud Detect
• Master Synchronous Serial Port (MSSP)
– supports SPI and I2C mode
BASIC CONNECTION OF A PIC
Basic codes of MikroC
• TRISB=0; means that all the pins of PORTB is set
as output. If it is set as 1 then all the pins will be
configured as input.
• PORTB=0; means that all the pins of PORTB is
Logic low. If it is set as 1 then all the pins will be
set as Logic high state.
• ANSELA = 0; Configure PORTA pins as digital.
ANSELA = 0b00000101; Means that RA0/C12IN0-
and RA2/C2IN+ pins are analog inputs.
• ANSELH=0; Configure PORTB pins as digital.
• TRISC.F0 = 1; Makes 0th bit of PORTC Input
• TRISC.F5 = 0; Makes 5th bit of PORTC Output
• PORTB.F3 = 1; Makes 3ed bit of PORTB at Logic
High
• PORTB.F7 = 0; Makes 7th bit of PORTB at Logic
Low
Simple MikroC program for blinking an
LED
Interfacing DC Motor with PIC
Microcontroller using L293D
• Control Signals and Motor Status
RB0/IN1 RB2/IN2 Motor
Status LOW LOW Stops
LOW HIGH ANT-CLK
HIGH LOW CLK
HIGH HIGH CLK
CCP(Capture/Compare/PWM) Module
• Three modes-Capture, compare , PWM
• PWM
• Signals with varying duty cycle.
• Importance in power control circuits.
• /* In this example, PWM module is initialized and set to give a pulse train of 50%
dutycycle.
For this purpose, functions PWM1_Init(), PWM1_Start() and PWM1_Set_Duty()
are used.
All of them are already contained in the mikroC PRO for PIC PWM library and just
need to
be copied to the program. */
unsigned short duty_c; // Define variable duty_c
void initMain() {
ANSEL = ANSELH = 0; // All I/O pins are configured as digital
PORTC = TRISC = 0; // Initial state of port C output pins
PWM1_Init(5000); // PWM module initialization (5KHz)
}
void main() {
initMain();
duty_c = 127; // Initial value of duty-cycle
PWM1_Start(); // Start PWM1 module
PWM1_Set_Duty(duty_c); // Set PWM duty-cycle to 50%
...
SERIAL COMMUNICATION
MODULES
• EUSART
Enhanced Universal Synchronous Asynchronous
Receiver Transmitter (EUSART)module is a serial I/O
communication peripheral unit.
• also known as Serial
Communications Interface (SCI)
• contains all clock generators,
shift registers and data buffers
necessary to perform an input/output serial data
transfer
• In order to enable data transmission via
EUSART module it is necessary to define the
state of the following pins-RX , TX
• RX-Receiver
• TX-Transmitter
/* In this example, internal EUSART module is initialized and set to send back the
message immediately after receiving it. Baude rate is set to 9600 bps. The
program
uses UART library routines UART1_init(), UART1_Write_Text(),
UART1_Data_Ready(),
UART1_Write() and UART1_Read().*/
char uart_rd;
void main() {
ANSEL = ANSELH = 0; // Configure AN pins as digital
C1ON_bit = C2ON_bit = 0; // Disable comparators
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to become stable
UART1_Write_Text("Start");
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data back via UART
}`
}
END
BY

More Related Content

What's hot

8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller pptRahul Kumar
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerJhemi22
 
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller Nitesh Kumar
 
Overview of Shift register and applications
Overview of Shift register and applicationsOverview of Shift register and applications
Overview of Shift register and applicationsKarthik Kumar
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
Programmable logic controller - Siemens S7-1200
Programmable logic controller - Siemens S7-1200Programmable logic controller - Siemens S7-1200
Programmable logic controller - Siemens S7-1200Ahmed Elsayed
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentationxavierpaulino
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
Programmable Logic Controller and ladder logic programming
Programmable Logic Controller and ladder logic programmingProgrammable Logic Controller and ladder logic programming
Programmable Logic Controller and ladder logic programmingseema Vishwakarma
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051ssuser3a47cb
 
Plc example presentation
Plc example presentationPlc example presentation
Plc example presentationRoshit Kadiru
 

What's hot (20)

8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
 
Overview of Shift register and applications
Overview of Shift register and applicationsOverview of Shift register and applications
Overview of Shift register and applications
 
Analog to digital converters, adc
Analog to digital converters, adcAnalog to digital converters, adc
Analog to digital converters, adc
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Interfacing Stepper motor with 8051
Interfacing Stepper motor with 8051Interfacing Stepper motor with 8051
Interfacing Stepper motor with 8051
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Programmable logic controller - Siemens S7-1200
Programmable logic controller - Siemens S7-1200Programmable logic controller - Siemens S7-1200
Programmable logic controller - Siemens S7-1200
 
Communication protocols - Embedded Systems
Communication protocols - Embedded SystemsCommunication protocols - Embedded Systems
Communication protocols - Embedded Systems
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentation
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
Programmable Logic Controller and ladder logic programming
Programmable Logic Controller and ladder logic programmingProgrammable Logic Controller and ladder logic programming
Programmable Logic Controller and ladder logic programming
 
Dynamic logic circuits
Dynamic logic circuitsDynamic logic circuits
Dynamic logic circuits
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
 
Arduino
ArduinoArduino
Arduino
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Plc example presentation
Plc example presentationPlc example presentation
Plc example presentation
 

Similar to PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS

Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
microcontroller board ppt
microcontroller board pptmicrocontroller board ppt
microcontroller board pptshashank tiwari
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]akmalKhan55
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacingRAMPRAKASHT1
 
Embedded systems and robotics by scmandota
Embedded systems and robotics by scmandotaEmbedded systems and robotics by scmandota
Embedded systems and robotics by scmandotascmandota
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080Vivek Venugopal
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]gauravholani
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptxgodfrey35
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)Sahil Gupta
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller pavihari
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarGauravRaikar3
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf818Farida
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollersBarER4
 
Bluetooth Home Automation
Bluetooth Home AutomationBluetooth Home Automation
Bluetooth Home AutomationApoorv Gupta
 

Similar to PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS (20)

Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
microcontroller board ppt
microcontroller board pptmicrocontroller board ppt
microcontroller board ppt
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
 
Embedded systemsc
Embedded systemscEmbedded systemsc
Embedded systemsc
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
Embedded systems and robotics by scmandota
Embedded systems and robotics by scmandotaEmbedded systems and robotics by scmandota
Embedded systems and robotics by scmandota
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
 
embedded system
embedded systemembedded system
embedded system
 
plc_scada.pptx
plc_scada.pptxplc_scada.pptx
plc_scada.pptx
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikar
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
 
Bluetooth Home Automation
Bluetooth Home AutomationBluetooth Home Automation
Bluetooth Home Automation
 

Recently uploaded

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS

  • 2. Difference from A microprocessor? • To communicate microprocessor with peripheral environment, special circuits must be used.
  • 4. Description • PIC – “Peripheral Interface Controller” • Made by Microchip Technology • Most popular by industry developers and hobbyists – Low cost (cents to dollars) – Availability – Extensive application notes – Serial programming 4
  • 5. Internal Units description REGISTER • An electronic circuit which can memorize the state of one byte
  • 6. SFR(Special Function Register) • Registers whose function is predetermined by the manufacturer of the microcontroller • Examples are timers, A/D converter, oscillators ,etc
  • 7. INPUT / OUTPUT PORTS • Microcontroller has one or more registers (called ports) connected to the microcontroller pins. • Can change a pin function as you wish
  • 8. MEMORY UNIT • Memory is part of the microcontroller used for data storage. • Types 1.MROM, 2.OTP ROM, 3.UV EP ROM, 4.FLASH MEM 5. EEPROM, 6. RAM
  • 9. INTERRUPT • Most programs use interrupts in their regular execution • The signal which informs the central processor unit about such an event is called an INTERRUPT.
  • 10. CENTRAL PROCESSOR UNIT (CPU) • Instruction decoder decodes program instructions and runs other circuits based on this • Accumulator is a kind of working desk used for storing all data upon which some operation should be performed (addition, shift/move etc.) • ALU
  • 11. OSCILLATOR • Enable harmonic and synchronous operation of all circuits within the microcontroller. • Usually configured so as to use quartz crystal or ceramic resonator for frequency stability • but it can also operate as a stand-alone circuit (like RC oscillator).
  • 12. TIMERS/COUNTERS • To measure time between two events, it is sufficient to count up pulses generated by the oscillator. This is exactly what the timer does. • ‘Stopwatches’ commonly 8- or 16-bit SFRs the contents of which is automatically incremented by each coming pulse.
  • 13. HOW DOES THE TIMER OPERATE? • It is easy to measure short time intervals, up to 256 microsecond in this mode •To measure time intervals greater than 256 micro size we use two modified methods
  • 14. Using a pre Scaler Using Interrupt
  • 15. COUNTERS • If the timer receives pulses form the microcontroller input pin, then it turns into a counter. • The only difference is that in this case pulses to be counted come over the microcontroller input pin and their duration (width) is mostly undefined.
  • 16. A/D CONVERTER • Converts continuous signals to discrete digital numbers or circuit converts an analogue value into a binary number and passes it to the CPU for further processing.
  • 17.
  • 18. Basic path of processing codes
  • 19. Tools required for programming • Micro C IDE • USB PIC Programmer drivers • USB PIC Programmer
  • 20.
  • 21. IDE FOR MIKROC PRO FOR PIC • HNKKKKHH
  • 22. COMPILER’S TOOLS AND LIBRARIES • USART TERMINAL • EEPROM EDITOR • ASCII CHART • SEVEN SEGMENT EDITOR • LCD CUSTOM CHARACTER • GRAPHIC LCD BITMAP GENERATOR • LIBRARIES
  • 24. PIC 16F877A LAYOUT Analog I/O UART I2C PORTA http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1- world-of-microcontrollers/ 24
  • 25.
  • 26. FEATURES OF PIC 16F887A • RISC architecture – Only 35 instructions to learn – All single-cycle instructions except branches • Operating frequency 0-20 MHz • Precision internal oscillator – Factory calibrated – Software selectable frequency range of 8MHz to 31KHz • Power supply voltage 2.0-5.5V – Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA (stand-by mode) • Power-Saving Sleep Mode • Brown-out Reset (BOR) with software control option • 35 input/output pins – High current source/sink for direct LED drive
  • 27. • 256 bytes EEPROM memory – Data can be written more than 1.000.000 times • 368 bytes RAM memory • A/D converter: – 14-channels – 10-bit resolution • 3 independent timers/counters • Watch-dog timer • Analogue comparator module with – Two analogue comparators – Fixed voltage reference (0.6V) – Programmable on-chip voltage reference • PWM output steering control • Enhanced USART module – Supports RS-485, RS-232 and LIN2.0 – Auto-Baud Detect • Master Synchronous Serial Port (MSSP) – supports SPI and I2C mode
  • 29. Basic codes of MikroC • TRISB=0; means that all the pins of PORTB is set as output. If it is set as 1 then all the pins will be configured as input. • PORTB=0; means that all the pins of PORTB is Logic low. If it is set as 1 then all the pins will be set as Logic high state. • ANSELA = 0; Configure PORTA pins as digital. ANSELA = 0b00000101; Means that RA0/C12IN0- and RA2/C2IN+ pins are analog inputs. • ANSELH=0; Configure PORTB pins as digital.
  • 30. • TRISC.F0 = 1; Makes 0th bit of PORTC Input • TRISC.F5 = 0; Makes 5th bit of PORTC Output • PORTB.F3 = 1; Makes 3ed bit of PORTB at Logic High • PORTB.F7 = 0; Makes 7th bit of PORTB at Logic Low
  • 31. Simple MikroC program for blinking an LED
  • 32. Interfacing DC Motor with PIC Microcontroller using L293D • Control Signals and Motor Status RB0/IN1 RB2/IN2 Motor Status LOW LOW Stops LOW HIGH ANT-CLK HIGH LOW CLK HIGH HIGH CLK
  • 33.
  • 34. CCP(Capture/Compare/PWM) Module • Three modes-Capture, compare , PWM • PWM • Signals with varying duty cycle. • Importance in power control circuits.
  • 35. • /* In this example, PWM module is initialized and set to give a pulse train of 50% dutycycle. For this purpose, functions PWM1_Init(), PWM1_Start() and PWM1_Set_Duty() are used. All of them are already contained in the mikroC PRO for PIC PWM library and just need to be copied to the program. */ unsigned short duty_c; // Define variable duty_c void initMain() { ANSEL = ANSELH = 0; // All I/O pins are configured as digital PORTC = TRISC = 0; // Initial state of port C output pins PWM1_Init(5000); // PWM module initialization (5KHz) } void main() { initMain(); duty_c = 127; // Initial value of duty-cycle PWM1_Start(); // Start PWM1 module PWM1_Set_Duty(duty_c); // Set PWM duty-cycle to 50% ...
  • 36. SERIAL COMMUNICATION MODULES • EUSART Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART)module is a serial I/O communication peripheral unit. • also known as Serial Communications Interface (SCI) • contains all clock generators, shift registers and data buffers necessary to perform an input/output serial data transfer
  • 37. • In order to enable data transmission via EUSART module it is necessary to define the state of the following pins-RX , TX • RX-Receiver • TX-Transmitter
  • 38. /* In this example, internal EUSART module is initialized and set to send back the message immediately after receiving it. Baude rate is set to 9600 bps. The program uses UART library routines UART1_init(), UART1_Write_Text(), UART1_Data_Ready(), UART1_Write() and UART1_Read().*/ char uart_rd; void main() { ANSEL = ANSELH = 0; // Configure AN pins as digital C1ON_bit = C2ON_bit = 0; // Disable comparators UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to become stable UART1_Write_Text("Start"); while (1) { // Endless loop if (UART1_Data_Ready()) { // If data is received, uart_rd = UART1_Read(); // read the received data, UART1_Write(uart_rd); // and send data back via UART }` }