MATLAB: How to convert pwm_change_duty() function used in pic uC to a pwm code

electric_motor_controlpower_conversion_controlpower_electronics_controlpwm_change_duty() to matlab 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.

Best Answer

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;
Related Question