Modeling in simscape

Voltage divider

    simulink>simscape>electrical
ဆားကစ်ပတ်လမ်းတစ်ခုတွင်ရှိသော ဗို့အားကို ခွဲယူသည့်ညီမျှခြင်း
Equation for voltage divider circuit
V_{out}= V_{in} \frac{R_{2}}{R_{1}+R_{2}}

 
လိုချင်တာကိုတည် စုစုပေါင်းခုံခံမှုနဲ့စား 

simulink ဖြင့်ပြသသော်

image
Current divider circuit

အထက်ပါ ပုံမှတဆင့် အခြားသော ဗို့အားခွဲဝေသည့် ဆားကစ်များကို ဆွဲသားနိုင်သည်။


current divider

    ဆားကစ်ပတ်လမ်းတစ်ခုတွင်ရှိသည့် လျှပ်စီးကြောင်းကိုခွဲယူသည့်ညီမျှခြင်း
Equation for current divider circuit
I_{out}=I_{in}\frac{R_{1}}{R_{2}+{R_{3}}}

မလိုချင်တာကိုတည် စုစုပေါင်း ခုခံမှုနဲ့စား 

simulink နှင့်ပြသသော်

image
Current divider circuit

stepseq.m

%—- Unit step sequence
%u(n) = 1 if n ≥ 0
%u(n) = 0 if n < 0
%——————-
%u(n-n0)=1 if n ≥ n0
%u(n-n0)=0 if n < n0
%n1 ≤ n0 ≤ n2
%——————- Start here
function [x,n]=stepseq(n0,n1,n2)
n=[n1:n2];
x=[(n-0)≥0];
%——– end

imseq.m

%——- Unit simple sequence
%
%———————-
% x(n) = \delta (n-n0)
%———————-Start here
function [x,n] = imseq(n0,n1,n2)
n=n1:n2;
x=[(n-n0)==0];
%——————– end

Example
x(n)=2\delta(n+2)-\delta(n-4), -5 \leq n \leq

>>n=-5:5;
>>x=2*imseq(-2,-5,5)-imseq(4,-5,5);
>>stem(n,x)
>>n=-6:6;
>>x=3*imseq(3,-6,6)-imseq(-5,-6,6);
>>stem(n,x)
>>axis([-6.5 6.5 -1.5 3.5])

evenodd.m

%—- Even and odd part of signal
% xe(-n)=xe(n) >>Even part
%xo(-n)=-xo(n) >>Odd part
%x(n)=xe(n)+xo(n)
%—————————–
%xe(n)= \frac{1}{2} [x(n)+x(-n)]
%xo(n)= \frac{1}{2} [x(n)-x(-n)]
%—————————- Start here

function [xe,xo,m] = evenodd(x,n)
if any(imag(x)~=0)
    error('x is not real sequence ')
end
m = -fliplr(n);
m1 = min([m,n]);
m2 = max([m,n]);
m = m1:m2;
nm = n(1)-m(1);
n1 = 1:length(n);
x1 = zeros(1,length(m));
x1(n1+nm) = x;
x = x1;
xe = 0.5*(x+fliplr(x));
xo = 0.5*(x-fliplr(x));

%——– end
%မှတ်ချက်။ ။ DSP တွင် square wave တစ်ခု၏ စုံ နှင့်မ power ကိုရှာရာတွင် အသုံးပြုနိုင်သည်။

>>subplot(311)
>>%square waveform
>>%x(n)=u(n)-u(n-10), 0 ≤ n ≤ 9
>>n=0:9;
>>x=stepseq(0,0,10)-stepseq(10,0,10);
>>[xe,xo,m]=evenodd(x,n);
>>subplot(311)
>>stem(n,x)
>>title('Original')
>>subplot(312)
>>stem(m,xe)
>>title('even part')
>>subplot(313)
>>stem(m,xo)
>>title('odd part')

image
Even and Odd parts of square wave

Archimedean spiral in matlab

Simple Archimedean spiral

>>t=0:pi/20:6*pi;
>>r=t.^2;
>>x=r.*cos(t);
>>y=r.*sin(t);
>>plot(x,y);
image
Archimedean spiral

two sprials

>>t =0:pi/20:6*pi;
>>r1=sqrt(t) ;
>>r2=-sqrt(t);
>mplot(r1.*cos(t),r1.*sin(t));
>>plot(r2.*cos(t),r2.*sin(t),'r');
image
two spirals

>>t=0.1:pi/50:6*pi;
>>subplot (311)
>>r1=1./t;
>>plot(r1.*cos(t),r1.*sin(t));
>>subplot(312)
>>r2=1./sqrt(t);
>>plot(r2.*cos(t),r2.*sin(t));
>>subplot(313)
>>r3=exp(-0.1*t);
>>plot(r3.*cos(t),r3.*sin(t));
image
Logarithmic spiral, square root spiral, archimedean spiral

3D sprials

