555 timer plots in matlab
Afficher commentaires plus anciens
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
le 28 Déc 2018
What doesn't work about it? All we have to look at is the callback function.
Is there a particular error message you are getting? What are your edit field strings (ra, rb, c, voh, vol)?
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
le 28 Déc 2018
Réponses (1)
Mohan singh
le 27 Août 2021
0 votes
bro if you are done plzz help me to solve this
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
