% Changing the path from main_folder to a particular chapter
main_path=fileparts(which('Main_Content.mlx'));
%addpath(append(main_path,'/Chapter2'))
cd (append(main_path,'/Chapter6/LED'))
addpath(append(main_path,'/Service'))
SAVE_FLAG=0; % saving the figures in a file
clear_all_but('SAVE_FLAG')
Vin(:,1)=0:0.0001:1; %time;
model_name = 'LEDControl';
% Set Simulation Mode the parameter in PWM to "Average"
set_param('LEDControl/PWM','pwm_or_av','2');
%m = sdo.getParameterFromModel(model_name, 'PWM');
simOut = sim(model_name, 'CaptureErrors', 'on');
Warning: Matching "Goto" for "From" 'LEDControl/LED W/From1' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W/From3' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W1/From1' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W1/From3' not found
plot(simOut.voltage_in.Data*100/5,simOut.Power_out.Data*1000)
xlabel('Duty cycle (%)', 'FontSize', 10)
ylabel('Radiant power (mW)', 'FontSize', 10)
title('LED average radiant power vs. PWM duty cycle')
annonation_save('b)',"Fig6.12b.jpg", SAVE_FLAG);
clear_all_but('SAVE_FLAG')
Vin(:,1)=0:0.0001:1; %time;
model_name = 'LEDControl';
% Set Simulation Mode the parameter in PWM to "PWM"
set_param('LEDControl/PWM','pwm_or_av','1');
simOut = sim(model_name, 'CaptureErrors', 'on');
Warning: Matching "Goto" for "From" 'LEDControl/LED W/From1' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W/From3' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W1/From1' not found
Warning: Matching "Goto" for "From" 'LEDControl/LED W1/From3' not found
plot(simOut.current_out.Time(1:2000), simOut.current_out.Data(1:2000)*1000)
xlabel('Time (s)', 'FontSize', 10)
ylabel('Forward current (mA)', 'FontSize', 10)
title('PWM current through the LED vs. time')
plot(simOut.current_out.Time(1:2000), simOut.Power_out.Data(1:2000)*1000)
xlabel('Time (s)', 'FontSize', 10)
ylabel('Radiant power (mW)', 'FontSize', 10)
title('LED radiant power')
annonation_save('a)',"Fig6.12a.jpg", SAVE_FLAG);
exportgraphics(gcf,"Fig6.12a.jpg", 'Resolution',600)
% plot(-simOut.diode_out.Data,-simOut.current_out.Data*1e6)
% xlabel(' Reverse Voltage (V)', 'FontSize', 10)
% ylabel('Reverse Light Current (µA)', 'FontSize', 10)
% Irr1(:,1)=0:0.01:10; %time
% Irr1(:,2)=10; % irradiance
% Vin(:,1)=0:0.01:10; %time;
% simOut = sim('photodiode', 'CaptureErrors', 'on');
% plot(-simOut.diode_out.Data,-simOut.current_out.Data*1e6)