555 timer plots in matlab

11 vues (au cours des 30 derniers jours)
Vlad Hornai
Vlad Hornai le 27 Déc 2018
Hi guys !
I want to implement the formulas for vo and vc for a 555 astable multivibrator circuit. I wrote the formulas for vc but it doesn't work. If anyone could help me, I would be very pleased.
function voplot_Callback(hObject, eventdata, handles)
% hObject handle to voplot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% plot Vo
ra = str2num(get(handles.edit1,'string'));
rb = str2num(get(handles.edit2,'string'));
c = str2num(get(handles.edit3,'string'))/1000000;
voh = str2num(get(handles.edit5,'string'));
vol = str2num(get(handles.edit6,'string'));
tc = 0.693*(ra+rb)*c;
td = 0.693*rb*c;
t = 0.693*(ra+(2*rb))*c;
d = (tc/t)*100; % duty cycle
f=1.45/((ra+2*rb)*c); % frequency
%Vi=0; %Vi should vary
%Vf=10; %Vf should vary
if f>100
p=0:1:200000;
out=2.5*square(2*pi*f*p,d)+2.5;
%VCcha = 10^(1-exp(-p./(ra+rb)*c)); %Vc charge
figure(1);
plot(p,out)
else
p=0:0.0001:5;
out=2.5*square(2*pi*f*p,d)+2.5;
% VCdis =0*exp(-p/rb*c); %Vc discharge
figure(1);
plot(p,out)
end
%subplot(2,1,1); plot(out)
%subplot(2,1,2); plot(VCcha)
ylim([0 6])
xlabel('Time(s)')
ylabel('Amplitude(V)')
title('Waveform of 555 Timer as an Astable Multivibrator')
  3 commentaires
Cris LaPierre
Cris LaPierre le 28 Déc 2018
Modifié(e) : Cris LaPierre le 28 Déc 2018
Using the values shared in this page for a 555 electronic metronome, your code appears to work. I put in the values for 180bpm (3/sec) and got this plot.
I therefore suspect your issue has more to do with making this work in a gui.
Vlad Hornai
Vlad Hornai le 28 Déc 2018
Hi Cris LaPierre,
Vo works, but I am trying to plot Vc, which is over the capacitor. Also, for Vo the amplitude should be between voh and vol. I changed the parameter from ylim with voh and vol, but still i don't get the good result.
Untitled.png
I should obtain this.Vo works somehow, but the problem is I don't know how to plot Vc. As you see in my code, I put in comment the equation for Vc which are exponential because the capactior charges and discharges. If you could help me with this, I would be very grateful because it is for a project for school and this is the hardest part form the project so far.
Thanks.

Connectez-vous pour commenter.

Réponses (1)

Mohan singh
Mohan singh le 27 Août 2021
bro if you are done plzz help me to solve this

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by