1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Vi điều khiển và ứng dụng OutputCompare

32 335 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Chuyên đề II Vi điều khiển và ứng dụng

  • OC with DsPIC

  • Chi tiết

  • Chức năng

  • Các chế độ hoạt động

  • Single compare match

  • OCx pin is high control bits OCM<2:0> are set to 001

  • OCx pin is low OCM<2:0> are set to 010

  • Single compare match, pin OCx toggles OCM<2:0> areset to 011

  • Ví dụ

  • Dual compare match mode

  • Single output pulse at pin Ocx OCM<2:0> are set to 100

  • Sequence of output pulses at pin Ocx control bits OCM<2:0> are set to 101

  • Ví dụ

  • The Pulse Width Modulation (PWM) Mode

  • PWM mode without fault protection input

  • PWM mode with fault protection input pin

  • PWM period and duty cycle calulation

  • PWM duty cycle

  • Slide 20

  • Mạch D/A

  • Ví dụ sóng vuông

  • Ví dụ sóng hình thang

  • Sóng hình sin

  • A second order filter

  • Ví dụ ứng dụng

  • Circular buffer

  • Slide 28

  • Circular Buffer

  • Phương pháp hoạt động

  • Xử lý lỗi

  • Slide 32

Nội dung

Chuyên đề II Vi điều khiển ứng dụng Output Compare OC with DsPIC Chi tiết Chức Các chế độ hoạt động  Single compare match mode,  Dual compare match mode generating either one output pulse or a sequence of output pulses,  Pulse Width Modulation (PWM) mode Single compare match  OCx pin is high, initial state is low, and interrupt is generated,  OCx pin is low, initial state is high, and interrupt is generated,  State of OCx pin toggles and interrupt is generated OCx pin is high control bits OCM are set to 001 OCx pin is low OCM are set to 010 Single compare match, pin OCx toggles OCM areset to 011 Ví dụ 10 PWM period and duty cycle calulation  The PWM period, TPWM=(PRy +1)TCY (TMRy prescale value), and the PWM frequency by: fPWM=1/TPWM  Example: Calculation of the PWM period for a microcontroller having a 10MHz clock with x4 PLL, Device clock rate is 40MHz The instruction clock frequency is FCY =FOSC/4, i.e 10MHz Timer prescale setting is Calculate the PWM period for the maximum value PR2=0xFFFF=65535 TPWM =(65535+1) x 0.1µs x (4) =26.21 ms, i.e fPWM =1/TPWM = 38.14 Hz 18 PWM duty cycle  If the duty cycle register,OCxR, is loaded with 0000, the duty cycle is zero and pin OCx will remain low throughout the PWM period  If the duty cycle register is greater that PRy, the output pin OCx will remain high throughout the PWM period (100% duty cycle)  If OCxR is equal to PRy, the OCx pin will be high in the first PWM cycle and low in the subsequent PWM cycle 19 Ví dụ 20 Mạch D/A 21 Ví dụ sóng vuông 22 Ví dụ sóng hình thang 23 Sóng hình sin 24 A second order filter 25 Ví dụ ứng dụng 26 Circular buffer 27 Circular buffer 28 Circular Buffer 29 Phương pháp hoạt động  Difficulites 30 Xử lý lỗi  Always Keep One Slot Open  Use a Fill Count  Read / Write Counts 31 Ví dụ 32 [...]... duty cycle calulation  The PWM period, TPWM=(PRy +1)TCY (TMRy prescale value), and the PWM frequency by: fPWM=1/TPWM  Example: Calculation of the PWM period for a microcontroller having a 10MHz clock with x4 PLL, Device clock rate is 40MHz The instruction clock frequency is FCY =FOSC/4, i.e 10MHz Timer 2 prescale setting is 4 Calculate the PWM period for the maximum value PR2=0xFFFF=65535 TPWM =(65535+1)... the OCx pin will be high in the first PWM cycle and low in the subsequent PWM cycle 19 Ví dụ 20 Mạch D/A 21 Ví dụ sóng vuông 22 Ví dụ sóng hình thang 23 Sóng hình sin 24 A second order filter 25 Ví dụ ứng dụng 26 Circular buffer 27 Circular buffer 28 Circular Buffer 29 Phương pháp hoạt động  Difficulites 30 Xử lý lỗi  Always Keep One Slot Open  Use a Fill Count  Read / Write Counts 31 Ví dụ 32

Ngày đăng: 30/12/2015, 18:05

TỪ KHÓA LIÊN QUAN

w