CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.

Slides:



Advertisements
Similar presentations
EEE305 Microcontroller Systems
Advertisements

More fun with Timer/Counters
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
555 Timer ©Paul Godin Updated February Oscillators ◊We have looked at simple oscillator designs using an inverter, and had a brief look at crystal.
ECT 357 Ch 16 Output Control. Today’s Quote: The measure of a man is not how great his faith is bt how great his love is. The measure of a man is not.
Infineon Technologies Corp. June 99 1 HOT167-1 Version 2.0 F PWMmax = x 50ns = 78 kHz Pulse Width Modulation Unit (PWM) (20 MHz)  4 independent.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
Taking timing further Chapter Nine 9.1 – 9.8 Dr. Gheith Abandah1.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Pulse Width Modulation (PWM) LED Dimmer Circuit
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
In this PPT, all the materials covered up for the PIC microcontroller set-up would be studied. Preliminary skills: Knowing of basic C grammar and basic.
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
V 0.21 Timers A timer on a  C is simply a counter The input clock frequency to a timer can be prescaled so that it is some fraction of the system clock.
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Lecture 29: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM)
ARM Timers.
System Clocks.
16F877A. Timer 0 The Timer0 module timer/counter has the following features: –8-bit timer/counter –Readable and writable –8-bit software programmable.
MS_uC / fue1 / V TIMx - Timer Programming Microcontroller TIMx - Timer Autumn term 2012.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Timers The timers of the PIC16C7X microcontroller can be briefly described in only one sentence. There are three completely independent timers/counters.
AT91 Embedded Peripherals
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
Timers.
By: Khalid Hawari Muath Nijim Thaer shaikh Ibrahim Supervisor: Dr. Jamal Kharousheh Dr. Nasser Hamad 27 December 2010.
Al-Najah National University
ELE22MIC Lecture 18 The AVR Sleep Modes The ATMEGA128’s Timer System
8254 Timer.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
Microcontroller Applications ELEC 421 Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
Timer 1 and 2 operation, PWM Principles. Timer 1 Operation.
Microcontrollers session. What is Microcontroller? Microcontroller is composed of microprocessor,ram, flash memory,EEPROM and some modules like timers,
8133A Overview. 8133A Overview 10-Feb04 Page A Overview 1) Specifications and Applications 2) Operational Overview 3) Block Diagram.
Seth Schwiethale James Crosetto James Ellison.  square pulse of ms, repeats every 20 ms  It is the same for both steering and acceleration 
Components of a typical full-featured microcontroller.
Pulse-Width Modulation: Simulating variable DC output
Module 8 Tutorial  An 8086 system is used for controlling the speed of a motor. The motor can operate at 5 different speeds (1- 5).  The speed.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Timer modules in PIC 16F877.  The PIC 16F877 basically has three independent timer modules,  denoted by the symbols, TIMER-0, TIMER1,andTIMER2. . These.
16F877A.
Why are Timer Functions Important?
MICROCONTROLLER AND INTERFACING
Timers and Event Counters
V.V.P. ENGINEERING COLLEGE,RAJKOT
Timer and Interrupts.
AVR Addressing Modes Subject: Microcontoller & Interfacing
Microprocessors Timers
Project Title EVM IN PIC Under the Guidance of Submitted by.
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
Timer/Counter Modified from Dr. Lam Phung’s Slides.
8-bit Timer/Counter0 with PWM
Introduction to Microprocessors and Microcontrollers
Pugazhendhi.M 11/12/2018 TIMERS 11/12/2018 CCET CCET.
ECE 354 Computer Systems Lab II
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
UNIT 19 PWM 로봇 SW 교육원 조용수.
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
Figure CCP1 Control Register
Mark Bristow CENBD 452 Fall 2002
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
Programmable Interval Timer
Pulse-Width Modulation: Simulating variable DC output
Timers Chapter 2.
Presentation transcript:

CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides access to the current state of a register which constantly changes its value. In this case, it is the timer TMR1 register.  Compare Mode constantly compares values of two registers. One of them is the timer TMR1 register. This circuit also allows the user to trigger an external event when a predetermined amount of time has expired.  PWM (Pulse Width Modulation) can generate signals of varying frequency and duty cycle on one or more output pins

CCP MODULES  The PIC16F887 microcontroller has two CCP modules- CCP1 and CCP2.  CCP1 IN PWM MODE  Signals of varying frequency and duty cycle have a wide range of application in automation.

CCP1 IN PWM MODE  A typical example is a power control circuit. Refer to figure below. If a logic zero (0) indicates the switch-off and a logic one (1) indicates the switch-on, the electrical power that load consumers will be directly proportional to the pulse duration. This ratio is often called Duty Cycle.

CCP1 IN PWM MODE  Another example, common in practice, is the use of PWM signals in the circuit for generating signals of arbitrary waveforms such as sinusoidal waveform. See figure below:  Devices which operate in this way are often used in practice as adjustable frequency drivers controlling the electric motor (speed, acceleration, deceleration etc.).

CCP1 IN PWM MODE

 The figure in previous ppt slide shows the block diagram of the CCP1 module set in PWM mode. In order to generate a pulse of arbitrary form on its output pin, it is necessary to set pulse period (frequency) and pulse duration.

CCP1 IN PWM MODE  PWM PERIOD  The output pulse period (T) is determined by the PR2 register of the timer TMR2. The PWM period can be calculated using the following equation:  PWM Period = (PR2 +1) * 4Tosc * TMR2 Prescale Value.  If the PWM period (T) is known, then it is easy to determine the signal frequency F because these two values are related by equation F=1/T.

CCP1 IN PWM MODE  PWM DUTY CYCLE  The PWM duty cycle is specified by using in total of 10 bits: eight MSbs of the CCPR1L register and two additional LSbs of the CCP1CON register (DC1B1 and DC1B0). The result is a 10-bit number contained in the formula:  Pulse Width = (CCPR1L,DC1B1,DC1B0) * Tosc * TMR2 Prescale Value

CCP1 IN PWM MODE  PWM RESOLUTION  An PWM signal is nothing more than a pulse sequence with varying duty cycle. For one specified frequency (number of pulses per second), there is a limited number of duty cycle combinations. This number represents a resolution measured by bits. For example, a 10- bit resolution will result in 1024 discrete duty cycles, whereas an 8-bit resolution will result in 256 discrete duty cycles etc. In relation to this microcontroller, the resolution is determined by the PR2 register. The maximum value is obtained by writing number FFh.

CCP1 IN PWM MODE How to do this in PICC ?!

CCP1 IN PWM MODE  setup_ccp1 (mode): mode is a constant. Valid constants are in the devices.h file  Set CCP to PWM mode: (CCP_PWM)  Enable Pulse Width Modulator

CCP1 IN PWM MODE  setup_timer_2 (mode, period, postscale)  mode may be one of: T2_DISABLED, T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16  period is a int that determines when the clock value is reset,  postscale is a number 1-16 that determines how many timer resets before an interrupt: (1 means one reset, 2 means 2, and so on).

CCP1 IN PWM MODE  Example: setup_timer_2 ( T2_DIV_BY_4, 0xc0, 2); // At 20mhz, the timer will increment every 800ns // will overflow every 153.6us // and will interrupt every 307.2us.

CCP1 IN PWM MODE  set_pwm1_duty (value) :value may be an 8 or 16 bit constant or variable  Example: // For a 20 mhz clock, 1.2 khz frequency,  // t2DIV set to 16  // the following sets the duty to 50% (or 416 us).  long duty;  duty = 520; // /(16*(1/ ))  set_pwm1_duty(duty);

CCP1 IN PWM MODE  This example generates a pulse of 5 KHz frequency and 85% duty cycle.

CCP1 IN PWM MODE

The End of PIC Part Next Time we’ll talk about Arduino Chips!! Thank You (^_^)