필터 지우기
필터 지우기

how to convert pwm_change_duty() function used in pic uC to a pwm code

조회 수: 7 (최근 30일)
preethi
preethi 2014년 7월 3일
댓글: Uladzimir 2014년 7월 3일
pwm_change_duty() is an already built in function used in pic microcontroller to change duty cycle. how do i convert it into a matlab formula.

채택된 답변

Uladzimir
Uladzimir 2014년 7월 3일
편집: Uladzimir 2014년 7월 3일
function output = pwmoutput(tctnr,q,Tcntr)
% q - pwm duty assignment 0...1
% Tcntr - pwm counter period
% tau - pwm duty
% tcntr - current pwm counter condition 0...Tcntr
tau = q*Tcntr;
output = tcntr <= tau;
  댓글 수: 2
preethi
preethi 2014년 7월 3일
could you please explain what tcnts,q,Tcntr is
Uladzimir
Uladzimir 2014년 7월 3일
Pwm timer counts from 0 to timer period. And moment of pwm pin switching is defined by the function pwm_change_duty(). tcntr - is the current value of timer counter. It increments from 0 to Tcntr. Tcntr is maximal quantity of pwm timer clocks. q is the duty factor, which defines the duration of impulse. So output goes high when tcntr is equal tau = q*Tcntr, e. g. tau is the moment of switching.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Pulse width modulation (PWM)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by