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

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 日

0 投票

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 件)

コミュニティ

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2014 年 7 月 3 日

コメント済み:

2014 年 7 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by