>>t=linspace(0,3*pi,50);
>>x=t.*cos(t);
>>y=t.*sin(t);
>>plot3(x,y,t,-x,-y,t,'r')

image


>>t1=0:80;
>>t2=0:80;
>>t=sort(horzcat(t1,t2));
>>x=t.*cos(t);y=t.*sin(t);
>>plot3(x,y,t)

image


Alexander Htun

Data shift register

<pD flip-flop များကိုသုံး၍ shift register အနေဖြင့်တည်ဆောက်နိုင်သည်။
D-FF ၏အထွက် Q ကို အခြား D-FF ၏ clock နှင့်ချိတ်ဆက်၍ data shift register အဖြစ်တည်ဆောက် နိုင်သည်။ သတိပြုရန်
Register များ၏ အထွက်တွင် delay အနည်းငယ်ရှိတတ်သည်။ထို delay များကို ထည့်ပေါင်းနိုင်မှသာ တိကျသော ရလဒ်ကိုရရှိမည်ဖြစ်သည်။ VLSI  modeling လုပ်ရာတွင် delay များကိုအတိအကျထည့်သွင်းနိုင်မှသာလျှင်မိမိ အလိုရှိရာ waveform ကိုရရှိလာမည်ဖြစ်သည်။

image

၎င်း၏ waveform မှာအောက်ပါအတိုင်းဖြစ်သည်။

image

Alexander Htun

Up Down Counter

အောက်တွင် ဖော်ပြထားသည့် ပုံသည် MATLAB/SIMULINK ကိုသုံး၍ up down counter တစ်ခုကို တည်ဆောက်ထားခြင်းဖြစ်သည်။ ဤ counter တွင် FF 4 ခုပါဝင်သည်။ ထိုကြောင့် ၎င်း၏ mode မှာ 16 ဖြစ်သည်။ MOD တွက်သည့် equation မှာ

2^4=16 

ဖြစ်သည်
စုစုပေါင်းရေတွက်မည့်ဂဏန်းအရေအတွက်မှာ

2^{4}-1=15 

ဖြစ်သည်။
ထို့ကြောင့်နောက်ဆုံး ကိန်းမှာ 15 ဖြစ်သည်။ control ကို 1 ထားလျှင်၎င်း၏ output မှာ up counter ဖြစ်ပြီး၊ control ကို 0 ထားခဲ့လျှင် output သည် down counter အဖြစ်ပြုမူမည်ဖြစ်သည်။

image
Simulink model of up/down counter

subsystem တွင်ပါဝင်သည့် block များ

image
Subsystem of up down counter

Q နှင့် !Q ကိုရွေးသည့် block များ

image
Control selection

Alexander Htun

Simulink model of downcounter

JK FF များကိုသုံး၍ down counter တည်ဆောက်နိုင်သည်။ ၎င်း FF သည် binary number 1111 မှစတင်ပြီး 0000 အထိလျှော့ချရေတွက်ပေးသွားမည်ဖြစ်သည်။ ဤcounter သည် asynchronous counter အမျိုးအစားတစ်ခုဖြစ်သည်။ ၎င်း၏ output သည် clock  ပေါ်တွင်မှီခိုနေခြင်းမရှိချေ။ ပထမ JK FF ၏ အခြေစတင်ပြောင်းလဲသွားမှသာ အခြားသော FF များတွင် ပါလိုက်ပါပြောင်းလဲသွားမည်ဖြစ်သည်။ SIMULINK model တွင် JK-FF မှာ negative falling edge အနုတ်အကျစွန်း တွင်စတင်ပြီးအလုပ်လုပ်သည်။
ဤ ပုံတွင်သုံးထားသည့် MATLAB version မှာ R2010a ဖြစ်သည်။ ယင်းကို အခြား MATLAB version R2011,R2012,R2013,R2014 များတွင်သုံးနိုင်သည်။
Truth table

CLK Q1 Q2 Q3 Q4
0 1 1 1 1
1 1 1 1 0
2 1 1 0 1
3 1 1 0 0
4 1 0 1 1
5 1 0 1 0
6 1 0 0 1
7 1 0 0 0
8 0 1 1 1
9 0 1 1 0
image
Down counter

အောက်ပါ ပုံသည် FF အထွက်များကို scope တွင်ဖမ်းပြထားခြင်းဖြစ်သည်။

image
down counter wave form

Digital electronic သည်ယခုခေတ်တွင်  အလွန်အရေးပါသည့် နည်းပညာရပ်တစ်ခုဖြစ်သည်။ အသေးစိပ်နားလည်ထားပြီး Boolean equation များကို စနစ်တကျသုံးစွဲကာ ၎င်း equation များကို minimize လုပ်တတ်ရန်လိုအပ်သည်။ များသောအားဖြင့် Karnaugh map click here၊ Quine-McCluskey algorithm click here၊ Petrick’ method click here နှင့် Espresso hueristic logic minimizer click here တို့ကိုနားလည်ထားရန်လိုအပ်သည်။

Alexander Htun